data/actions/scripts/chestsys.lua
- Código:
local t = {
[1001] = {2002,"magic sword",2400},
[1002] = {2004,"royal crossbow",8851}
}
function onUse(cid,item,fromPosition,itemEx,toPosition)
local v = t[item.uid]
if getPlayerStorageValue(cid,v[1]) == -1 and getPlayerFreeCap(cid) >= (getItemWeightById(v[3])) then
setPlayerStorageValue(cid,v[1],1)
doPlayerAddItem(cid,v[3])
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a " .. v[2] .. "!")
elseif getPlayerStorageValue(cid,v[1]) == 1 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty")
elseif getPlayerFreeCap(cid) < (getItemWeightById(v[3])) then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need " .. getItemWeightById(v[3]) .. " capacity in order to get the item")
end
return true
end
data/actions/actions.xml
- Código:
<action uniqueid="1001-1002" event="script" value="chestsys.lua"/>