zbizu
Legendary OT User
This script allows you to prevent players from playing clients that aren't whitelisted by the script
preview:
creaturescripts.xml:
creaturescripts/scripts/client_control.lua:
preview:
creaturescripts.xml:
XML:
<event type="login" name="clientControlLogin" script="client_control.lua" />
<event type="think" name="clientControl" interval="5000" script="client_control.lua" />
creaturescripts/scripts/client_control.lua:
Lua:
--[[
available clients to whitelist:
CLIENTOS_LINUX
CLIENTOS_WINDOWS
CLIENTOS_FLASH
CLIENTOS_OTCLIENT_LINUX
CLIENTOS_OTCLIENT_WINDOWS
CLIENTOS_OTCLIENT_MAC
]]
-- config
local whitelist = {CLIENTOS_WINDOWS, CLIENTOS_LINUX}
local msg = "This game client is not supported on the server."
-- end config
-- do not touch
local tibiaClient = {CLIENTOS_WINDOWS, CLIENTOS_LINUX}
local function forceLogout(cid)
local player = Player(cid)
if player then
local tile = player:getTile()
if not (tile:hasFlag(TILESTATE_NOLOGOUT) or (player:hasCondition(CONDITION_INFIGHT) and not tile:hasFlag(TILESTATE_PROTECTIONZONE))) then
player:remove()
end
end
end
function onLogin(player)
player:registerEvent("clientControl")
return true
end
function onThink(player, interval)
local clientType = player:getClient().os
if not isInArray(whitelist, clientType) then
if isInArray(tibiaClient, clientType) then
-- tibia client
local m = ModalWindow()
m:setTitle("Error")
m:setMessage(msg)
m:addButton(1, "ok")
m:sendToPlayer(player)
else
-- ot client
local m = NetworkMessage()
m:addByte(0x14)
m:addString(msg)
m:sendToPlayer(player)
end
addEvent(forceLogout, 100, player:getId())
end
return true
end