Fermantor
Active Member
There are crates in rl Tibia, that gives you an item, every 1 hour, when you click on them. I wanna use this on my server to, but I don't know, how to re-set the StorageValue of an player, if he/she is logged out.
My script so far, look like this:
I am using TFS 0.2.14 (mystic spirit, tibia 9.61)
My script so far, look like this:
LUA:
local Items = {
[1] = {2160,2},
[2] = {2160,2},
[3] = {2160,2},
[4] = {2160,2},
[5] = {2160,2}
}
function onUse(cid, item, fromPos, item2, toPos)
if getPlayerStorageValue(cid, 11010) == -1 then
local chance = math.random(1,5)
for id, item in pairs(Items) do
if chance == id then
doPlayerAddItem(cid, item[1], item[2])
doCreatureSay(cid, "You have found " .. item[2] .. " " .. item[1], 34)
setPlayerStorageValue(cid, 11010, 1)
local GUID = getPlayerGUID(cid)
addEvent(back, 1000*5, GUID)
end
end
else
doCreatureSay(cid, "You have found nothing usefull.", 34)
end
return true
end
function back(id)
db.query("UPDATE `player_storage` SET `value` = -1 WHERE `player_id` = " .. id .. " AND `key` = 11010")
end
I am using TFS 0.2.14 (mystic spirit, tibia 9.61)