• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

/mc upgrade

Shadowman321

Member
Joined
Mar 27, 2010
Messages
205
Reaction score
22
Can anyone upgrade my /mc command?
Now it shows sth like this:
00:01 Currently online players with same IP address(es):
00:01 Char (213.238.78.82)
00:01 Char Iii (113.1111.22.6)
00:01 Char Ii (213.238.78.82)
00:01 Char Xx(213.238.78.82)
00:01 Char Zz (113.1111.22.6)
It's hard to know how many real players is there. How many characters specific ip has. And how many multipled characters there is.
And I want to sort it and show count of ips... Something like:
00:01 Total players on mc = 5, multi players = 3, unique ips = 2.
00:01 There is 251 players online. 3 of them are multipled. You have 248 real players online now.
00:01 IP 213.238.78.82 (3 players):
00:01 Char, Char Ii, Char Xx
00:01 IP 113.1111.22.6 (2 players):
00:01 Char Iii, Char Zz

I'm using default /mc script:
Code:
function onSay(cid, words, param, channel)
    local _ip = nil
    if(param ~= '') then
        _ip = tonumber(param)
        if(not _ip or _ip == 0) then
            local revertIp = doRevertIp(param)
            if(not revertIp) then
                local tid = getPlayerByNameWildcard(param)
                if(not tid) then
                    _ip = nil
                else
                    _ip = getPlayerIp(tid)
                end
            else
                _ip = doConvertIpToInteger(revertIp)
            end
        end
    end

    local list, ips = {}, {}
    local players = getPlayersOnline()
    for i, pid in ipairs(players) do
        local ip = getPlayerIp(pid)
        local tmp = table.find(ips, ip)
        if(tmp ~= nil and (not _ip or _ip == ip)) then
            if(table.countElements(list, ip) == 0) then
                list[players[tmp]] = ip
            end

            list[pid] = ip
        end

        table.insert(ips, ip)
    end

    if(table.maxn(list) > 0) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently online players with same IP address(es):")
        for pid, ip in pairs(list) do
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getCreatureName(pid) .. " (" .. doConvertIntegerToIp(ip) .. ")")
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently there aren't any players with same IP address(es).")
    end

    return true
end

Ahh. For sure. I'm using TFS 0.4 r3884.
Or if it is too much job to do, just sort list by ips so it get easier to count. It would be great too. ;)
 
Last edited:
I didn't figure out how to get the count yet. But this will list the IP, and characters on that IP address.

Let me know if it works.

Code:
function onSay(cid, words, param, channel)
    local _ip = nil
    if(param ~= '') then
        _ip = tonumber(param)
        if(not _ip or _ip == 0) then
            local revertIp = doRevertIp(param)
            if(not revertIp) then
                local tid = getPlayerByNameWildcard(param)
                if(not tid) then
                    _ip = nil
                else
                    _ip = getPlayerIp(tid)
                end
            else
                _ip = doConvertIpToInteger(revertIp)
            end
        end
    end

    local list, ips = {}, {}
    local mcips = {}
    local players = getPlayersOnline()
    for i, pid in ipairs(players) do
        local ip = getPlayerIp(pid)
        local tmp = table.find(ips, ip)
        if(tmp ~= nil and (not _ip or _ip == ip)) then
            if(table.countElements(list, ip) == 0) then
                list[players[tmp]] = ip
            end

            list[pid] = ip
        end

        table.insert(ips, ip)
    end
   
    if(table.maxn(list) > 0) then
        for pid, ip in pairs(list) do
            if not(isInArray(mcips, ip)) then
                table.insert(mcips, ip)
            end
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently online players with same IP address(es):")
        for i=1, table.maxn(mcips) do
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "IP: " .. doConvertIntegerToIp(mcips[i]))
            for pid, ip in pairs(list) do
                if(mcips[i] == ip) then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, " > " .. getCreatureName(pid))
                end
            end
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently there aren't any players with same IP address(es).")
    end

    return true
end
 
02:11 Currently online players with same IP address(es):
02:11 IP: 213.238.78.83
02:11 > Evry Body Love Somebody
02:11 > Distance Anastazi
02:11 > Amba Haxaver
02:11 > Mezo
02:11 > Niedzwiedzi Pazur
02:11 IP: 31.175.108.46
02:11 > Vanpp
02:11 > Askor
02:11 IP: 91.242.58.124
02:11 > Mistrz Damian
02:11 > Mistrz Daman
02:11 IP: 91.202.174.5
02:11 > Uronfire
02:11 > Xesex
02:11 IP: 77.254.111.177
02:11 > Sebek
02:11 > Maria Janina
02:11 IP: 31.175.232.20
02:11 > Gashous
02:11 > Przytul Moje Exori
Well, not 100% how I wanted it. But still. It's something. Something great and usefull . Thanks ;) Any improvements are nice to see, but not really needed more. Most important thing is done here.
 
Well, not 100% how I wanted it. But still. It's something. Something great and usefull . Thanks ;)
Yeah I know it's not exactly what you wanted, like I said I don't really know exactly what you want, and I was not able to make it collect the count of the amount of players first without making the script a bit more complicated.

Someone who is a little better with strings in lua, could help us expand and make it list the names with commas rather than an up and down direction.
 
Last edited:
Well, not 100% how I wanted it. But still. It's something. Something great and usefull . Thanks ;) Any improvements are nice to see, but not really needed more. Most important thing is done here.

How about this? =)
Code:
function onSay(cid, words, param, channel)
    local _ip = nil
    if(param ~= '') then
        _ip = tonumber(param)
        if(not _ip or _ip == 0) then
            local revertIp = doRevertIp(param)
            if(not revertIp) then
                local tid = getPlayerByNameWildcard(param)
                if(not tid) then
                    _ip = nil
                else
                    _ip = getPlayerIp(tid)
                end
            else
                _ip = doConvertIpToInteger(revertIp)
            end
        end
    end

    local list, ips = {}, {}
    local mcips = {}
    local players = getPlayersOnline()
    for i, pid in ipairs(players) do
        local ip = getPlayerIp(pid)
        local tmp = table.find(ips, ip)
        if(tmp ~= nil and (not _ip or _ip == ip)) then
            if(table.countElements(list, ip) == 0) then
                list[players[tmp]] = ip
            end

            list[pid] = ip
        end

        table.insert(ips, ip)
    end
    if(table.maxn(list) > 0) then
        for pid, ip in pairs(list) do
            if not(isInArray(mcips, ip)) then
                table.insert(mcips, ip)
            end
        end
     
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently online players with same IP address(es):")
        for i=1, table.maxn(mcips) do
            local strings = {""}
            local z, position = 1, 1
            local added = false
            for pid, ip in pairs(list) do
                if(mcips[i] == ip) then
                    if(added) then
                        if(z > (position * 6)) then
                            strings[position] = strings[position] .. ","
                            position = position + 1
                            strings[position] = ""
                        else
                            strings[position] = z == 1 and "" or strings[position] .. ", "
                        end
                    end
                 
                    strings[position] = strings[position] .. getCreatureName(pid)
                    z = z + 1
                    added = true
                end
            end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "IP: "..doConvertIntegerToIp(mcips[i]).." ("..(z - 1).." Players)" )
            for z, str in ipairs(strings) do
                if(str:sub(str:len()) ~= ",") then
                    str = str .. "."
                end
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
            end
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently there aren't any players with same IP address(es).")
    end

    return true
end
 
Last edited:
21:40 Currently online players with same IP address(es):
21:40 IP: 31.175.57.100 (11 Players)
21:40 Gashous, Szuszkin, Mistrz Daman, Maria Janina, Przytul Moje Exori, Pixie,
21:40 Pixie Morduje, Mistrz Damian, Roshado, Sebek, Ramzes.
21:40 IP: 83.7.255.178 (22 Players)
21:40 Gashous, Szuszkin, Mistrz Daman, Maria Janina, Przytul Moje Exori, Pixie,
21:40 Pixie Morduje, Mistrz Damian, Roshado, Sebek, Ramzes, Gashous,
21:40 Szuszkin, Mistrz Daman, Maria Janina, Przytul Moje Exori, Pixie, Pixie Morduje,
21:40 Mistrz Damian, Roshado, Sebek, Ramzes.
21:40 IP: 91.242.57.179 (33 Players)
21:40 Gashous, Szuszkin, Mistrz Daman, Maria Janina, Przytul Moje Exori, Pixie,
21:40 Pixie Morduje, Mistrz Damian, Roshado, Sebek, Ramzes, Gashous,
21:40 Szuszkin, Mistrz Daman, Maria Janina, Przytul Moje Exori, Pixie, Pixie Morduje,
21:40 Mistrz Damian, Roshado, Sebek, Ramzes, Gashous, Szuszkin,
21:40 Mistrz Daman, Maria Janina, Przytul Moje Exori, Pixie, Pixie Morduje, Mistrz Damian,
21:40 Roshado, Sebek, Ramzes.
21:40 IP: 178.36.135.245 (44 Players)
21:40 Gashous, Szuszkin, Mistrz Daman, Maria Janina, Przytul Moje Exori, Pixie,
21:40 Pixie Morduje, Mistrz Damian, Roshado, Sebek, Ramzes, Gashous,
21:40 Szuszkin, Mistrz Daman, Maria Janina, Przytul Moje Exori, Pixie, Pixie Morduje,
21:40 Mistrz Damian, Roshado, Sebek, Ramzes, Gashous, Szuszkin,
21:40 Mistrz Daman, Maria Janina, Przytul Moje Exori, Pixie, Pixie Morduje, Mistrz Damian,
21:40 Roshado, Sebek, Ramzes, Gashous, Szuszkin, Mistrz Daman,
21:40 Maria Janina, Przytul Moje Exori, Pixie, Pixie Morduje, Mistrz Damian, Roshado,
21:40 Sebek, Ramzes.
21:40 IP: 89.229.69.239 (55 Players)
21:40 Gashous, Szuszkin, Mistrz Daman, Maria Janina, Przytul Moje Exori, Pixie,
21:40 Pixie Morduje, Mistrz Damian, Roshado, Sebek, Ramzes, Gashous,
21:40 Szuszkin, Mistrz Daman, Maria Janina, Przytul Moje Exori, Pixie, Pixie Morduje,
21:40 Mistrz Damian, Roshado, Sebek, Ramzes, Gashous, Szuszkin,
21:40 Mistrz Daman, Maria Janina, Przytul Moje Exori, Pixie, Pixie Morduje, Mistrz Damian,
21:40 Roshado, Sebek, Ramzes, Gashous, Szuszkin, Mistrz Daman,
21:40 Maria Janina, Przytul Moje Exori, Pixie, Pixie Morduje, Mistrz Damian, Roshado,
21:40 Sebek, Ramzes, Gashous, Szuszkin, Mistrz Daman, Maria Janina,
21:40 Przytul Moje Exori, Pixie, Pixie Morduje, Mistrz Damian, Roshado, Sebek,
21:40 Ramzes.
Bad. Really bad.
There is prev version used same time:
21:40 Currently online players with same IP address(es):
21:40 IP: 31.175.57.100
21:40 Gashous
21:40 Przytul Moje Exori
21:40 Roshado
21:40 IP: 83.7.255.178
21:40 Szuszkin
21:40 Ramzes
21:40 IP: 91.242.57.179
21:40 Mistrz Daman
21:40 Mistrz Damian
21:40 IP: 178.36.135.245
21:40 Maria Janina
21:40 Sebek
21:40 IP: 89.229.69.239
21:40 Pixie
21:40 Pixie Morduje
 
ha whoops, sorry did not have environment to test it in, but it's a start. I will go from there. thanks for results.
 
This should do the trick
Code:
function onSay(cid, words, param, channel)
    local _ip = nil
    if(param ~= '') then
        _ip = tonumber(param)
        if(not _ip or _ip == 0) then
            local revertIp = doRevertIp(param)
            if(not revertIp) then
                local tid = getPlayerByNameWildcard(param)
                if(not tid) then
                    _ip = nil
                else
                    _ip = getPlayerIp(tid)
                end
            else
                _ip = doConvertIpToInteger(revertIp)
            end
        end
    end

    local list, ips = {}, {}
    local mcips = {}
    local players = getPlayersOnline()
    for i, pid in ipairs(players) do
        local ip = getPlayerIp(pid)
        local tmp = table.find(ips, ip)
        if(tmp ~= nil and (not _ip or _ip == ip)) then
            if(table.countElements(list, ip) == 0) then
                list[players[tmp]] = ip
            end

            list[pid] = ip
        end

        table.insert(ips, ip)
    end
    if(table.maxn(list) > 0) then
        for pid, ip in pairs(list) do
            if not(isInArray(mcips, ip)) then
                table.insert(mcips, ip)
            end
        end
     
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently online players with same IP address(es):")
        for i=1, table.maxn(mcips) do
            local strings = {""}
            local z, position = 1, 1
            local added = false
            for pid, ip in pairs(list) do
                if(mcips[i] == ip) then
                    if(added) then
                        if(z > (position * 6)) then
                            strings[position] = strings[position] .. ","
                            position = position + 1
                            strings[position] = ""
                        else
                            strings[position] = z == 1 and "" or strings[position] .. ", "
                        end
                    end
                 
                    strings[position] = strings[position] .. getCreatureName(pid)
                    z = z + 1
                    added = true
                end
            end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "IP: "..doConvertIntegerToIp(mcips[i]).." ("..(z - 1).." Players)" )
            for z, str in ipairs(strings) do
                if(str:sub(str:len()) ~= ",") then
                    str = str .. "."
                end
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
            end
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently there aren't any players with same IP address(es).")
    end

    return true
end
 
Last edited:
Well... Better, but still:
03:36 Currently online players with same IP address(es):
03:36 IP: 31.175.57.100 (13 Players)
03:36 Gashous, Maria Janina, Pixie, Pixie Morduje, Mistrz Daman, Uronfire,
03:36 Przytul Moje Exori, Szuszkin, Xesex, Mistrz Damian, Roshado, Sebek,
03:36 Ramzes.
03:36 IP: 178.36.135.245 (13 Players)
03:36 Gashous, Maria Janina, Pixie, Pixie Morduje, Mistrz Daman, Uronfire,
03:36 Przytul Moje Exori, Szuszkin, Xesex, Mistrz Damian, Roshado, Sebek,
03:36 Ramzes.
03:36 IP: 89.229.69.239 (13 Players)
03:36 Gashous, Maria Janina, Pixie, Pixie Morduje, Mistrz Daman, Uronfire,
03:36 Przytul Moje Exori, Szuszkin, Xesex, Mistrz Damian, Roshado, Sebek,
03:36 Ramzes.
03:36 IP: 91.242.58.54 (13 Players)
03:36 Gashous, Maria Janina, Pixie, Pixie Morduje, Mistrz Daman, Uronfire,
03:36 Przytul Moje Exori, Szuszkin, Xesex, Mistrz Damian, Roshado, Sebek,
03:36 Ramzes.
03:36 IP: 91.202.174.5 (13 Players)
03:36 Gashous, Maria Janina, Pixie, Pixie Morduje, Mistrz Daman, Uronfire,
03:36 Przytul Moje Exori, Szuszkin, Xesex, Mistrz Damian, Roshado, Sebek,
03:36 Ramzes.
03:36 IP: 83.7.255.178 (13 Players)
03:36 Gashous, Maria Janina, Pixie, Pixie Morduje, Mistrz Daman, Uronfire,
03:36 Przytul Moje Exori, Szuszkin, Xesex, Mistrz Damian, Roshado, Sebek,
03:36 Ramzes.

At least, maybe that "13 players" can be used to do this smoehow?
00:01 Total players on mc = 5, multi players = 3, unique ips = 2.
00:01 There is 251 players online. 3 of them are multipled. You have 248 real players online now.
 
Well... Better, but still:


At least, maybe that "13 players" can be used to do this smoehow?
Yeah I can probably do that for you too after I get this finished, it's bugging me that I keep messing up xD, the code is getting closer, like I said, I don't have an environment to actually test the script, I can only run it to check for errors, but here is another update, something I overlooked I just changed.
Code:
function onSay(cid, words, param, channel)
    local _ip = nil
    if(param ~= '') then
        _ip = tonumber(param)
        if(not _ip or _ip == 0) then
            local revertIp = doRevertIp(param)
            if(not revertIp) then
                local tid = getPlayerByNameWildcard(param)
                if(not tid) then
                    _ip = nil
                else
                    _ip = getPlayerIp(tid)
                end
            else
                _ip = doConvertIpToInteger(revertIp)
            end
        end
    end

    local list, ips = {}, {}
    local mcips = {}
    local players = getPlayersOnline()
    for i, pid in ipairs(players) do
        local ip = getPlayerIp(pid)
        local tmp = table.find(ips, ip)
        if(tmp ~= nil and (not _ip or _ip == ip)) then
            if(table.countElements(list, ip) == 0) then
                list[players[tmp]] = ip
            end

            list[pid] = ip
        end

        table.insert(ips, ip)
    end

    if(table.maxn(list) > 0) then
        for pid, ip in pairs(list) do
            if not(isInArray(mcips, ip)) then
                table.insert(mcips, ip)
            end
        end
      
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently online players with same IP address(es):")
        for i=1, table.maxn(mcips) do
            local strings = {""}
            local z, position = 1, 1
            local added = false
            for pid, ip in pairs(list) do
                if(mcips[i] == ip) then
                    if(added) then
                        if(z > (position * 6)) then
                            strings[position] = strings[position] .. ","
                            position = position + 1
                            strings[position] = ""
                        else
                            strings[position] = z == 1 and "" or strings[position] .. ", "
                        end
                    end
                  
                    strings[position] = strings[position] .. getCreatureName(pid)
                    z = z + 1
                    added = true
                end
            end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "IP: "..doConvertIntegerToIp(mcips[i]).." ("..(z - 1).." Players)" )
            for z, str in ipairs(strings) do
                if(str:sub(str:len()) ~= ",") then
                    str = str .. "."
                end
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
            end
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently there aren't any players with same IP address(es).")
    end

    return true
end
 
02:38 Currently online players with same IP address(es):
02:38 IP: 37.128.112.43 (2 Players)
02:38 Ordor Lucyon, Baba Da Lorde.
02:38 IP: 34.231.232.211 (3 Players)
02:38 Beautiful Existence, Iwonder, Raw.
02:38 IP: 91.202.174.5 (2 Players)
02:38 Xesex, Uronfire.
02:38 IP: 91.242.59.247 (2 Players)
02:38 Mistrz Daman, Mistrz Damian.

Looks good. Maybe some sorting(3 players before 2 players) and first 2 lines and its really done :O
 
Looks good. Maybe some sorting(3 players before 2 players) and first 2 lines and its really done :O

I will look into it, but I may need help with that part, because initially it checks by the order of online players, so I have to figure out how to get the count of players per ip back when it's creating mcips table and figure out how to organize the table based on that. currently on my phone. Will try another time.
 
Back
Top