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

Whats wrong with my code?

Zerity

New Member
Joined
Jul 7, 2009
Messages
89
Reaction score
0
Hallo I have a code that "can make" so you get teleported by a lever if you put a soul stone on the coal basin and pulling the lever should make you get teleported but it wont work for me :(



function onUse(cid, item, fromPosition, itemEx, toPosition)
local tpPos = {x = 307, y = 61, z = 9}
local pPos = {x = 305, y = 61, z = 9, stackpos = 253} -- dont touch the stackpos
local itemPos = {x = 304, y = 61, z = 9, stackpos = 1}
local getItem = getThingFromPos(itemPos)
local getPlayer = getThingFromPos(pPos)
local itemId = 5944

if getPlayer.itemid > 0 then
if getItem.itemid == itemId then
doRemoveItem(getItem.uid, 1)
doSendMagicEffect(getPlayer.uid, CONST_ME_POFF)
doTeleportThing(getPlayer.uid, tpPos)
doSendMagicEffect(tpPos, 37)

else
doPlayerSendCancel(cid, "You have to stay on the right position and put the "..getItemNameById(itemId).." on the coal basin")
end
end
return TRUE
end
Thats the code i use and when i click on the lever nothings happens and i get this error in "console"
[12/07/2009 01:26:02] Lua Script Error: [Action Interface]
[12/07/2009 01:26:02] data/actions/scripts/tele.luanUse

[12/07/2009 01:26:02] data/actions/scripts/tele.lua:5: attempt to call global 'getThingFromPos' (a nil value)
[12/07/2009 01:26:02] stack traceback:
[12/07/2009 01:26:02] data/actions/scripts/tele.lua:5: in function <data/actions/scripts/tele.lua:1
 
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local tpPos = {x = 307, y = 61, z = 9}
local pPos = {x = 305, y = 61, z = 9, stackpos = 253} -- dont touch the stackpos
local itemPos = {x = 304, y = 61, z = 9, stackpos = 1}
local getItem = getThingfromPos(itemPos)
local getPlayer = getThingfromPos(pPos)
local itemId = 5944

if isPlayer(getPlayer.uid) then
if getItem.itemid == itemId then
doRemoveItem(getItem.uid, 1)
doSendMagicEffect(getPlayer.uid, CONST_ME_POFF)
doTeleportThing(getPlayer.uid, tpPos)
doSendMagicEffect(tpPos, 37)

else
doPlayerSendCancel(cid, "You have to stay on the right position and put the "..getItemNameById(itemId).." on the coal basin")
end
end
return TRUE
end


Ofcourse u can use instead "getPlayer", "cid", but then will be teleported this one who use lever, when someone is standing on tile, and put on coalbasin this item. If this place is like "depot" (unreachable for more than 1 player) then use "cid" in doTeleportThing.
 
LUA:
local config = {
	tpPos = {x = 307, y = 61, z = 9},
	pPos = {x = 305, y = 61, z = 9, stackpos = 253}, -- dont touch the stackpos
	itemPos = {x = 304, y = 61, z = 9, stackpos = 1},
	itemId = 5944
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local getItem = getTileThingByPos(config.itemPos)
local getPlayer = getThingFromPos(pPos)
    if getPlayer.config.itemid == TRUE then
	if getItem.config.itemid == config.itemId then
	    doRemoveItem(getItem.uid, 1)
	    doSendMagicEffect(getPlayer.uid, CONST_ME_POFF)
	    doTeleportThing(getPlayer.uid, config.tpPos)
	    doSendMagicEffect(config.tpPos, 37)
	else
	    doPlayerSendCancel(cid, "You have to stay on the right position and put the "..getItemNameById(config.itemId).." on the coal basin")
        end
    end
    return TRUE
end
 
LUA:
local config = {
        tpPos = {x = 307, y = 61, z = 9},
        pPos = {x = 305, y = 61, z = 9, stackpos = 253}, -- dont touch the stackpos
        itemPos = {x = 304, y = 61, z = 9, stackpos = 1},
        itemId = 5944
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local getItem = getTileThingByPos(config.itemPos)
local getPlayer = getThingFromPos(pPos)
    if getPlayer.config.itemid == TRUE then
        if getItem.config.itemid == config.itemId then
            doRemoveItem(getItem.uid, 1)
            doSendMagicEffect(getPlayer.uid, CONST_ME_POFF)
            doTeleportThing(cid, config.tpPos)
            doSendMagicEffect(config.tpPos, 37)
        else
            doPlayerSendCancel(cid, "You have to stay on the right position and put the "..getItemNameById(config.itemId).." on the coal basin")
        end
    end
    return TRUE
end

??????

Regards,
Shawak
 
It still wont work..!
now the soul orb dont even disapper ..

it looks like this on the map
2uorm6h.jpg


and here is the code

local config = {
tpPos = {x = 307, y = 61, z = 9},
pPos = {x = 305, y = 61, z = 9, stackpos = 253}, -- dont touch the stackpos
itemPos = {x = 304, y = 61, z = 9, stackpos = 1},
itemId = 5944
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local getItem = getTileThingByPos(config.itemPos)
local getPlayer = getThingFromPos(pPos)
if getPlayer.config.itemid == TRUE then
if getItem.config.itemid == config.itemId then
doRemoveItem(getItem.uid, 1)
doSendMagicEffect(getPlayer.uid, CONST_ME_POFF)
doTeleportThing(cid, config.tpPos)
doSendMagicEffect(config.tpPos, 37)
else
doPlayerSendCancel(cid, "You have to stay on the right position and put the "..getItemNameById(config.itemId).." on the coal basin")
end
end
return TRUE
end
<action uniqueid="1238" script="tele.lua" />

try find out whats wrong with it please.
when i put the soul orb on the coal basin and pulling the lever nothing happends i get this error in " Console "
[16/07/2009 00:12:58] Lua Script Error: [Action Interface]
[16/07/2009 00:12:58] data/actions/scripts/tele.lua:onUse

[16/07/2009 00:12:58] data/actions/scripts/tele.lua:10: attempt to call global 'getThingFromPos' (a nil value)
[16/07/2009 00:12:58] stack traceback:
[16/07/2009 00:12:58] data/actions/scripts/tele.lua:10: in function <data/actions/scripts/tele.lua:8>
 
LUA:
local config = {
        tpPos = {x = 307, y = 61, z = 9},
        pPos = {x = 305, y = 61, z = 9, stackpos = 253}, -- dont touch the stackpos
        itemPos = {x = 304, y = 61, z = 9, stackpos = 1},
        itemId = 5944
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local getItem = getThingfromPos(config.itemPos)
local getPlayer = getThingfromPos(config,pPos)
    if getPlayer.itemid > 0 then
        if getItem == config.itemId then
            doRemoveItem(getItem.uid, 1)
            doSendMagicEffect(fromPosition, CONST_ME_POFF)
            doTeleportThing(cid, config.tpPos)
            doSendMagicEffect(config.tpPos, 37)
        else
            doPlayerSendCancel(cid, "You have to stay on the right position and put the "..getItemNameById(config.itemId).." on the coal basin")
        end
    end
    return TRUE
end

Sorry, my miss.

Regards,
Shawak
 
@Up,

LUA:
local getPlayer = getThingfromPos(config,pPos)
Change to:
LUA:
local getPlayer = getThingfromPos(config.pPos)
 
Back
Top