• 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 [movements] Anti-MC in Area

subyth

New Member
Joined
May 1, 2009
Messages
56
Reaction score
4
Well, this script works like a wrong way.

Check the X player in the area and if you have the same IP, player Y is taken to the temple.

But if player Y enters before player X, nothing happens.

Lua:
local playersPorIp = 1
local tp_temple_mineracao = {x = 2052, y = 2051, z = 7}
local tp_mineracao = {x = 1848, y = 1871, z = 8}
local areasMineracao = {
[1] = {{x = 1803, y = 1861, z = 8}, {x = 1864, y = 1896, z = 8}},
[2] = {{x = 1799, y = 1864, z = 9}, {x = 1869, y = 1903, z = 9}},
[3] = {{x = 1802, y = 1876, z = 10}, {x = 1894, y = 1923, z = 10}}
}

function onStepIn(cid, item, position, fromPosition, toPosition)
if (not isPlayer(cid)) then
        return false
    end

    for _, v in pairs(areasMineracao) do
        for _, pid in pairs(getPlayersOnline()) do
            if (getPlayerIp(pid) > 1 and isInRange(getThingPos(pid), v[1], v[2])) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Só é permitido 1 jogador por IP na mineração.")
                doTeleportThing(cid, tp_temple_mineracao, false)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                return true
            else
                doTeleportThing(cid, tp_mineracao, false)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                return true
            end
        end
    end
    return true
end
 
Solution
Your code was returning true before it had finished the checks.
Do the teleport at the very bottom, after it has checked the entire list (if true it "return true", if not let it continue.

Lua:
local tp_temple_mineracao = {x = 2052, y = 2051, z = 7}
local tp_mineracao = {x = 1848, y = 1871, z = 8}
local areasMineracao = {
[1] = {{x = 1803, y = 1861, z = 8}, {x = 1864, y = 1896, z = 8}},
[2] = {{x = 1799, y = 1864, z = 9}, {x = 1869, y = 1903, z = 9}},
[3] = {{x = 1802, y = 1876, z = 10}, {x = 1894, y = 1923, z = 10}}
}
function onStepIn(cid, item, position, fromPosition, toPosition)
if (not isPlayer(cid)) then
        return false
    end
    for _, v in pairs(areasMineracao) do
        for _, pid in pairs(getPlayersOnline()) do...
Your code was returning true before it had finished the checks.
Do the teleport at the very bottom, after it has checked the entire list (if true it "return true", if not let it continue.

Lua:
local tp_temple_mineracao = {x = 2052, y = 2051, z = 7}
local tp_mineracao = {x = 1848, y = 1871, z = 8}
local areasMineracao = {
[1] = {{x = 1803, y = 1861, z = 8}, {x = 1864, y = 1896, z = 8}},
[2] = {{x = 1799, y = 1864, z = 9}, {x = 1869, y = 1903, z = 9}},
[3] = {{x = 1802, y = 1876, z = 10}, {x = 1894, y = 1923, z = 10}}
}
function onStepIn(cid, item, position, fromPosition, toPosition)
if (not isPlayer(cid)) then
        return false
    end
    for _, v in pairs(areasMineracao) do
        for _, pid in pairs(getPlayersOnline()) do
            if (getPlayerIp(pid) == getPlayerIp(cid) and isInRange(getThingPos(pid), v[1], v[2])) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Só é permitido 1 jogador por IP na mineração.")
                doTeleportThing(cid, tp_temple_mineracao, false)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                return true
            end
        end
    end
     doTeleportThing(cid, tp_mineracao, false)
      doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    return true
end

also you get the players online, but you don't check the ip addresses are the same.
I don't have a working version of tfs 0.x to test it, but i have it working with tfs 1.2
 
Last edited:
Solution
Your code was returning true before it had finished the checks.
Do the teleport at the very bottom, after it has checked the entire list (if true it "return true", if not let it continue.

Lua:
local tp_temple_mineracao = {x = 2052, y = 2051, z = 7}
local tp_mineracao = {x = 1848, y = 1871, z = 8}
local areasMineracao = {
[1] = {{x = 1803, y = 1861, z = 8}, {x = 1864, y = 1896, z = 8}},
[2] = {{x = 1799, y = 1864, z = 9}, {x = 1869, y = 1903, z = 9}},
[3] = {{x = 1802, y = 1876, z = 10}, {x = 1894, y = 1923, z = 10}}
}
function onStepIn(cid, item, position, fromPosition, toPosition)
if (not isPlayer(cid)) then
        return false
    end
    for _, v in pairs(areasMineracao) do
        for _, pid in pairs(getPlayersOnline()) do
            if (getPlayerIp(pid) == getPlayerIp(cid) and isInRange(getThingPos(pid), v[1], v[2])) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Só é permitido 1 jogador por IP na mineração.")
                doTeleportThing(cid, tp_temple_mineracao, false)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                return true
            end
        end
    end
     doTeleportThing(cid, tp_mineracao, false)
      doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    return true
end

also you get the players online, but you don't check the ip addresses are the same.
I don't have a working version of tfs 0.x to test it, but i have it working with tfs 1.2

Work! Thx!!!
 
Back
Top