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

PlayerPos + Lever = TP

Ozo

New Member
Joined
Jun 30, 2008
Messages
58
Reaction score
0
Hello!

Scenario:
Player stands at a specific tile -> pulls lever -> gets teleported

How would i modify this script to check if a player stands at the correct position
instead of an item/corpse?

Lua:
Code:
function onUse(cid, item, frompos, item2, topos)
    playerpos = getPlayerPosition(cid)
    nplayer1pos = {x= , y= , z= } --Put here the New position
    corpsepos = {x= , y= ,  z= , stackpos=1} --And here the Corpse position
    corpse = getThingfromPos(corpsepos) 
 
    if item.itemid == 1945 then
        if corpse.itemid = corpseID then --Change corpseID for the ID of the corpse
            doTransformItem(item.uid,item.itemid+1)
            doRemoveItem(corpse.uid, 1)
            doSendMagicEffect(topos, 36)
            doSendMagicEffect(playerpos,2)
            doTeleportThing(cid,nplayer1pos)
            doSendMagicEffect(nplayer1pos,10)
            doSendAnimatedText(nplayer1pos, "Teleport!", TEXTCOLOR_RED)
        else
            doPlayerSendTextMessage(cid, 22, "Put the corpse on coal basin.")
        end
    elseif item.itemid == 1946 then
        doTransformItem(item.uid,item.itemid-1)
        doSendMagicEffect(topos, 2)
    end
    return 1
end
Thanks in advance!
 
Code:
tilepos = { x = , y = , z = }
after item.id check:
Code:
if getPlayerPosition(cid) == tilepos then
 
Code:
tilepos = { x = , y = , z = }
after item.id check:
Code:
if getPlayerPosition(cid) == tilepos then

I am sorry but, my lua skills is not good enough.. been trying for an hour or so now. Could anyone please help me out? :)

this is what the code looks like now
Code:
function onUse(cid, item, frompos, item2, topos)
    playerpos = getPlayerPosition(cid)
    nplayer1pos = {x=572 , y=532 , z=12 } -- Destination
    tilepos = {x=566 , y=532 ,  z=12} -- Player Position
 
    if item.itemid == 1945 then
        if getPlayerPosition(cid) == tilepos then
            doTransformItem(item.uid,item.itemid+1)
            doSendMagicEffect(topos, 36)
            doSendMagicEffect(playerpos,2)
            doTeleportThing(cid,nplayer1pos)
            doSendMagicEffect(nplayer1pos,10)
        else
            doPlayerSendTextMessage(cid, 22, "Sorry, not possible.")
        end
    elseif item.itemid == 1946 then
        doTransformItem(item.uid,item.itemid-1)
        doSendMagicEffect(topos, 2)
    end
    return 1
end

Thanks!
 
Last edited:
Try changing
Code:
    tilepos = {x=566 , y=532 ,  z=12}
to:
Code:
    tilepos = {x=566 , y=532 ,  z=12, stackpos = 255}

I've had that problem lots of times. ;P
 
is the player standing next to the lever when they pull it or do they need somee1 else to pull it for them?
 
is the player standing next to the lever when they pull it or do they need somee1 else to pull it for them?

It is a tile (like the DP tile) that's right beside the lever.
lever.gif
 
Last edited:
Back
Top