When using the lever and no player is on the position i get player not found, need a better way to check it, otherwise my console gets spammed with this error message:
LuaScriptInterface::internalGetPlayerInfo(). Player not found.
LuaScriptInterface::internalGetPlayerInfo(). Player not found.
Code:
function onUse(cid, item, frompos, item2, topos)
leverUID = 1337
playerPos = {x = 10, y = 20, z = 30, stackpos = 253}
getPlayerPos = getThingFromPos(playerPos)
newPos = {x = 30, y = 50, z = 100}
if item.uid == leverUID then
if item.itemid == 1945 then
if getPlayerPos.itemid > 0 then
doTeleportThing(getPlayerPos.uid, newPos)
doSendMagicEffect(playerPos, CONST_ME_TELEPORT)
else
doPlayerSendCancel(cid, "test123")
end
elseif item.itemid == 1946 then
doTransformItem(item.uid, item.itemid-1)
else
return false
end
else
print("wrong uid")
end
return true
end