- Joined
- Dec 11, 2007
- Messages
- 3,666
- Solutions
- 1
- Reaction score
- 125
- Location
- Warsaw, Poland
- GitHub
- tayandenga
- Twitch
- tayandenga
Note: This talkaction is included to TheForgottenServer 0.3 since Alpha 3.
Create multicheck.lua located in data/talkactions/scripts and paste there:
Open talkactions.xml located in data/talkactions and add there:
Now you need to add the following functions to global.lua:
Note: If you're using other distribution than TFS, please make sure that you have the following function: getIPByPlayerName or getIPByName.
Create multicheck.lua located in data/talkactions/scripts and paste there:
Code:
function onSay(cid, words, param)
if(getPlayerAccess(cid) == 0) then
return TRUE
end
local players = getOnlinePlayers()
local IPs = {}
local multiClients = {}
local multiClientIPs = {}
for i, player in ipairs(players) do
local ip = getIPByName(player)
local pos = table.find(IPs, ip)
if(pos ~= nil) then
if(not table.isStrIn(players[pos], multiClients)) then
table.insert(multiClients, players[pos])
table.insert(multiClientIPs, ip)
end
table.remove(players, pos)
table.remove(IPs, pos)
table.insert(multiClients, player)
table.insert(multiClientIPs, ip)
end
table.insert(IPs, ip)
end
if(table.maxn(multiClients) > 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently online players with same IP address(es):")
for i, multiClient in ipairs(multiClients) do
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, multiClient .. " (" .. convertIntToIP(multiClientIPs[i]) .. ")")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently there aren't any players with same IP address(es).")
end
return FALSE
end
Code:
<talkaction words="/mc" script="multicheck.lua"/>
Now you need to add the following functions to global.lua:
Code:
function convertIntToIP(int, mask)
local mask = mask or 4294967295
local b4 = bit.urshift(bit.uband(int, 4278190080), 24)
local b3 = bit.urshift(bit.uband(int, 16711680), 16)
local b2 = bit.urshift(bit.uband(int, 65280), 8)
local b1 = bit.urshift(bit.uband(int, 255), 0)
if(mask ~= nil) then
local m4 = bit.urshift(bit.uband(mask, 4278190080), 24)
local m3 = bit.urshift(bit.uband(mask, 16711680), 16)
local m2 = bit.urshift(bit.uband(mask, 65280), 8)
local m1 = bit.urshift(bit.uband(mask, 255), 0)
if((m1 == 255 or m1 == 0) and (m2 == 255 or m2 == 0) and (m3 == 255 or m3 == 0) and (m4 == 255 or m4 == 0)) then
if m1 == 0 then b1 = "x" end
if m2 == 0 then b2 = "x" end
if m3 == 0 then b3 = "x" end
if m4 == 0 then b4 = "x" end
else
if(m1 ~= 255 or m2 ~= 255 or m3 ~= 255 or m4 ~= 255) then
return b1 .. "." .. b2 .. "." .. b3 .. "." .. b4 .. " : " .. m1 .. "." .. m2 .. "." .. m3 .. "." .. m4
end
end
end
return b1 .. "." .. b2 .. "." .. b3 .. "." .. b4
end
table.isStrIn = function (txt, str)
local result = false
for i, v in pairs(str) do
result = (string.find(txt, v) and not string.find(txt, '(%w+)' .. v) and not string.find(txt, v .. '(%w+)'))
if(result) then
break
end
end
return result
end
getIPByName = getIPByPlayerName
Note: If you're using other distribution than TFS, please make sure that you have the following function: getIPByPlayerName or getIPByName.
Last edited: