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

[Help] Teleport won't disepear

Fragdonut

Banned User
Joined
Jul 27, 2009
Messages
2,606
Reaction score
0
Location
HDUXZZZ13387
I want this teleport to disepear after 20 seconds, however, it doesn't work.
Here's the script:
Code:
function onDeath(cid, corpse, killer)

registerCreatureEvent(cid, "werewolfded")

local creaturename = getCreatureName(cid)
local in_pos = {x=1091, y=1652, z=7, stackpos=2}
local checkIID = getThingFromPos(in_pos)
local to_pos = {x=1125, y=1658, z=7, stackpos=1}
local time_to_pass = 2 -- in seconds
local tpID = 1387

if creaturename == 'The Werewolf' then

teleport = doCreateTeleport(tpID, to_pos, in_pos)

doSendMagicEffect(in_pos, CONST_ME_TELEPORT)

doCreatureSay(cid, "You have 20 seconds to enter the teleport before it is closed.", TALKTYPE_ORANGE_1)
addEvent(removeTeleport, (1000*2))


end
end

function removeTeleport()
	if getThingFromPos({x=1091, y=1652, z=7, stackpos=2}).itemid == 1387 then
	doRemoveItem(getThingFromPos({x=1091, y=1652, z=7, stackpos=1}).uid,1)
	doSendMagicEffect({x=1091, y=1652, z=7, stackpos=1}, CONST_ME_POFF)
	return TRUE
	end
end
 
Last edited:
Yes :thumbup:

w/e :blink:

Lua:
local config = {
	positions = { { x = 1091, y = 1652, z = 7, stackpos = 1 }, { x = 1125, y = 1658, z = 7 } }, -- Teleport Position, Teleport Destination
	delay = 2 -- seconds
}

function onKill(cid, target)
    if getCreatureName(target):lower() == "the werewolf" then
        doCreateTeleport(1387, config.positions[1], config.positions[2])
        doSendMagicEffect(config.positions[1], CONST_ME_TELEPORT)
        doCreatureSay(cid, "You have "..config.delay.." seconds to enter the teleport before it is closed.", TALKTYPE_ORANGE_1)
        addEvent(removeTeleport, config.delay * 1000, config.positions[1])
    end
	
	return TRUE
end

local function removeTeleport(position)
	if getThingfromPos(position).itemid == 1387 then
		doRemoveItem(getThingfromPos(position).uid)
	end
	
	return TRUE
end

You have to register the event at login.lua/npc script or any other.
 
Should Work

Lua:
local tele_pos = {x=1091, y=1652, z=7} -- Position of Teleport
local new_pos = {x=1125, y=1658, z=7} -- Position of new spot
local timeToPass = 2 -- Length TP exists

function onKill(cid, target)
local creatureName = getCreatureName(target)

    if creatureName == "The Werewolf" then
        doCreateTeleport(1387, tele_pos, new_pos)
        doSendMagicEffect(tele_pos, CONST_ME_TELEPORT)
        doCreatureSay(cid, "You have ".. timeToPass .." seconds to enter the teleport before it is closed.", TALKTYPE_ORANGE_1)
        addEvent(removeTeleport, timeToPass * 1000)
    end
end

function removeTeleport()
local teleport = getTileItemById(tele_pos, 1387)

    if teleport.uid > 0 then
        doRemoveItem(teleport.uid)
        doSendMagicEffect(tele_pos, CONST_ME_POFF)
    end
end
 
Remove event from The Werewolf.xml, I believe it was something like <event name="eventname" />.
 
Back
Top