Mobius1 / esx_xp

XP Ranking System for FiveM
45 stars 23 forks source link

How can player get 2xp for playing 1 minute? #32

Open nepramusinek opened 2 years ago

nepramusinek commented 2 years ago

Hello, I need code, that would add 2 XP to player when his playtime will be 1minute, I need this loop.

Im playing 1 minute I will get 2 XP, I play another minute I will get again 2 XP.

It's like SA-MP, can u help me?

nepramusinek commented 2 years ago

Nvm. If someone need it to:

RegisterNetEvent("esx_xp:updateUI")

AddEventHandler("esx_xp:updateUI", function(_xp)

CurrentXP = tonumber(_xp)

SendNUIMessage({

xpm_set = true,

xp = CurrentXP

}) end)

PlayerOnlineTime = 0

Citizen.CreateThread(function()

while true do

Wait(60000) -- EDIT THIS, DEFAULT IS 10 SECONDS IN MS

PlayerOnlineTime = PlayerOnlineTime + 1

if PlayerOnlineTime == 1 then

    exports('ESXP_Add', ESXP_Add)

    exports['mythic_notify']:SendAlert('success', '+100 XP')

    TriggerEvent('esx_xp:Add', 100)

    PlayerOnlineTime = 0

end

end end)