Skip to content

Dragodast/SA-PlayTime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SA-PlayTime

Basic script for counting PlayTime ingame. So first what we need to edit is QB-Core where we add to QB-Core > Server > player.lua this lines somewhere in metadata (for example line 70) PlayerData.metadata['playtime'] = PlayerData.metadata['playtime'] or 0

and now we need to add this to QB-Core > server > events.lua local playtimen = tonumber(playtimes) -- 5=5 minutes Player.PlayerData.metadata['playtime'] = playtimen + QBConfig.UpdateInterval to increase that value every time what we have set. QB-Core > server > events.lua

RegisterNetEvent('QBCore:UpdatePlayer', function(PlayerData)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    if Player then
        local newHunger = Player.PlayerData.metadata['hunger'] - QBCore.Config.Player.HungerRate
        local newThirst = Player.PlayerData.metadata['thirst'] - QBCore.Config.Player.ThirstRate
        local playtimes = Player.PlayerData.metadata['playtime']
        local playtimen = tonumber(playtimes) -- 5=5 minutes
        Player.PlayerData.metadata['playtime'] = playtimen + QBConfig.UpdateInterval
        if newHunger <= 0 then
            newHunger = 0
        end
        if newThirst <= 0 then
            newThirst = 0
        end
        Player.Functions.SetMetaData('thirst', newThirst)
        Player.Functions.SetMetaData('hunger', newHunger)
        TriggerClientEvent('hud:client:UpdateNeeds', src, newHunger, newThirst)
        Player.Functions.Save()
    end
end)

That's all now it will work. Playtime is editable in MySQL

Newer and better version [PAID] : https://studio-players.tebex.io/ Support: https://discord.gg/5Xpa4wEehD

Donate

About

Script for counting players ingame playtime

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages