• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua global storage permanent

ZeroSkyer

Member
Joined
May 17, 2019
Messages
62
Reaction score
9
Location
EEUU
Hello I am making a script to give a mount to the first 100 players that enter my server. The mount part is ready, but how can I end the event? Think of a globalstorage that adds up to 100 and when it is greater than or equal to 100 the script would stop working. It works in fact, but in the serversave the globalstorage is restarted xd and I don't know any other way to do it. Script I did.

Thanks in advance:)

Lua:
function onLogin(cid)
    local player = Player(cid)
    local giveawaymounts = {
        174, 170, 117, 169, 156
    }
    

    if Game.getStorageValue(GIVEAWAY) < 100 then
        if player:getStorageValue(WINNER_GA) < 1 then
            player:addMount(giveawaymounts[math.random(#giveawaymounts)])
            player:setStorageValue(WINNER_GA, 1)
            Game.setStorageValue(GIVEAWAY, Game.getStorageValue(GIVEAWAY) + 1)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Congratulations! You have been one of the first 100 players to enter and have won a mount.")
        end
    end
    return true
end
 
I think u missing (GlobalStorageKeys.GIVEAWAY)
That’s why it doesn’t update it.
You said you added it under global storages at lib file.
Re check it.
Also script looks fine.
 
Maybe I just have to deactivate the script at the end of delivering the 100 rewards, because the whole script works, only that the Game.Storage is not saved in the server saves, that is the configuration of tfs I think. Likewise thanks for your help, I hope someone will help the little script I made<3
 
Maybe I just have to deactivate the script at the end of delivering the 100 rewards, because the whole script works, only that the Game.Storage is not saved in the server saves, that is the configuration of tfs I think. Likewise thanks for your help, I hope someone will help the little script I made<3

You can't achieve what you are wanting to do with the current Game.setStorageValue functions, as they are stored in ram.

You'll want to make an adjustment to your database, and use some Lua functions to update them.

Link below will show you how to do that. The thread being titled TFS 1.2 will not affect the functionality of the solution.

 
Back
Top