10-06-2014, 04:53 AM 
		
	
	(10-06-2014, 04:07 AM)STR_Warrior Wrote: https://forum.cuberite.org/showthread.ph...5#pid11875 ?
Okay this is better then a plugin that disables use of items.
| 
				
				 
					Prevent 1.8 clients from joining?
				 
			 | 
		
| 
	 
		
		
		10-06-2014, 04:53 AM 
		
	 
	(10-06-2014, 04:07 AM)STR_Warrior Wrote: https://forum.cuberite.org/showthread.ph...5#pid11875 ? Okay this is better then a plugin that disables use of items. 
		
		
		10-06-2014, 04:56 AM 
		
	 
	(10-06-2014, 04:07 AM)STR_Warrior Wrote: https://forum.cuberite.org/showthread.ph...5#pid11875 ?I've tried this plugin, but I don't know how to allow only 1.7 clients to join. It does prevent older clients than 1.7 from joining, but not 1.8 clients. 
		
		
		10-06-2014, 04:59 AM 
		
	 
	
		If you set AllowedProtocols to "4,5" it should only allow 1.7 clients.
	 
	
	
	
	
		
		
		10-06-2014, 05:12 AM 
		
	 
	
	
	
	
	
		
		
		10-06-2014, 05:15 AM 
		
	 
	
		That's weird. It should work with every protocol, since I coded it so that it's dynamic. Do you get an error?
	 
	
	
	
	
		
		
		10-06-2014, 05:20 AM 
		
	 
	
	
	
	
	
		
		
		10-06-2014, 05:34 AM 
		
	 
	
		And 1.6? Did it even load correctly? Do you see "Initialized ProtLimit" in the console?
	 
	
	
	
	
		
		
		10-06-2014, 05:39 AM 
		
	 
	
	
	
	
	
		Oh right. I forgot that  
	
	
	
	
  Thanks.So then does anyone see a problem here (Exept the style problems): 
PLUGIN = nil
AllowedProtocols = {}
KickMessage = ""
function Initialize(Plugin)
	PLUGIN = Plugin
	Plugin:SetName("ProtLimit")
	Plugin:SetVersion(1)
	
	cPluginManager.AddHook(cPluginManager.HOOK_LOGIN, OnLogin)
	
	if not LoadSettings() then
		LOGERROR("ProtLimit: Could not load " .. PLUGIN:GetLocalFolder() .. "/Config.ini")
		return false
	end
	
	LOG("Initialized ProtLimit")
	return true
end
function OnLogin(Client, ProtocolVersion, UserName)
	for Idx, Prot in ipairs(AllowedProtocols) do
		if Prot == ProtocolVersion then
			return false
		end
	end
	
	cRoot:Get():GetDefaultWorld():ScheduleTask(1, function()
		cRoot:Get():FindAndDoWithPlayer(UserName, function(Player)
			if Player:GetName() ~= UserName then
				return false
			end
			Player:GetClientHandle():Kick(KickMessage)
		end)
	end)
	return false
end
function LoadSettings()
	local SettingsIni = cIniFile()
	SettingsIni:ReadFile(PLUGIN:GetLocalFolder() .. "/Config.ini")
	local AllowedProtString = SettingsIni:GetValueSet("General", "AllowedProtocols", 4)
	local RawAllowedProtocols = StringSplitAndTrim(AllowedProtString, ",")
	for Idx, Value in ipairs(RawAllowedProtocols) do
		if tonumber(Value) ~= nil then
			table.insert(AllowedProtocols, tonumber(Value))
		else
			LOGERROR("Protocol version \"" .. Value .. "\" isn't valid. Ignoring")
		end
	end
	
	KickMessage = SettingsIni:GetValueSet("General", "KickMessage", "You do not have the right client version.")
	SettingsIni:WriteFile(PLUGIN:GetLocalFolder() .. "/Config.ini")
	return true
end
	
	
	 | 
| 
				
	 
					« Next Oldest | Next Newest »
				 
			 |