• 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!

TFS 0.X HELP ME PLEASE ON THIS SCRIPT!

lSenturion2

Active Member
Joined
Oct 2, 2019
Messages
124
Reaction score
29
I need help with this:
The command /mc shows the players with same IP, but y it shows on : doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,...
I need this shows on: doShowTextDialog
Like this:Sin título.png
 
Solution
If I did get you right, this is what you want:

Lua:
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)...
doShowTextDialog(cid, text)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, text)

Literally just swap the function.
You already told us what you wanted to do. xD
 
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
 
If I did get you right, this is what you want:

Lua:
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
        local str = ""
        for pid, ip in pairs(list) do
            str = str .. getCreatureName(pid) .. " (" .. doConvertIntegerToIp(ip) .. ")\n"
        end
        doShowTextDialog(cid, 2175, "Currently online players with same IP address(es):\n\n" .. str)
    else
        doShowTextDialog(cid, 2175, "Currently there aren't any players with same IP address(es).")
    end

    return true
end
 
Solution
I had already created it, feel free to use either

Lua:
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
 
Back
Top