I've created simple script, but it doesnt work and console doesnt return any errors. I am using Mystic Spirit 0.2.9
I'll rep++ for help.
Lua:
-- [chest.uid] = [item_id, item_id_count, player_storage_value_id]
local chest = {
[2000] = {2475, 1, 2000},
[2001] = {2475, 2, 2000}
}
function onUse(cid, item)
local i = chest[item.uid]
local freecap = getPlayerFreeCap(cid)
local cap = getItemWeight(i[1],i[2]) - freecap
if item.uid == i then
if getPlayerStorageValue(cid,i[3]) == -1 then
if freecap >= (getItemWeight(i[1],i[2])) then
doPlayerAddItem(cid,i[1],i[2])
if i[2] > 1 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found " ..i[2].. " " .. getItemName(i[1]) .. ".")
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found " .. getItemName(i[1]) .. ".")
end
setPlayerStorageValue(cid,i[3],1)
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need " .. cap .. " more cap to get this item.")
end
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "This chest is empty.")
end
end
end