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

Teleport players in area

kokokoko

Veteran OT User
Joined
Feb 4, 2008
Messages
921
Reaction score
257
What i want it to do: When the creature Tormented Soul is killed, teleport all players in the area specified to the coordinates specified. I get no errors in the console.

Problem: The player(s) standing in that area does not get teleported.

Lua:
  local config = {
    bossname = "Tormented Soul",
    globalStorage = 1000,
    setTo = 0
}

function onDeath(cid, corpse, killer)
    if config.bossname == getCreatureName(cid) then
        if getGlobalStorageValue(config.globalStorage) >= 1 then
            setGlobalStorageValue(config.globalStorage, 0)
        end    
    end
for x = 1010, 1013 do
	for y = 1173, 1177 do
		getPos = getThingfromPos({x=x, y=y, z=7})
		if isPlayer(getPos.uid) then
	doTeleportThing(getPos.uid, {x=1017, y=1175, z=8})
		end
	end
end
return TRUE
end

Thanks in advance,
//Kokokoko
 
Tr this one: :D

Lua:
  local config = {
    bossname = "Tormented Soul",
    globalStorage = 1000,
    setTo = 0,
	toPos = {x=1013, y=1177, z=7},
	fromPos = {x=1010, y=1173, z=7}
}

function onDeath(cid, corpse, killer)
    if config.bossname == getCreatureName(cid) then
        if getGlobalStorageValue(config.globalStorage) >= 1 then
            setGlobalStorageValue(config.globalStorage, 0)
        end    
    end
local players = getPlayersOnline()
	for k, pid in ipairs(players) do
	local pos = getPlayerPosition(pid)
		if (isInArea(pos, config.fromPos, config.toPos) == TRUE) then
			doTeleportThing(pid, {x=1017, y=1175, z=8})
		end 
	end		
return TRUE
end
 
Last edited:
Yay! Thanks alot!! :D

One thing though, could you explain what this line does? I have never understood ipairs :p
Lua:
for k, pid in ipairs(players) do
 
Haha that line as been very useful Pitufo, helped alot of requests. I don't really understand pairs well either, would love an explanation how they work, All I know is that function gets the cid of each online player.
 
Well, in "getPlayersOnline" is storaged in a table ({}) all the names online.
Example:

local table = {
[12] = {"Pitufo", "kokokoko", "Zonet"}
}

for n, names in ipairs(table) do

n = [12]
names = {"Pitufo", "kokokoko", "Zonet"}

In this case we are not using "n" since theres nothing stores in there just inside the {}.
So, "for" is a loop that will execute until it gets all the items from the table.

Well is something like that i really dont know how to explain it. :D

LUA Example:
Lua:
local names = {"Zonet", "Pitufo"}
for k, names in ipairs(names) do
doPlayerSendCancel(getPlayerByName(names), "Hello user")
end

That will send a message to all of the table :D
 
Back
Top