• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Problem in Action (addEvent)

iurygoncalves

New Member
Joined
Aug 14, 2008
Messages
10
Reaction score
0
Why this addevent doesn't work? It teleports just one time but it doesn't take the player teleporting.

function onUse(cid, item, frompos, item2, topos)
local oldPos = getCreaturePosition(cid)
addEvent(playerMove, 100, cid, oldPos)
end

function playerMove(cid)
local newPos = getCreatureLookPosition(cid, oldPos)
if getDistanceBetween(getThingPos(cid), oldPos) == 0 then
local tmp = newPos
tmp.stackpos = 253
if getTileThingByPos({x=newPos.x, y=newPos.y, z=newPos.z}).uid ~= 0 and getTilePzInfo(newPos) == FALSE and isCreature(getThingFromPos(tmp).uid) == FALSE then
doTeleportThing(cid, newPos, false)
doSendMagicEffect(oldPos, CONST_ME_GROUNDSHAKER)
end
end
end
 
Last edited:
addEvent(playerMove, 100, cid, oldPos) << you need to add this in the function playerMove()
so when the function is excuted this event is executed again
 
1 bump per 24h, you should get that

LUA:
function onUse(cid, item, frompos, item2, topos)
local oldPos = getThingPos(cid)
addEvent(playerMove, 100, cid, oldPos)
end

function playerMove(cid, oldPos)
local newPos = getCreatureLookPosition(cid, oldPos)
	if getDistanceBetween(getThingPos(cid), oldPos) == 0 then
		local tmp = newPos
		tmp.stackpos = 253
		
		if doTileQueryAdd(cid, tmp) == 1 and getTilePzInfo(newPos) == FALSE and isCreature(getThingFromPos(tmp).uid) == FALSE then
			doTeleportThing(cid, newPos, false)
			doSendMagicEffect(oldPos, CONST_ME_GROUNDSHAKER)
			addEvent(playerMove, 100, cid, newPos)
		end
	end
end
 
Back
Top