local function spairs(t, order)
-- collect the keys
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
if order then
table.sort(keys, function(a,b) return order(t, a, b) end)
else
table.sort(keys)
end
local i = 0
return function()
i = i + 1
if keys[i] then
return keys[i], t[keys[i]]
end
end
end
function onSay(cid, words, param, channel)
local list = {}
local players = getPlayersOnline()
local uniqueClients = 0
for i, pid in ipairs(players) do
local ip = getPlayerIp(pid)
if not list[ip] then
list[ip] = {}
uniqueClients = uniqueClients + 1
end
list[ip][#list[ip] + 1] = pid
end
local t = {}
if (uniqueClients > 0) then
for ip,cids in spairs(list, function(t,a,b) return #t[b] < #t[a] end) do
if #cids > 1 then
t[#t+1] = "IP: "..doConvertIntegerToIp(ip).." - "..#cids
for i = 1, #cids do
t[#t+1] = "("..i..") - "..getCreatureName(cids[i])
end
end
end
if (#t == 0) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently there aren't any players with same IP address(es).")
end
doShowTextDialog(cid, 1956, table.concat(t, "\n"))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Total: "..uniqueClients.." clients with more than one connection.")
end
return true
end