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
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.
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
for the last line, when it’s loading the XP the first time (on spawning) looks much nicer/more complete AND it will not make the game go through ALL levels nonstop if the player has a high level
Else your code will cause the player to level up from 0 to level 50 for example if they are level 50
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…
Well in my opinion this should always be the case if you’re running your “own custom server” 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
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
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
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
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
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
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