• 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 Quest Lever 7.6

gianflogao

Member
Joined
Jun 6, 2014
Messages
134
Solutions
2
Reaction score
13
I need a quest by lever, when using the lever the player gains "x" item.

Someone help me?
 
Solution
yes, the lever moved, but the player did not win the item
ok. I removed the 'true' portion, which I added.
I guess your server doesn't have that functionality.

Added in the level requirement as well.

Lua:
local reqLevel = 666

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 5009) == 1 then
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        doPlayerSendTextMessage(cid, 22, "It is empty.")
        return true
    end
    if getPlayerLevel(cid) < reqLevel then
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        doPlayerSendTextMessage(cid, 22, "Require level " .. reqLevel .. " to use this object.")
        return true
    end
    setPlayerStorageValue(cid, 5009, 1)...
Lua:
function onUse(cid, item, frompos, item2, topos)

if item.uid == 5009 and item.itemid == 1945 then
           queststatus = getPlayerStorageValue(cid,5009)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found a fear backpack.")
               doPlayerAddItem(cid,3940,1)
               setPlayerStorageValue(cid,5009,1)
             doTransformItem(item.uid,item.itemid+1)

        elseif item.uid == 5009 and item.itemid == 1946 then
        doTransformItem(item.uid,item.itemid-1)
        else
               doPlayerSendTextMessage(cid,22,"it\'s empty.")     
        end
    end   
return 1
end

I put this script together, but the lever does not return to position...

Help-me
 
Lua:
function onUse(cid, item, frompos, item2, topos)

if item.uid == 5009 and item.itemid == 1945 then
           queststatus = getPlayerStorageValue(cid,5009)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found a fear backpack.")
               doPlayerAddItem(cid,3940,1)
               setPlayerStorageValue(cid,5009,1)
             doTransformItem(item.uid,item.itemid+1)

        elseif item.uid == 5009 and item.itemid == 1946 then
        doTransformItem(item.uid,item.itemid-1)
        else
               doPlayerSendTextMessage(cid,22,"it\'s empty.")  
        end
    end
return 1
end

I put this script together, but the lever does not return to position...

Help-me
Is this what you mean?
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 5009) == 1 then
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendTextMessage(cid, 22, "It is empty.")
        return true
    end
    setPlayerStorageValue(cid, 5009, 1)
    doPlayerAddItem(cid, 3940, 1, true)
    doPlayerSendTextMessage(cid, 22, "You have found a fear backpack.")
    doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
    return true
end
 
Is this what you mean?
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 5009) == 1 then
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendTextMessage(cid, 22, "It is empty.")
        return true
    end
    setPlayerStorageValue(cid, 5009, 1)
    doPlayerAddItem(cid, 3940, 1, true)
    doPlayerSendTextMessage(cid, 22, "You have found a fear backpack.")
    doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
    return true
end
Uniqueid on the lever is "5009", there if you want to use a "storage" so you can not use more.

The server you use is yurots 0.9.4f 7.6

That means you're more to me.
 
put an "if" to level too ...

But to no avail: /

Lua:
function onUse(cid, item, frompos, item2, topos)

local reqLevel = 666

if getPlayerLevel(cid) >= reqLevel then
if item.uid == 5009 and item.itemid == 1945 then
           queststatus = getPlayerStorageValue(cid,5009)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found a fear backpack.")
               doPlayerAddItem(cid,3940,1)
               setPlayerStorageValue(cid,5009,1)
             doTransformItem(item.uid,item.itemid+1)

        elseif item.uid == 5009 and item.itemid == 1946 then
        doTransformItem(item.uid,item.itemid-1)
        else
               doPlayerSendTextMessage(cid,22,"it\'s empty.")     
        end
    end
end   
return 1
end
 
Uniqueid on the lever is "5009", there if you want to use a "storage" so you can not use more.

The server you use is yurots 0.9.4f 7.6

That means you're more to me.
put an "if" to level too ...

But to no avail: /

Lua:
function onUse(cid, item, frompos, item2, topos)

local reqLevel = 666

if getPlayerLevel(cid) >= reqLevel then
if item.uid == 5009 and item.itemid == 1945 then
           queststatus = getPlayerStorageValue(cid,5009)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found a fear backpack.")
               doPlayerAddItem(cid,3940,1)
               setPlayerStorageValue(cid,5009,1)
             doTransformItem(item.uid,item.itemid+1)

        elseif item.uid == 5009 and item.itemid == 1946 then
        doTransformItem(item.uid,item.itemid-1)
        else
               doPlayerSendTextMessage(cid,22,"it\'s empty.")    
        end
    end
end  
return 1
end
Did you even test my script?
 
yes, the lever moved, but the player did not win the item
ok. I removed the 'true' portion, which I added.
I guess your server doesn't have that functionality.

Added in the level requirement as well.

Lua:
local reqLevel = 666

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 5009) == 1 then
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        doPlayerSendTextMessage(cid, 22, "It is empty.")
        return true
    end
    if getPlayerLevel(cid) < reqLevel then
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        doPlayerSendTextMessage(cid, 22, "Require level " .. reqLevel .. " to use this object.")
        return true
    end
    setPlayerStorageValue(cid, 5009, 1)
    doPlayerAddItem(cid, 3940, 1)
    doPlayerSendTextMessage(cid, 22, "You have found a fear backpack.")
    doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
    return true
end
 
Last edited:
Solution
It worked when you use the lever ...
this part did not work:

Lua:
    if getPlayerLevel(cid) < reqLevel then
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendTextMessage(cid, 22, "Require level " .. reqLevel .. " to use this object.")
        return true
    end

and the lever does not return to position 1945
 
@Xikini

look at an example of a leverage quest:

Lua:
function onUse(cid, item, frompos, item2, topos)
piece1pos = {x=1027, y=1011, z=5, stackpos=2} -- Big Ruby
piece2pos = {x=1028, y=1011, z=5, stackpos=2} -- Big Emerald
piece3pos = {x=1029, y=1011, z=5, stackpos=2} -- Blessed Shield
piece4pos = {x=1027, y=1014, z=5, stackpos=2} -- Violet Gem
piece5pos = {x=1028, y=1014, z=5, stackpos=2} -- Yellow Gem
piece6pos = {x=1029, y=1014, z=5, stackpos=2} -- Hand Axe
shieldpos = {x=1029, y=1012, z=5, stackpos=2} -- Where Ornamented Shield spawns
getpiece1 = getThingfromPos(piece1pos)
getpiece2 = getThingfromPos(piece2pos)
getpiece3 = getThingfromPos(piece3pos)
getpiece4 = getThingfromPos(piece4pos)
getpiece5 = getThingfromPos(piece5pos)
getpiece6 = getThingfromPos(piece6pos)

if item.uid == 7051 and item.itemid == 1945 and getpiece1.itemid == 2156 and getpiece2.itemid == 2155 and getpiece3.itemid == 2523 and getpiece4.itemid == 2153 and getpiece5.itemid == 2154 and getpiece6.itemid == 2380 then
doRemoveItem(getpiece1.uid,1)
doRemoveItem(getpiece2.uid,1)
doRemoveItem(getpiece3.uid,1)
doRemoveItem(getpiece4.uid,1)
doRemoveItem(getpiece5.uid,1)
doRemoveItem(getpiece6.uid,1)
doCreateItem(2524,1,shieldpos)
doSendMagicEffect(shieldpos,2)
doPlayerSendTextMessage(cid,22,"You have enchanted your ornamented shield!")
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 7051 and item.itemid == 1946 then
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendTextMessage(cid,22,"Sorry, some piece maybe on the incorrect place.")
end
return 1
end
 
It worked when you use the lever ...
this part did not work:

Lua:
    if getPlayerLevel(cid) < reqLevel then
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendTextMessage(cid, 22, "Require level " .. reqLevel .. " to use this object.")
        return true
    end

and the lever does not return to position 1945
I'll add some prints.. I don't understand what might be wrong.
Can you show me what prints to console?

Lua:
local reqLevel = 666

function onUse(cid, item, fromPosition, itemEx, toPosition)
    print("Starting script..")
    print("Checking quest status..")
    print("Player storage = " .. getPlayerStorageValue(cid, 5009) .. "")
    if getPlayerStorageValue(cid, 5009) == 1 then
        print("Quest completed. Script ended.")
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendTextMessage(cid, 22, "It is empty.")
        return true
    end
    print("Quest has not been completed yet. Continuing..")
    print("Checking player level requirements..")
    print("Player level = " .. getPlayerLevel(cid) .. "")
    if getPlayerLevel(cid) < reqLevel then
        print("Player level is below " .. reqLevel .. ". Script ended.")
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendTextMessage(cid, 22, "Require level " .. reqLevel .. " to use this object.")
        return true
    end
    print("Player level is above or equal to " .. reqLevel .. ". Continuing..")
    print("Setting player storage..")
    setPlayerStorageValue(cid, 5009, 1)
    print("Adding item to player..")
    doPlayerAddItem(cid, 3940, 1)
    doPlayerSendTextMessage(cid, 22, "You have found a fear backpack.")
    print("Moving lever..")
    doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
    print("Everything complete. Script Ended.")
    return true
end
 
ok. I removed the 'true' portion, which I added.
I guess your server doesn't have that functionality.

Added in the level requirement as well.

Lua:
local reqLevel = 666

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 5009) == 1 then
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        doPlayerSendTextMessage(cid, 22, "It is empty.")
        return true
    end
    if getPlayerLevel(cid) < reqLevel then
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        doPlayerSendTextMessage(cid, 22, "Require level " .. reqLevel .. " to use this object.")
        return true
    end
    setPlayerStorageValue(cid, 5009, 1)
    doPlayerAddItem(cid, 3940, 1)
    doPlayerSendTextMessage(cid, 22, "You have found a fear backpack.")
    doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
    return true
end

now it worked!!!!!!!!!!!
 
Lua:
   doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)

This part he goes to 1946 but he returns to 1945 doing the quest again.
I'll upload a picture ...

Imgur

ulSsPRS


ulSsPRS
 
Back
Top