I dont think im displaying the GTA:Online Rank Bar or MP_RANK_BAR Component correctly

Language: C# Using Citizen, Citizen.Core, Citizen.Core.Screen

Background Context: Im attempting to display and otherwise call the Rank bar from GTA:Online into FiveM

Issue: Calling it via Screen.HUD.ShowComponentThisFrame(HudComponent.MpRankBar) Does not seem to work, in fact calling anything other than the cash or bank cash using ShowComponentThisFrame() does not seem to work.

What i’ve tried: Well the thing is, i actually got it to work. But there is some complications and some hoops i had to jump through. instead of just showing the actual rank bar, it turns out you first need to request and load it using Function.Call(Hash._REQUEST_HUD_SCALEFORM, 19); and then waiting for it to load, then you may call a Hud native function using _BEGIN_SCALEFORM_MOVIE_METHOD_HUD_COMPONENT followed by the function name.

The thing is, i dont think this is the ‘correct’ way of displaying the rank bar and the reason why i think that is how the cash is displayed. Thanks to someone else in these forums for asking, it turns out that in order to modify the cash you need to call it by StatSetInt(Hash, amount, true) and the hud will animate and take care of the rest. So is that not the same for the rank bar? I’ve dug through the stat files and found

  StatSetInt(CHAR_XP_FM, 34242, true);
  StatSetInt(CHAR_RANK_FM, 20, true);

   StatSetInt(NEXT_RANKXP_FM, 21, true);
   StatSetInt(PREV_RANKXP_FM, 19, true);

But to no avail. My guess is there must be some way, code wise that doesn’t require loading that you can set the rank experience and/or level and it animates itself like the cash does. If anyone has any experience in this field and/or scaleforms in general, i would be great full if you can assist

1 Like

Currently I’m working on exactly the same issue/part for my ‘from scratch server’ (rather than using frameworks, only thing (while i already have A LOT of the normal single player and multiplayer features re-developed for FiveM (which will be released later on though) is that my Rank bar WILL show up now, but i can’t seem to assign XP/RP to the player (YET).

Will resume my search and experimenting meanwhile, but was interested if you or anyone else had found a working solution already? :slight_smile:

UPDATE:
Okay GREAT NEWS!

I got the original XP/Rankbar functioning including the leveling animations! :slight_smile:

So I will now work on making it into a useful resource and then post it in releases for others to use and/or implement in an easy way :slight_smile:

Well as promised,
And posting it here since this is (nearly) the only post i could find when i needed info about using it (so others can also find it more easily when they are looking for it :slight_smile: )

I have made a fully functional script to interface with the rankbar and published it here:

3 Likes

Hey its nice to see someone acually got some use out of this 7 months later lol. i acually implemented it the way you implemented it but never posted the resource because i was never quite happy with it. Glad you got it working. Need to take a look at yours to see what you did differently

1 Like

Thanks man, unfortunately i could not use much from your inital post however the ‘hint’ of “HudComponent.MpRankBar” was a huge help so i knew where to look inside the swf files :slight_smile:

If you still might have issues just PM me or so :slight_smile: won’t mind helping out :+1: