• 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 player (as global event)

Magictibiaman

New Member
Joined
May 25, 2009
Messages
371
Reaction score
0
i am trying to make it so every 30 seconds a person gets teleported from a square using a global event
i'm close but what have i done wrong?
Code:
function onThink(interval, lastExecution)

	random = math.random(0,3)
	local pos = {x=502, y=510, z=8, stackpos=253}

	if(random == 0) then
		pos = {x=502, y=510, z=8, stackpos=253}
	elseif(random == 1) then
		pos = {x=497, y=505, z=8, stackpos=253}
	elseif(random == 2) then
		pos = {x=507, y=505, z=8, stackpos=253}
	elseif(random == 3) then
		pos = {x=502, y=501, z=8, stackpos=253}
	end

	player1pos = {x=524, y=522, z=7, stackpos=253}
	player1 = getThingfromPos(player1pos)

      doTeleportThing(player1.uid,pos)
      return TRUE
end
 
Code:
local t = {
	pos = {x=524, y=522, z=7},
	positions = {
		{x=502, y=510, z=8},
		{x=497, y=505, z=8},
		{x=507, y=505, z=8},
		{x=502, y=501, z=8}
	}
}
function onThink(interval, lastExecution)
	local cid = getTopCreature(t.pos).uid
	return cid > 0 and doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT) and doTeleportThing(cid, t.positions[math.random(#t.positions)]) and doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
end
 
Code:
local t = {
	pos = {x=524, y=522, z=7},
	positions = {
		{x=502, y=510, z=8},
		{x=497, y=505, z=8},
		{x=507, y=505, z=8},
		{x=502, y=501, z=8}
	}
}
function onThink(interval, lastExecution)
	local cid = getTopCreature(t.pos).uid
	return cid > 0 and doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT) and doTeleportThing(cid, t.positions[math.random(#t.positions)]) and doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
end

aff, roxx.
 
Back
Top