function onUse(cid, item, fromPosition, itemEx, toPosition)
if doPlayerRemoveItem(cid, 2159, 50) then
doPlayerAddItem(cid, 7897, 1)
else
doPlayerSendCancel(cid, 'You need 50 "..getItemPluralNameById(2159).." to use this lever.')
end
return true
end
<action actionid="9000" event="script" value="other/script.lua"/>
<action uniqueid="9000" event="script" value="other/script.lua"/>
It doesn't matter what you use, if you only have 1 lever, then you can use an unique id, if you are going to use more levers with the same script, then use an action id.
You have to add it to actions.xml with an unique id or action id (depense on what you use). Good thing to remember: onUse means things you click use on. Actions are onUse scripts, so scripts that have function onUse should always go in actions.
Example how to add it with action and unique id to actions.xml
The number you choose doesn't matter, but use a number that is not in use yet, unique ids can only be used once and with using a used action id can cause conflicts with other scripts.XML:<action actionid="9000" event="script" value="other/script.lua"/> <action uniqueid="9000" event="script" value="other/script.lua"/>
LUA:function onUse(cid, item, fromPosition, itemEx, toPosition) if doPlayerRemoveItem(cid, 2159, 50) then doPlayerAddItem(cid, 7897, 1) else doPlayerSendCancel(cid, 'You need 50 "..getItemPluralNameById(2159).." to use this lever.') end return true end
<movevent type="Equip" itemid="7897" slot="armor" event="function" value="onEquipItem"/>
<movevent type="DeEquip" itemid="7897" slot="armor" event="function" value="onDeEquipItem"/>
Movements.xml
You can add other vocations you want to the item if you want more vocations to be able to wear it.
Or you can remove them if you want all vocations to be able to wear it, so it looks like this:
XML:<movevent type="Equip" itemid="7897" slot="armor" event="function" value="onEquipItem"/> <movevent type="DeEquip" itemid="7897" slot="armor" event="function" value="onDeEquipItem"/>