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

teleport script

Na Amigo

The crazy girl
Joined
Jun 5, 2017
Messages
254
Solutions
3
Reaction score
17
Location
Egypt
i've this script but it's not working if i use "click" the items it removed and nothing happen
Code:
<action itemid="6542" script="Femer.lua"  />
LUA:
function onUse(cid, item, frompos, item2, topos)
npos2 = {x=601, y=574, z=7}
        if item.itemid == 6542 and doPlayerRemoveItem(cid,6542,1) == 1 then
        doSendMagicEffect(getPlayerPosition(cid),17)
        doTeleportThing(cid, npos2)
        doSendMagicEffect(getPlayerPosition(cid), 17)
else
     doPlayerSendCancel(cid,"You Can`t Use It")
end
return 1
end
 
Solution
X
i tried to change xikini but nothing happen :) and no errors at the console xD

i've also copied your script it dosen't work too give this error at the console xD
Code:
[20:7:12.455] [Error - LuaInterface::loadFile] data/actions/scripts/Femer.lua:4: unexpected symbol near ','
[20:7:12.455] [Error - Event::checkScript] Cannot load script (data/actions/scripts/Femer.lua)
[20:7:12.455] data/actions/scripts/Femer.lua:4: unexpected symbol near ','
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local npos2 = {x = 601, y = 574, z = 7}
    if doPlayerRemoveItem(cid, 6542, 1) then
        doSendMagicEffect(fromPosition, CONST_ME_MORTAREA)
        doTeleportThing(cid, npos2)
        doSendMagicEffect(npos2...
Well I formatted your script a bit better, but other than that, just by looking at it, there doesn't seem to be anything wrong.
Code:
function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 6542 and doPlayerRemoveItem(cid,6542,1) == 1 then
        doSendMagicEffect(getPlayerPosition(cid),17)
        doTeleportThing(cid, {x=601, y=574, z=7}, true)
        doSendMagicEffect(getPlayerPosition(cid), 17)
    else
     doPlayerSendCancel(cid,"You can't use it.")
    end
return true
end

You may want to change
Code:
npos2 = {x=601, y=574, z=7}
to
Code:
local npos2 = {x=601, y=574, z=7}
Because in your case, it's a global variable and that can mess things up for you in the long run (unless you specifically need it to be).
Or avoid using a variable here since it's not really that necessary, you can just put coords directly into doTeleportThing.

I'd recommend you to check this position x=601, y=574, z=7 manually and see if it's possible to walk on it and it's free to teleport onto.
It could prevent you from teleporting if the position is not valid or something is blocking the way.
Another thing you can try is do is alter the stackpos to teleport to with:
Code:
{x=601, y=574, z=7, stackpos = 255} --< change this number.
 
change
Code:
getPlayerPosition(cid)
to
Code:
getThingPosition(cid)
If you looked at your server log like I've told you to do countless times you would've seen the error
 
change
Code:
getPlayerPosition(cid)
to
Code:
getThingPosition(cid)
If you looked at your server log like I've told you to do countless times you would've seen the error

Yo doesn't getPlayerPosition come in compat files?
Then again, we don't know which version this person is using judging by the post and no error.

He could also add
getPlayerPosition = getThingPosition

to compat.lua in libs if he wants to keep using it I guess. (error might occur in other scripts that were made with this function otherwise)
 
Yo doesn't getPlayerPosition come in compat files?
Then again, we don't know which version this person is using judging by the post and no error.

He could also add
getPlayerPosition = getThingPosition

to compat.lua in libs if he wants to keep using it I guess. (error might occur in other scripts that were made with this function otherwise)
Idk if I edited this section or not in the past, but this is how mine currently looks on 0.3.7
He should have it, but I know from working with his distro in the past that his compat file is missing or wonky. -shrug-
LUA:
getCreaturePosition = getThingPosition
getPlayerPosition = getCreaturePosition
getCreaturePos = getCreaturePosition
creatureGetPosition = getCreaturePosition
 
First: If you register only one itemid for the script, there's no need to check inside it for "if item.itemid =xxx" since only one item could activate it.
Second: doPlayerRemoveItem pushes a bool. So even if the function remove the items it will not be ==1 because boolean true is not equal number 1

Just change to "if doPlayerRemoveItem(cid,6542,1) then " and it should work. The problem is explicit in " items it removed and nothing happen ", which proves that the function runs ok, but some of the if logic was not ok.
 
change
Code:
getPlayerPosition(cid)
to
Code:
getThingPosition(cid)
If you looked at your server log like I've told you to do countless times you would've seen the error
i tried to change xikini but nothing happen :) and no errors at the console xD
Yo doesn't getPlayerPosition come in compat files?
Then again, we don't know which version this person is using judging by the post and no error.

He could also add
getPlayerPosition = getThingPosition

to compat.lua in libs if he wants to keep using it I guess. (error might occur in other scripts that were made with this function otherwise)
i've also copied your script it dosen't work too give this error at the console xD
Code:
[20:7:12.455] [Error - LuaInterface::loadFile] data/actions/scripts/Femer.lua:4: unexpected symbol near ','
[20:7:12.455] [Error - Event::checkScript] Cannot load script (data/actions/scripts/Femer.lua)
[20:7:12.455] data/actions/scripts/Femer.lua:4: unexpected symbol near ','
 
i tried to change xikini but nothing happen :) and no errors at the console xD

i've also copied your script it dosen't work too give this error at the console xD
Code:
[20:7:12.455] [Error - LuaInterface::loadFile] data/actions/scripts/Femer.lua:4: unexpected symbol near ','
[20:7:12.455] [Error - Event::checkScript] Cannot load script (data/actions/scripts/Femer.lua)
[20:7:12.455] data/actions/scripts/Femer.lua:4: unexpected symbol near ','
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local npos2 = {x = 601, y = 574, z = 7}
    if doPlayerRemoveItem(cid, 6542, 1) then
        doSendMagicEffect(fromPosition, CONST_ME_MORTAREA)
        doTeleportThing(cid, npos2)
        doSendMagicEffect(npos2, CONST_ME_MORTAREA)
    else
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        doPlayerSendCancel(cid, "Sorry not possible.")
    end
    return true
end
 
Solution
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local npos2 = {x = 601, y = 574, z = 7}
    if doPlayerRemoveItem(cid, 6542, 1) then
        doSendMagicEffect(fromPosition, CONST_ME_MORTAREA)
        doTeleportThing(cid, npos2)
        doSendMagicEffect(npos2, CONST_ME_MORTAREA)
    else
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        doPlayerSendCancel(cid, "Sorry not possible.")
    end
    return true
end
Worked ty
 
Back
Top