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

Solved onUse script help.

bybbzan

mapper
Joined
Aug 4, 2012
Messages
809
Solutions
2
Reaction score
136
Location
Sweden
Hello.

I want to add so you can't use the lever until the timer ended.
Right now, you can just spam it.

19:16 You opened the secret passage.
19:16 You opened the secret passage.
19:16 You opened the secret passage.
19:16 You opened the secret passage.

I want it to say "its already open" if its open.

Thanks.


Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local pos = {x = 901, y = 1144, z = 10}
    doTransformItem(getTileItemById(pos, 9023).uid, 369)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You opened the secret passage.")   
    doTransformItem(item.uid, item.itemid == 9825 and 9826 or 9825)   
    addEvent(function () doTransformItem(getTileItemById(pos, 369).uid, 9023) end, 10000)
    return true
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local pos = {x = 901, y = 1144, z = 10}
    if getTileItemById(pos, 9023).uid > 0 then
        doTransformItem(getTileItemById(pos, 9023).uid, 369)
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You opened the secret passage.") 
        doTransformItem(item.uid, item.itemid == 9825 and 9826 or 9825) 
        addEvent(function () doTransformItem(getTileItemById(pos, 369).uid, 9023) end, 10000)
    else
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It's already open.")
    end
    return true
end
 
u lever may have a bug it isnt using any action id,
so any other lever on the map will be also buged !
THIS ISN'T the script u need ( the final version shall be a lot smaller )
what is this script ?
i want just to show how i debug something that isnt working.
[HERE] it is, after EXE it tell us the OUTPUT it give OK?
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local pos = {x = 901, y = 1144, z = 10}
    local xtime = 10000
    local item_blocked = 9023
    local item_free = 369
    local xitem = getTileItemById(pos, item_blocked)
 
    if xitem==nil or xitem.uid<1 then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Item not found, check its ID and POS.")
        print ( " ERROR :  Item not found, check its ID and POS." )
        return false
    end
    if xitem.itemid == item_blocked then
        doTransformItem( xitem.uid , item_free )
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You opened the secret passage.")
        doTransformItem(item.uid, item.itemid == 9825 and 9826 or 9825)
        addEvent(doTransformItem,xtime, xitem.uid, item_blocked)
        return true
    end
    if xitem.itemid == item_free then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It's already open.")
        return true
    end
 
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "THE script failled, cotact the ADM, and inform him about this error [code=fadmin].")
    print ("ERROR : the lever failed to work, if any next info is wrong, pls fix it !")
    return false
end
 
Back
Top