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

Solved If same IP return fromPosition

Shackal

Alien Project
Joined
Feb 7, 2009
Messages
211
Reaction score
17
Location
Brazil
Hello guys,

Need to make a script that:
• If a player with the same ip trying to enter the tp return to function:
Code:
doTeleportThing(cid, fromPosition, true)
follow the script:
Code:
local pos = {
    go      =  {x = 899, y = 846, z = 7}
}

local function checkIpOnBattlefield(condition)
local ips = {}
local ip = getPlayerIp(cid)
   
    local i = 1
    table.insert(ips, i, ip)
    i = i + 1
        if ips[i] == getPlayerIp(cid) then
            condition = "true"
        end
    local condition
    return condition
end

function onStepIn(cid, item, position, fromPosition)
    if checkIpOnBattlefield("true") then
        doTeleportThing(cid, fromPosition, true)
        doBroadcastMessage(ips[1])
    else
        doBroadcastMessage(getPlayerIp(cid))
        doTeleportThing(cid, pos.go, true)
        doSendMagicEffect(pos.go, 10)
    end
    return true
end
 
You can see here how you can do it.
https://otland.net/threads/reward-commands-without-mc.227177/#post-2189843

So basicly all you have to do is insert the ip into a table, then check with isInArray if the player ip is in the table.
Add the local ips table outside any function, so it will keep the ips in the table when more characters step on the tile.
If it needs to be an empty table again after a while you can just do: ips = {} when that should happen.
 
Code:
function onStepIn(cid, item, position, fromPosition)
    local list = {}
    local ips = {}
    local players = getPlayersOnline()
    for i, pid in ipairs(players) do
        local ip = getPlayerIp(pid)
        local tmp = table.find(ips, ip)
        if(tmp ~= nil) 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 getPlayerIp(cid) == ip then
                doTeleportThing(cid,fromPosition,true)
                doPlayerPopupFYI(cid, '                 Alert: Events allow one player per IP  \nDuplicate IP found for: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'. Please close multi-client.')
            return true
        end
    end
end
return true
end
 
Back
Top