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

Lua Levers - block use to restart server

SalvaART

TriasOT.online
Joined
May 1, 2017
Messages
208
Solutions
1
Reaction score
123
Location
USA
Hello, can someone explain to me how to make a lever and lock it for the next server save?

... so we can use only one time this lever who will open something on server save

FOR ANY TIPS BIG +++

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local gatePos = {x=32010, y=32100, z=8, stackpos=1}
    local nextTile = {x=gatePos.x, y=gatePos.y+1, z=gatePos.z}
    local gateItem = getThingfromPos(gatePos)

    if item.itemid == 1945 and gateItem.itemid == 1304 then
        doRemoveItem(gateItem.uid,1)
        doTransformItem(item.uid,item.itemid+1)
    elseif item.itemid == 1946 then
        doRelocate(gatePos, nextTile)
        doCreateItem(1304,1,gatePos)
        doTransformItem(item.uid,item.itemid-1)
    else
        doPlayerSendCancel(cid,"Sorry not possible.")
    end
    
    return true
end
 
Solution
You can simply put a variable at the top of the script, which will be hold until server restarts.

like this:
Lua:
local hasBeenUsed = false

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if hasBeenUsed then
        doPlayerSendCancel(cid,"You can use after next server save.")
        return true
    end

    local gatePos = {x=32010, y=32100, z=8, stackpos=1}
    local nextTile = {x=gatePos.x, y=gatePos.y+1, z=gatePos.z}
    local gateItem = getThingfromPos(gatePos)

    if item.itemid == 1945 and gateItem.itemid == 1304 then
        doRemoveItem(gateItem.uid,1)
        doTransformItem(item.uid,item.itemid+1)
        hasBeenUsed = true
    elseif item.itemid == 1946 then
        doRelocate(gatePos, nextTile)...
You can simply put a variable at the top of the script, which will be hold until server restarts.

like this:
Lua:
local hasBeenUsed = false

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if hasBeenUsed then
        doPlayerSendCancel(cid,"You can use after next server save.")
        return true
    end

    local gatePos = {x=32010, y=32100, z=8, stackpos=1}
    local nextTile = {x=gatePos.x, y=gatePos.y+1, z=gatePos.z}
    local gateItem = getThingfromPos(gatePos)

    if item.itemid == 1945 and gateItem.itemid == 1304 then
        doRemoveItem(gateItem.uid,1)
        doTransformItem(item.uid,item.itemid+1)
        hasBeenUsed = true
    elseif item.itemid == 1946 then
        doRelocate(gatePos, nextTile)
        doCreateItem(1304,1,gatePos)
        doTransformItem(item.uid,item.itemid-1)
    else
        doPlayerSendCancel(cid,"Sorry not possible.")
    end
    
    return true
end
 
Solution
Back
Top