local ipTable = {}
function getPlayersConnected(ip)
return ipTable[ip] or 0
end
--<event type="login" name="ip counter login" script="x.lua"/>
function onLogin(player)
local ip = player:getIp()
ipTable[ip] = ipTable[ip] and ipTable[ip] + 1 or 1
return true
end
--<event type="logout" name="ip counter logout" script="x.lua"/>
function onLogout(player)
local ip = player:getIp()
ipTable[ip] = ipTable[ip] and ipTable[ip] - 1 or nil
return true
end
if getPlayersConnected(player:getIp()) >= 2 then
--
end
local ipTable = {}
function getPlayersConnected(ip)
return ipTable[ip] or 0
end
--<event type="login" name="ip counter login" script="x.lua"/>
function onLogin(player)
local ip = player:getIp()
ipTable[ip] = ipTable[ip] and ipTable[ip] + 1 or 1
return true
end
--<event type="logout" name="ip counter logout" script="x.lua"/>
function onLogout(player)
local ip = player:getIp()
ipTable[ip] = ipTable[ip] and ipTable[ip] - 1 or nil
return true
end
if getPlayersConnected(player:getIp()) >= 2 then
--
end
make sure this is all in 1 file, i commented what you should register in creaturescripts.xml
LUA:local ipTable = {} function getPlayersConnected(ip) return ipTable[ip] or 0 end --<event type="login" name="ip counter login" script="x.lua"/> function onLogin(player) local ip = player:getIp() ipTable[ip] = ipTable[ip] and ipTable[ip] + 1 or 1 return true end --<event type="logout" name="ip counter logout" script="x.lua"/> function onLogout(player) local ip = player:getIp() ipTable[ip] = ipTable[ip] and ipTable[ip] - 1 or nil return true end
to get amount of ips connected:
LUA:if getPlayersConnected(player:getIp()) >= 2 then -- end
yes, getPlayersConnected(ip) is global, so you can use it anywhereIts for talkactions, I can use this function inside talkactions too right?
yes, getPlayersConnected(ip) is global, so you can use it anywhere