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

Creating a teleport for X seconds

kokokoko

Veteran OT User
Joined
Feb 4, 2008
Messages
921
Reaction score
257
I tried creating a teleport that should disappear after 5 seconds, but i get this error:
Code:
Lua Script Error: [TalkAction Interface]
in a timer event called from:
data/talkactions/scripts/teleport_town.lua:onSay

luaDoRemoveItem(). Item not found

Here's my script:
Code:
function onSay(cid, words, param, channel)


if param == "1" then
	xPos = getPlayerStorageValue(cid, 5001)
	yPos = getPlayerStorageValue(cid, 5002)
	zPos = getPlayerStorageValue(cid, 5003)
setPlayerStorageValue(cid, 5030, 1)

elseif param == "2" then
	xPos = getPlayerStorageValue(cid, 5004)
	yPos = getPlayerStorageValue(cid, 5005)
	zPos = getPlayerStorageValue(cid, 5006)
setPlayerStorageValue(cid, 5030, 2)


end

setPlayerStorageValue(cid, 5020, 1)
addEvent(createTeleport, 1000, cid)
end

function createTeleport(cid)
if getPlayerStorageValue(cid, 5020) == 1 then
doCreateTeleport(1387, {x=xPos, y=yPos, z=zPos}, getPlayerPosition(cid))
addEvent(removeTeleport, 1000*5, cid)
end
end


function removeTeleport(cid)

getTarget = getPlayerStorageValue(cid, 5030)

if getTarget == "1" then
	xPos = getPlayerStorageValue(cid, 5001)
	yPos = getPlayerStorageValue(cid, 5002)
	zPos = getPlayerStorageValue(cid, 5003)

elseif getTarget == "2" then
	xPos = getPlayerStorageValue(cid, 5004)
	yPos = getPlayerStorageValue(cid, 5005)
	zPos = getPlayerStorageValue(cid, 5006)
end

teleporterPos = {x=xPos, y=yPos, z=zPos}
getTP = getThingfromPos(teleporterPos)

doRemoveItem(getTP.uid, 1)
end

It creates the teleport, and i get teleported when entering it. But the teleport does not disappear :blink:

Thanks in advance,
//Kokokoko
 
You could make it so when the portal is created with the talkaction it sets an Action ID on it and then in movements you could create a script similar to this..

Code:
<movevent type="StepOut" itemid="1387" event="script" value="portal.lua"/>

Code:
function onStepOut(cid, item, position, fromPosition)
    if item.actionid == 5000 then
    doSendMagicEffect(position, 2)
    doRemoveItem(item.uid, 1)
    end
    return TRUE
end

Also please try n post your requests in~
http://otland.net/f132/old-greg-chris77s-scripting-services-37296/
 
It didn't work :s
(Btw, you forgot 'then', probably because you're used to C++ xD)

It does the same thing as before, except that now i get no error. It does not remove the teleport.

Code:
function removeTeleport(cid)

getTarget = getPlayerStorageValue(cid, 5030)

if getTarget == "1" then
	xPos = getPlayerStorageValue(cid, 5001)
	yPos = getPlayerStorageValue(cid, 5002)
	zPos = getPlayerStorageValue(cid, 5003)

elseif getTarget == "2" then
	xPos = getPlayerStorageValue(cid, 5004)
	yPos = getPlayerStorageValue(cid, 5005)
	zPos = getPlayerStorageValue(cid, 5006)
end

pos = {x=xPos, y=yPos, z=zPos}

local teleport = getTileItemById(pos, 1387)
if(teleport.uid> 0) then
	doRemoveItem(teleport.uid)
end

^This is only the doRemoveTeleport function.
 
OH! The script tried to remove the teleport where you go when the you get teleported, and not where the teleport is.. Silly me! :p

Thanks for your help Slawkens, probably wouldn't have figured it out without your little script xD

The working thing, if anyone stumbles upon the same problem:
Code:
function onSay(cid, words, param, channel)


if param == "1" then
	xPos = getPlayerStorageValue(cid, 5001)
	yPos = getPlayerStorageValue(cid, 5002)
	zPos = getPlayerStorageValue(cid, 5003)

elseif param == "2" then
	xPos = getPlayerStorageValue(cid, 5004)
	yPos = getPlayerStorageValue(cid, 5005)
	zPos = getPlayerStorageValue(cid, 5006)


end
setPlayerStorageValue(cid, 5040, getPlayerPosition(cid).x)
setPlayerStorageValue(cid, 5041, getPlayerPosition(cid).y)
setPlayerStorageValue(cid, 5042, getPlayerPosition(cid).z)
addEvent(createTeleport, 1000, cid)
end

function createTeleport(cid)
doCreateTeleport(1387, {x=xPos, y=yPos, z=zPos}, getPlayerPosition(cid))
addEvent(removeTeleport, 1000*5, cid)
end


function removeTeleport(cid)

pos_x = getPlayerStorageValue(cid, 5040)
pos_y = getPlayerStorageValue(cid, 5041)
pos_z = getPlayerStorageValue(cid, 5042)

pos = {x=pos_x, y=pos_y, z=pos_z}

local teleport = getTileItemById(pos, 1387)
if(teleport.uid> 0) then
	doRemoveItem(teleport.uid)
end
end

Thanks yet again! :D
 
Back
Top