whitevo
Feeling good, thats what I do.
I want to change the mechanics how my task reset.
Each day globalevent changes 1 random storage value to -1.
I have been looking around in forum and seen some good examples, but not sure am i doing it correctly.
Working script here.
Each day globalevent changes 1 random storage value to -1.
I have been looking around in forum and seen some good examples, but not sure am i doing it correctly.
Working script here.
Code:
function onThink()
local allStorageIDs = {}
for k, v in pairs(tasks) do
table.insert(allStorageIDs, v.storageID)
end
local randomTask = allStorageIDs[math.random(1, #allStorageIDs)]
local players = Game.getPlayers()
db.query("UPDATE `player_storage` SET `value` = -1 WHERE `value` = -2 AND `key` = "..randomTask)
for k, player in ipairs(players) do
if player:getStorageValue(randomTask) == -2 then
player:setStorageValue(randomTask, -1)
player:sendTextMessage(BLUE, "1 random task can be redone, check back to Task Master")
end
end
return true
end
Last edited: