• 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:
Change
Lua:
if getThingfromPos({x=1125, y=1658, z=7, stackpos=1}).itemid == 1387 then

To
Lua:
if getThingfromPos({x=1125, y=1658, z=7, stackpos=2}).itemid == 1387 then
 
it didn't work.
I'm using tfs 0.3.4 crying damson.
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
 
try it:
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*20), teleport, in_pos)


end
end

function removeTeleport(teleport, in_pos)
doRemoveItem(teleport,1)
doSendMagicEffect(in_pos, CONST_ME_POFF)
end
 
Lua:
local creatureName = getCreatureName(cid)
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 onDeath(cid, corpse, killer)
registerCreatureEvent(cid, "werewolfded")

    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
 
Post on the correct board next time instead of spamming around all the time.

I do not see what this have with spamming todo...
I'm sorry for posting in the wrong board.

JDB, Your script did not work :/

I get this bug:

[01/08/2009 17:35:38] Lua Script Error: [CreatureScript Interface]
[01/08/2009 17:35:38] data/creaturescripts/scripts/werewolfded.lua

[01/08/2009 17:35:38] luaGetCreatureName(). Creature not found
 
Where is the creature supposed to stand?

Lua:
registerCreatureEvent(cid, "werewolfded")
 
Script:
Lua:
local creatureName = getCreatureName(cid)
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 onDeath(cid, corpse, killer)

    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

Login.lua
PHP:
registerCreatureEvent(cid, "werewolfded")

Dude, you are using CID parameter not inside ANY function, thats why there is an error (Creature not found). Put it below onDeath.

To be more clear: local creatureName = getCreatureName(cid), cid = nil here.
 
Lua:
function onDeath(cid, corpse, killer)
registerCreatureEvent(cid, "werewolfded")

:blink:

huh?

THIS:
Lua:
local creatureName = getCreatureName(cid)
SHOULD BE HERE:
Lua:
function onDeath(cid, corpse, killer)
    local creatureName = getCreatureName(cid)

Also, use onKill.
 
Try?

@Up,

Ty :cool:

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(cid)

    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
 
Back
Top