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

How to check if player entered in teleport?

vexler222

Member
Joined
Apr 22, 2012
Messages
364
Solutions
6
Reaction score
12
Hi, i wanna create teleport for max 10 players but idk how to check if player entred in, and set limit to 9 if next player entered, set limit to 8 ...
Something like a zombie event teleport

Someone can help me? :) TFS 0.4
 

Shadowman321

Member
Joined
Mar 27, 2010
Messages
188
Reaction score
15
Instead of simply putting in a tp with coordinates, create moveevent with onstepin, which would increase some counter (global storage?) each time someone enters. And when enough players enter tp, you can block access to tp for all others.
 

dami1310

◄ Unidentified ►
Joined
Jan 27, 2013
Messages
624
Solutions
8
Reaction score
529
Location
Poland
You can also scan the whole area the players are supposed to be teleport to.
Code:
local topLeft = {x = ??, y = ??, z = ??} --top-left-corner of the room that players are teleported to
local bottomRight = {x = ??, y = ??, z = ??} --bottom-right-corner of the room that players are teleported to     JUST MAKE SURE THAT TOP LEFT AND BOT RIGHT HAVE LOWEST AND HIGHEST Z COORDINATE (if topleft have lowest then bottomright should be highest)
local destinationPos = {x = ??, y = ??, z = ??}
local count = 0 -- dont change
maxPlayers = 10 --how many players can enter

for z = topLeft.z, bottomRight.z do
    for x = topLeft.x, bottomRight.x do
        for y = topLeft.y, bottomRight.x do
            for f = 1, maxPlayers do
                local whatisit = getTopCreature({x=x,y=y,z=z, stackpos = f+1}).uid
                if isPlayer(whatisit) == TRUE then
                    count=count+1
                end
            end
        end
    end
end

if count >= 10 then
    doPlayerSendCancel(cid, "You shall not pass!")
return false
else
    doTeleportThing(cid, destinationPos)
end
 
Top