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

Sorry guys, unfortunately for me it’s impossible to help everyone with “one basic solution” do to all the different saving and database styles.

If this wasn’t such a ‘big issue’ i would have just incorporated it into my script as ‘addon feature’ but there is to much difference in how several game modes use the XP and/or store it :frowning:

no worry my dude… I use to say that im good. but when i have to deal with DB im like a grandma with a smartphone.

You did already a lot.
Everything is implemented and working.
Only trouble saving and retrieving from database…
Ill get it soon :wink:

By the way… Pretty much 5 starts release

:rofl::rofl::rofl:

Thanks man haha
Hope you’ll get it working soon enough, if you keep having issues just PM me,
i will then when i have time try to help a bit along (altough i CAN NOT test the code ‘suggestions’ due to not running those frameworks myself).

Would PROBERBLY be tomorrow (for me) though since i still have to finish a build (at the office job haha) and it’s already 5:30AM here haha so need to head home soon to.

1 Like

Hello, And thank you I could touch the code and now it works here is the new one for those who want to use it, but I let you do the one that records in the bdd

AddEventHandler('esx:playerLoaded', function(source)
    local xPlayer = ESX.GetPlayerFromId(source)

	MySQL.Async.fetchAll('SELECT `rank` FROM users WHERE identifier = @identifier', {
		['@identifier'] = xPlayer.identifier
	}, function(result)
        -- print(result[1].rank)
        rankbd = result[1].rank
    end)
    
    Wait(0)
    TriggerClientEvent('XNL_NET:AddPlayerXP', source , rankbd)
end)
1 Like

Nice one :slight_smile:
Although i do recommend using this one:

TriggerClientEvent('XNL_NET:XNL_SetInitialXPLevels', source, rankbd, true, true)

for the last line, when it’s loading the XP the first time (on spawning) :slight_smile: looks much nicer/more complete :slight_smile: AND it will not make the game go through ALL levels nonstop if the player has a high level :wink:

Else your code will cause the player to level up from 0 to level 50 for example if they are level 50 :wink:

You save me time i save you time…

Server side…

RegisterServerEvent('AddXp')
AddEventHandler('AddXp',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
   	
	MySQL.Async.fetchAll("UPDATE users SET xp = @xp WHERE identifier = @identifier",
                {
                 ['@identifier'] = xPlayer.identifier,
				 ['@xp'] = xpbd + (value)
                }
                )
	 end)
end)


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
   
	MySQL.Async.fetchAll("UPDATE users SET xp = @xp WHERE identifier = @identifier",
                {
                 ['@identifier'] = xPlayer.identifier,
				 ['@xp'] = xpbd - (value)
                }
                )
	 end)
end)

Client side… Add xp

TriggerServerEvent('AddXp', 10)

Client side RemoveXp

TriggerServerEvent('RemoveXp', 500)

Those Trigger Save with esx framework to the database
in this case i created an xp column in the users tab. Change xp to rank in your case (server side code)

here a little exemple where to put trigger… in fact just after an XNL Add or XNL remove…

exemple:

#Add 10
exports.XNLRankBar:Exp_XNL_AddPlayerXP(10)
TriggerServerEvent('AddXp', 10)			  
#remove 500
exports.XNLRankBar:Exp_XNL_RemovePlayerXP(500)
TriggerServerEvent('RemoveXp', 500)
4 Likes

Thanks, wonderful to see others (with the same framework) helping each other out and that script is useful for people :slight_smile:

1 Like

Added your reply to the main post as guidance for ESX users :slight_smile:

1 Like

And this part…
Added server side…
it retrieve the xp in database at a player connection and add XNL xp in game…

ESX               = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(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)
        xpbd = result[1].xp
    end)
    
    Wait(0)
    TriggerClientEvent('XNL_NET:AddPlayerXP', source , xpbd)
end)	

note this part is a complete version of
Jules_Lucas Fix
Thanks for helping me out with this dude.

Credits in main post appropriately adjusted :wink: Thanks you both, bet it will be useful for many other users whom use ESX :slight_smile:

1 Like

They still have to work a litlle. :slight_smile: By Adding in their DB table xp or rank or whatever they like…
and figure out where to put trigger…

As you said this is for DEV users that create and play with their script and little knowledge in scripting is necessary.

Thanks again for this wonderful release.

1 Like

Thanks for the appreciation :smiley:

Well in my opinion this should always be the case if you’re running your “own custom server” :wink: haha

I TRY to make it as LESS "dev’ as possible, but since i’m not working with frameworks of others it’s not possible to make it ‘totally drop and play’ for everyone, and that’s also why i appreciate users like you (two) helping the other framework users out :slight_smile:

Oh yes I did not understand that this trigger was equal to his thanks

Yes, my script adds 500 XP every hour in the bdd

Jup haha, if you for example use “AddXP” while the player joins instead of using “SetInitial…” and that player would be level 150 (just an example)… it would keep filling up ALL bars from level 1 till it reaches level 150 (which would be ANNOYING AS F*CK for those players :rofl:

What is the purpose of this script? What benefit to level up?

The purpose of this script, just as explained in the post is that it re-enables users to use the normal native GTA Rankbar/XP Bar again.

Many gamemodes/scripts now use a ‘on screen text’ which shows xp or level, and with my script it’s possible again to use the normal XP rank bar once again :slight_smile:

This script itself (like it also clearly mentions in the post) does not do ANYTHING with levels or storing levels, it’s a User Interface tool which gives opportunities to use the native HUD components of GTA again :slight_smile:

And thus YOU can add ‘benifits’ to leveling on your server again for example and then use this XP bar to show the progress like it should do normally on GTA Online :slight_smile:

1 Like

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

Is it possible to get exp each time a delivery is made, in esx_truckerjob?

Yes it would be, IF either the developer of esx_truckerjob or you (if capable of it of course) adds the support for rewarding XP to the jobscript.

Keep in mind though (just like mentioned at the initial post): This script does NOT save XP, ranks or so. This script is purely made so that people have ‘normal access’ to the regular game rankbar/xpbar interface again :slight_smile:

And then everyone can implement it on his/her server where he/she wants, or even implement it in his/her/their framework.

MY OWN server does save XP and fully utilizes the rankbar, BUT i’m NOT using esx, vRP or any other framework, I’'m making my own framework, and this resource is just one of the portions I’ve written for my own server and shared in a way so that others can also use it to implement on their own gamemode, script or job :slight_smile: