[RELEASE] XNLRankBar ('Fully' working original GTA Rankbar / XP Bar NATIVELY! - with original GTA Levels!)

Little update of server side ESX code
for RegisterServerEvent(‘RemoveXp’)
Change the all part of the server event for this one.

RegisterServerEvent('RemoveXp')
AddEventHandler('RemoveXp',function(value)
	
	local _source = source
	local xPlayer  = ESX.GetPlayerFromId(_source)
	MySQL.Async.fetchAll('SELECT `xp` FROM users WHERE identifier = @identifier', {
		['@identifier'] = xPlayer.identifier
	}, function(result)
        -- print(result[1].rank)
       local xpbd = result[1].xp
   
	if xpbd >= (value) then
	MySQL.Async.fetchAll("UPDATE users SET xp = @xp WHERE identifier = @identifier",
                {
                 ['@identifier'] = xPlayer.identifier,
				 ['@xp'] = xpbd - (value)
                }
                )
	
	else 
	MySQL.Async.fetchAll("UPDATE users SET xp = @xp WHERE identifier = @identifier",
                {
                 ['@identifier'] = xPlayer.identifier,
				 ['@xp'] = 0
                }
                )
				end
	 end)
end)

This way if the database value of XP is less then the ammount we want to remove then the xp update to 0…
Prevent getting in negative value.

Cheers.

1 Like