• 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 ADDON LEVER - I CAN DO IT?

rexgandi

Member
Joined
Oct 22, 2011
Messages
189
Reaction score
9
Hello,
I try write script - when i put item on table, and use lever, items remove and give me addon.
My idea is to write it like this: If there is an item "ID1" in the amount of "Q1" and item "ID2" in the amount of "Q2" then the player gets an addon 1.
If these indices are not on the table, it checks the next condition on the same principle.
Can you help me please?

local itemsPos = {1935, 1217, 7}
local stackpos = {1,2,3,4,5,6,7,8,9,10}

function onUse(cid, item, fromPosition, itemEx, toPosition)

if isPremium(cid) == FALSE then
doPlayerSendCancel(cid, "Sorry, only premium players may use addon lever.")
return TRUE
end

if getItemCountFromPosition(6500, item_pos) >= 500 and getPlayerStorageValue(cid) > 9000 then
doRemoveItem(uid,500)
setPlayerStorageValue(cid,9001,1)
doPlayerAddOutfit(cid,279,1)
doPlayerAddOutfit(cid,278,1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, You have unlocked new addon!")

else if getItemCountFromPosition(2001, item_pos) >= 100 then
doRemoveItem(uid,100)
setPlayerStorageValue(cid,9002,1)
doPlayerAddOutfit(cid,279,2)
doPlayerAddOutfit(cid,278,2)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, You have unlocked new addon!")






else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You dont have needed items!")

end
return true
end
 
Last edited:
Hello,
I try write script - when i put item on table, and use lever, items remove and give me addon.
My idea is to write it like this: If there is an item "ID1" in the amount of "Q1" and item "ID2" in the amount of "Q2" then the player gets an addon 1.
If these indices are not on the table, it checks the next condition on the same principle.
Can you help me please?

Can 2 or more outfits have items in common?
example:
-- outfit1 needs item 2160
-- outfit2 needs item 2160

.. OR are the item sets gonna be unique? meaning 2 outfits won't need the same item as another outfit?
 
Can 2 or more outfits have items in common?
example:
-- outfit1 needs item 2160
-- outfit2 needs item 2160

.. OR are the item sets gonna be unique? meaning 2 outfits won't need the same item as another outfit?
One addon can have two elements, for example:

if getItemCountFromPosition (6500, item_pos)> = 500 and (6432, item_pos)> 100 then ...

But the script is supposed to give addons comparing items, this is the simplest solution.

It should work if you write a script:

1 citizen needs == 100 mino leather
2 beggar == 30 mino leather

???

If not, simply add different items to each add-on.

How can I make it work? Does it work?
Maybe it will work when for the same items I give after (item_pos) I give (stack_pos). Then, for example:
Citizen 1 - must have 100 mino leatcher but on the stack_pos 2 and 3 gold coins on stack pos 1
Beggar 1 - must have 100 mino leather but on stack_pos 1 and 5 gold coins on stack pos 2

Now the script will recognize items in positions that must match, if the player put them otherwise will get another addon?
 
Last edited:
Back
Top