├── ScreenShotExamples ├── TakingAwayXP.gif ├── InitialSetupDuringSpawn.gif └── MultipleLevelsUpAnimation.gif ├── XNLRankBar ├── __resource.lua └── client.lua └── readme.md /ScreenShotExamples/TakingAwayXP.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VenomXNL/XNLRankBar/HEAD/ScreenShotExamples/TakingAwayXP.gif -------------------------------------------------------------------------------- /ScreenShotExamples/InitialSetupDuringSpawn.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VenomXNL/XNLRankBar/HEAD/ScreenShotExamples/InitialSetupDuringSpawn.gif -------------------------------------------------------------------------------- /ScreenShotExamples/MultipleLevelsUpAnimation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VenomXNL/XNLRankBar/HEAD/ScreenShotExamples/MultipleLevelsUpAnimation.gif -------------------------------------------------------------------------------- /XNLRankBar/__resource.lua: -------------------------------------------------------------------------------- 1 | resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' 2 | 3 | client_scripts { 4 | 'client.lua' 5 | } 6 | 7 | 8 | export 'Exp_XNL_SetInitialXPLevels' 9 | export 'Exp_XNL_AddPlayerXP' 10 | export 'Exp_XNL_RemovePlayerXP' 11 | export 'Exp_XNL_GetCurrentPlayerXP' 12 | export 'Exp_XNL_GetLevelFromXP' 13 | export 'Exp_XNL_GetCurrentPlayer' 14 | export 'Exp_XNL_GetCurrentPlayerLevel' 15 | export 'Exp_XNL_GetXPCeilingForLevel' 16 | export 'Exp_XNL_GetXPFloorForLevel' 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ------------------------------------------------ 2 | Getting quite 'annoyed' by now, by people which keep adding "issues" to "ask" for functions they want in THEIR script, READ THE DOCUMENTATION before even considering to openining an issue! This Resource DOES NOT save, manage or limit level perks etc! It doesn't even store levels/xp! It's "JUST" an graphical interface. 3 | ------------------------------------------------ 4 | 5 | 6 | Basic Information: 7 | What is it: This is a FiveM scripts which gives you the ability to use the normal 8 | ingame Rank/XP Bar to use in your own gamemode/server. 9 | 10 | My scripts supports several function calls like for example 11 | the first 'init' when spawning: 12 | ![alt text](https://github.com/VenomXNL/XNLRankBar/blob/master/ScreenShotExamples/InitialSetupDuringSpawn.gif) 13 | 14 | Also supports rankbar animation when gaining multiple levels at once: 15 | ![alt text](https://github.com/VenomXNL/XNLRankBar/blob/master/ScreenShotExamples/MultipleLevelsUpAnimation.gif) 16 | 17 | And as extra addition it also supports taking away XP (with a red color), 18 | which can for example be used when an server admin uses an "XP punishment": 19 | ![alt text](https://github.com/VenomXNL/XNLRankBar/blob/master/ScreenShotExamples/TakingAwayXP.gif) 20 | 21 | KNOWN 'ISSUES': 22 | - It CURRENTLY doesn't support to color the 'globes'/level circles (except the normal color blue) 23 | - When ranking 'down' (taking away XP) it doesn't animate the 'level globes' (and i don't care for that either :P) 24 | 25 |

26 | Script License and Usage 27 |

28 | 29 | This script has been fully written from scratch by VenomXNL 30 | FiveM Account: https://forum.fivem.net/u/VenomXNL/ 31 | 32 | I've spend a sh*tload of time on research to get it to function like 33 | I wanted (near original game style), spend lots of time on trial 34 | and errors, and even debugging the original game to be "100% certain" 35 | of the correct parameters. So PLEASE have decency and respect the 36 | small 'requests' in my license :) 37 | 38 | 39 | I won't put up all kinds of MIT, CC or what ever licenses etc here for 40 | you to read and/or understand. Just some basic 'rules' which count as 41 | my license and license limitations: 42 | 43 | Limitations, You: 44 | - CAN NOT Claim that this script is yours or that you've made it 45 | - CAN NOT Make a small adaption and call it an "improved version" or "updated version" 46 | - CAN NOT EVER sell this script or include it in 'sold bundles' 47 | - CAN NOT Redistribute it elsewhere (I MYSELF will maintain the latest release version on MY github) 48 | - CAN NOT Re-upload your 'own version' without WRITTEN permission on my FiveM account! 49 | - CAN NOT Use it on servers which violate the FiveM ToS about making profits! (Yeah, aint I a bitch? :P) 50 | 51 | However: 52 | - You CAN Implement it in your own game-mode/server 53 | - You CAN adapt/change it (OBVIOUSLY) to your own needs for your server (just NO re-uploading without permission) 54 | 55 |

56 | Implementations into frameworks (Like ESX, vRP, EssentialMode or whatever is out there) 57 |

58 | So we can't redistribute it into our framework without permission? 59 | Yes you CAN implement AND redistribute it into frameworks, altough I would HIGHLY appreciate 60 | it that you would send me a message (PM or so) that you are using it in your framework so 61 | that I know that my script is of good use and being a useful resource 62 | 63 | What is MANDATORY though when implementing it in frameworks like ESX, vRP or any other, 64 | is that you DO PUT THE APPROPRIATE credits in the code at my rankbar scrip section(s)! 65 | 66 |

67 | Implementations or 'moduled versions' for gamemodes 68 |

69 | I'm I for example allowed to "just make an ESX version" as 'addon' for ESX and then 70 | publish it for ESX users? 71 | 72 | NO! You will NEED PERMISSION to do so! 73 | WHY? Well simple: Since I want to prevent the forums and releases section from flooding 74 | with all kinds of 'alternate versions' of my script like for example: 75 | - XNLRankBar (original) 76 | - XNLRankBar [ESX Addon] 77 | - XNLRankBar [vRP Addon] 78 | - XNLRankBar [EsMode Addon] 79 | - XNLRankBar [MyFramework Addon] 80 | 81 | etc etc etc, 82 | 83 | This will just causes a freaking mess on the forum and impossible to decently 84 | maintain script. So IF there is (ENOUGH!) need/requests for an addon for one of the 85 | frameworks (and the framework itself doesn't want or refuses to implement it) THEN 86 | ONE other developer/scripter can get permission to adapt the code to make it compatible 87 | for that framework, but ONLY ON REQUEST. 88 | 89 |

90 | Q&A 91 |

92 | Q: Will you (VenomXNL) make 'alternate versions' to support frameworks like ESX, vRP etc? 93 | A: NO I WILL NOT, I Do NOT use frameworks myself (I'm developing my OWN 100% 94 | custom server from scratch with my own (non-released) 'framework'. And thus I have no 95 | interest in installing other frameworks or scripts to test adaptions. 96 | When i would do this i would need to either: 97 | A: Install a 'massive framework' and run it without knowing what the code's actually do 98 | or B: Install the framework and read all code so i know what runs on my server. 99 | So NOPE, not going to happen, When I write, run or test code I want to know 100% what 100 | that code does, or even better: have written it > 99% by myself. 101 | 102 | Q: Why are you so strict on 'the license' and usage? 103 | A: Well basically i'm not strict, you can use it, adapt it, use it on your server etc etc, 104 | You just can't 'steal the code' and take credits, profits or any other 'common sense abuse' of it 105 | IF you think those 'limitatations' are 'unfair' or 'to strict' then you are proberbly not 106 | having the 'correct intentions' with code written by others ;) 107 | 108 | Q: Why do you have so much comments in your code? 109 | A: To make sure it is well documented and explained as clearly as possible, so it's usable for 110 | "all levels" of scripters (from beginner to advanced). And also in the HOPES to get more 111 | beginners interested in coding due to them actually understanding what it does and thus 112 | them actually learning scripting themselves to :) 113 | 114 | Q: You seem to limit 'extra versions' for frameworks, do you have something against frameworks? 115 | A: Well... euhm.. yes and no... : 116 | I don't mind frameworks, don't mind basic toolsets to make a basic setup/startup. 117 | What I DO mind is that so many people install sh*tloads of frameworks and addonds for them 118 | without understanding the most basic aspect of scripting in games like these. 119 | 120 | The issue I have with that is that it often causes issues, people complaining about conflicts 121 | and script problems and 'admins' running servers without actually knowing what the server and or 122 | scripts do on their server.. And then the part that AWESOME scripts are made but only are compatible 123 | with "sh*tloads or requirements" like entire frameworks for just a "simple small extra function". 124 | 125 | I would rather see scripts being developed in the style like this one for example, where the script 126 | has it's own "OnPlayerEvent" functions that are called so that everyone can use them. 127 | 128 | So NOPE i don't have anything against frameworks, but DO have something against the way how many people 129 | use them without knowing a single bit of coding and then complaining at the developers about conflicting scripts 130 | and due to that lots of scripts flooding the forums with 'alternate versions' to "fix an issue" which isn't even 131 | an issue when the script would just be made "universally compatible" 132 | 133 | -------------------------------------------------------------------------------- /XNLRankBar/client.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | ===================================================================== 3 | Script License and Usage V1.2 4 | ===================================================================== 5 | 6 | This script has been fully written from scratch by VenomXNL 7 | FiveM Account: https://forum.fivem.net/u/VenomXNL/ 8 | 9 | I've spend a sh*tload of time on research to get it to function like 10 | I wanted (near original game style), spend lots of time on trial 11 | and errors, and even debugging the original game to be "100% certain" 12 | of the correct parameters. So PLEASE have decency and respect the 13 | small 'requests' in my license :) 14 | 15 | 16 | I won't put up all kinds of MIT, CC or what ever licenses etc here for 17 | you to read and/or understand. Just some basic 'rules' which count as 18 | my license and license limitations: 19 | 20 | Limitations, You: 21 | - CAN NOT Claim that this script is yours or that you've made it 22 | - CAN NOT Make a small adaption and call it an "improved version" or "updated version" 23 | - CAN NOT EVER sell this script or include it in 'sold bundles' 24 | - CAN NOT Redistribute it elsewhere (I MYSELF will maintain the latest release version on MY github) 25 | - CAN NOT Re-upload your 'own version' without WRITTEN permission on my FiveM account! 26 | - CAN NOT Use it on servers which violate the FiveM ToS about making profits! (Yeah, aint I a bitch? :P) 27 | 28 | However: 29 | - You CAN Implement it in your own game-mode/server 30 | - You CAN adapt/change it (OBVIOUSLY) to your own needs for your server (just NO re-uploading without permission) 31 | 32 | ========================================================================================= 33 | Implementations into frameworks (Like ESX, vRP, EssentialMode or whatever is out there) 34 | ========================================================================================= 35 | So we can't redistribute it into our framework without permission? 36 | Yes you CAN implement AND redistribute it into frameworks, altough I would HIGHLY appreciate 37 | it that you would send me a message (PM or so) that you are using it in your framework so 38 | that I know that my script is of good use and being a useful resource 39 | 40 | What is MANDATORY though when implementing it in frameworks like ESX, vRP or any other, 41 | is that you DO PUT THE APPROPRIATE credits in the code at my rankbar scrip section(s)! 42 | 43 | 44 | ========================================================================================= 45 | Implementations or 'moduled versions' for gamemodes 46 | ========================================================================================= 47 | I'm I for example allowed to "just make an ESX version" as 'addon' for ESX and then 48 | publish it for ESX users? 49 | 50 | NO! You will NEED PERMISSION to do so! 51 | WHY? Well simple: Since I want to prevent the forums and releases section from flooding 52 | with all kinds of 'alternate versions' of my script like for example: 53 | - XNLRankBar (original) 54 | - XNLRankBar [ESX Addon] 55 | - XNLRankBar [vRP Addon] 56 | - XNLRankBar [EsMode Addon] 57 | - XNLRankBar [MyFramework Addon] 58 | 59 | etc etc etc, 60 | 61 | This will just causes a freaking mess on the forum and impossible to decently 62 | maintain script. So IF there is (ENOUGH!) need/requests for an addon for one of the 63 | frameworks (and the framework itself doesn't want or refuses to implement it) THEN 64 | ONE other developer/scripter can get permission to adapt the code to make it compatible 65 | for that framework, but ONLY ON REQUEST. 66 | 67 | 68 | ========================================================================================= 69 | Q&A 70 | ========================================================================================= 71 | Q: Will you (VenomXNL) make 'alternate versions' to support frameworks like ESX, vRP etc? 72 | A: NO I WILL NOT, I Do NOT use frameworks myself (I'm developing my OWN 100% 73 | custom server from scratch with my own (non-released) 'framework'. And thus I have no 74 | interest in installing other frameworks or scripts to test adaptions. 75 | When i would do this i would need to either: 76 | A: Install a 'massive framework' and run it without knowing what the code's actually do 77 | or B: Install the framework and read all code so i know what runs on my server. 78 | So NOPE, not going to happen, When I write, run or test code I want to know 100% what 79 | that code does, or even better: have written it > 99% by myself. 80 | 81 | Q: Why are you so strict on 'the license' and usage? 82 | A: Well basically i'm not strict, you can use it, adapt it, use it on your server etc etc, 83 | You just can't 'steal the code' and take credits, profits or any other 'common sense abuse' of it 84 | IF you think those 'limitatations' are 'unfair' or 'to strict' then you are proberbly not 85 | having the 'correct intentions' with code written by others ;) 86 | 87 | Q: Why do you have so much comments in your code? 88 | A: To make sure it is well documented and explained as clearly as possible, so it's usable for 89 | "all levels" of scripters (from beginner to advanced). And also in the HOPES to get more 90 | beginners interested in coding due to them actually understanding what it does and thus 91 | them actually learning scripting themselves to :) 92 | 93 | Q: You seem to limit 'extra versions' for frameworks, do you have something against frameworks? 94 | A: Well... euhm.. yes and no... : 95 | I don't mind frameworks, don't mind basic toolsets to make a basic setup/startup. 96 | What I DO mind is that so many people install sh*tloads of frameworks and addonds for them 97 | without understanding the most basic aspect of scripting in games like these. 98 | 99 | The issue I have with that is that it often causes issues, people complaining about conflicts 100 | and script problems and 'admins' running servers without actually knowing what the server and or 101 | scripts do on their server.. And then the part that AWESOME scripts are made but only are compatible 102 | with "sh*tloads or requirements" like entire frameworks for just a "simple small extra function". 103 | 104 | I would rather see scripts being developed in the style like this one for example, where the script 105 | has it's own "OnPlayerEvent" functions that are called so that everyone can use them. 106 | 107 | So NOPE i don't have anything against frameworks, but DO have something against the way how many people 108 | use them without knowing a single bit of coding and then complaining at the developers about conflicting scripts 109 | and due to that lots of scripts flooding the forums with 'alternate versions' to "fix an issue" which isn't even 110 | an issue when the script would just be made "universally compatible" 111 | 112 | ]] 113 | 114 | --========================================================================================= 115 | -- Script information and details 116 | --========================================================================================= 117 | -- These are the original Rockstar XP/RP requirements per level (till level 100), after level 100 i'm using a 'simple formula' to 118 | -- calculate the correct levels and related XP floor and ceilings for those levels since from there on it's just a 'base offset' 119 | -- 28500XP EXTRA which is required per level which will be increased by 50 for each next level. 120 | -- 121 | -- Basic Explanation: Going from level 99 to level 100 requires 28550 XP ontop of the XP the player already has. 122 | -- Going from level 100 to level 101 requires 28600 XP ontop of the XP the player already has. 123 | -- 124 | -- So from level 100 and up I can just use a simple "for loop formula" to generate/calculate the correct XP levels 125 | -- 126 | -- BUT bellow level 100 there isn't really a 'steady structure', in the XP requirements bellow level 100 rockstar 127 | -- has made several 'strange jumps' in structure (not by adding 50 every time or a 'steady/logical' amount). 128 | -- Changes like +500, +400, +600, +1100 and even -400 difference in the extra XP needed for the next level are seen. 129 | -- Therefor it was easier (and AFAIK the only way) to guarantee correct XP levels/requirements :) 130 | -- 131 | -- Ofcourse you are not obligated to stick to these levels and ranks, and you CAN change them, but I have created it this way 132 | -- since i'm making a server with all single player features, all multiplayer features and LOTS more object/location interactions 133 | -- but I/we want to re-create the 'normal gta' experiance with all 'basic game stuff' working like it does normally, 134 | -- therefor I decided to use the original levels/style... 135 | -- 136 | -- PLEASE DO KEEP IN MIND: I DO NOT! offer support for using other level styles or XP requirements! 137 | -- I did NOT designed this script to do so, and nor do I have time to make it 'custom' for lots of different servers and people's 138 | -- requirements per server style. However it should not be that hard to change the XP requirements and/or style for calculation :) 139 | -- 140 | -- More information about these ranks and their "structure" can be found at: 141 | -- https://gta.fandom.com/wiki/Rank 142 | local RockstarRanks = { 143 | 800, 2100, 3800, 6100, 9500, 12500, 16000, 19800, 24000, 28500, 33400, 38700, 44200, 50200, 56400, 63000, 69900, 77100, 84700, 92500, 144 | 100700, 109200, 118000, 127100, 136500, 146200, 156200, 166500, 177100, 188000, 199200, 210700, 222400, 234500, 246800, 259400, 272300, 145 | 285500, 299000, 312700, 326800, 341000, 355600, 370500, 385600, 401000, 416600, 432600, 448800, 465200, 482000, 499000, 516300, 533800, 146 | 551600, 569600, 588000, 606500, 625400, 644500, 663800, 683400, 703300, 723400, 743800, 764500, 785400, 806500, 827900, 849600, 871500, 147 | 893600, 916000, 938700, 961600, 984700, 1008100, 1031800, 1055700, 1079800, 1104200, 1128800, 1153700, 1178800, 1204200, 1229800, 1255600, 148 | 1281700, 1308100, 1334600, 1361400, 1388500, 1415800, 1443300, 1471100, 1499100, 1527300, 1555800, 1584350} 149 | 150 | --=================================================================================== 151 | -- "Settings" you can change 152 | --=================================================================================== 153 | XNL_UseRedBarWhenLosingXP = true -- This sets if the bar should turn red when a player is LOSING XP (due to an admin 'punishment' for example!) 154 | XNL_MaxPlayerLevel = 500 -- Sets the maximum level (Maximum which can be used is 7999!) 155 | -- This will also prevent the player from getting more XP than possible 156 | -- IF you use my variable to set/read the player XP 157 | XNL_EnableZKeyForRankbar = true -- This Enables/Disables (when you set it to false) the Rankbar showing up when the player presses Z on the keyboard 158 | 159 | --=================================================================================== 160 | -- Variable(s) you should NOT be messing with! These are used by the script to make 161 | -- sure everything runs smooth and is calculated well for 'followup' animations 162 | -- in the Rank Bar 163 | --=================================================================================== 164 | XNL_CurrentPlayerXP = 0 165 | 166 | 167 | --=================================================================================== 168 | -- !!WARNING!! !!WARNING!! !!WARNING!! !!WARNING!! !!WARNING!! !!WARNING!! 169 | --=================================================================================== 170 | -- These are BASIC EXAMPLE COMMANDS so you can test the script/rankbar INSTANTLY 171 | -- on your game by using these commands: 172 | -- XNLSetBaseXPExample [amountofxp] 173 | -- XNLAddXPExample [amountofxp] 174 | -- XNLRemoveXPExample [amountofxp] 175 | -- 176 | -- OBVIOUSLY you enter those WITHOUT the brackets ([ or ]) 177 | -- AND... even obvious: REMOVE THESE THREE COMMANDS WHEN YOU ARE GOING TO USE 178 | -- THIS SCRIPT!!!!! 179 | --=================================================================================== 180 | -- !!WARNING!! !!WARNING!! !!WARNING!! !!WARNING!! !!WARNING!! !!WARNING!! 181 | --=================================================================================== 182 | RegisterCommand("XNLAddXPExample",function(source, args) 183 | local FirstParam = args[1] 184 | TestNR = tonumber(FirstParam) 185 | XNL_AddPlayerXP(TestNR) 186 | end) 187 | 188 | RegisterCommand("XNLRemoveXPExample",function(source, args) 189 | local FirstParam = args[1] 190 | TestNR = tonumber(FirstParam) 191 | XNL_RemovePlayerXP(TestNR) 192 | end) 193 | 194 | RegisterCommand("XNLSetBaseXPExample",function(source, args) 195 | local FirstParam = args[1] 196 | TestNR = tonumber(FirstParam) 197 | XNL_SetInitialXPLevels(TestNR, true, true) 198 | end) 199 | 200 | 201 | --=================================================================================== 202 | -- This thread will Enable the player to press Z to show the current XP/Rankbar 203 | -- IT IS NOT TESTED WITH CONTROLLERS! please check or implement controller 204 | -- combatability yourself since we don't use controllers and neither allow them 205 | --=================================================================================== 206 | Citizen.CreateThread(function() 207 | if not XNL_EnableZKeyForRankbar then return end 208 | while true do 209 | Wait(1) 210 | if IsControlJustPressed(0, 20) then 211 | CurLevel = XNL_GetLevelFromXP(XNL_CurrentPlayerXP) 212 | CreateRankBar(XNL_GetXPFloorForLevel(CurLevel), XNL_GetXPCeilingForLevel(CurLevel), XNL_CurrentPlayerXP, XNL_CurrentPlayerXP, CurLevel, false) 213 | 214 | -- ShowHudComponentThisFrame(3) -- Enable this line if you want to display the native player CASH 215 | --ShowHudComponentThisFrame(4) -- Enable this line if you want to display the native player BANK amount 216 | -- NOTE ON THE TWO ABOVE: Those are NOT implemented in this script! but just as 'extra info' for a 'complete hud' 217 | end 218 | end 219 | end) 220 | 221 | 222 | --=================================================================================== 223 | -- Export Functions so they can more easily be called from external scripts :) 224 | -- as suggested by one of the Elements (oganesson): 225 | -- https://forum.fivem.net/t/release-xnlrankbar-fully-working-original-gta-rankbar-xp-bar-natively-with-original-gta-levels/318839/12?u=venomxnl 226 | --=================================================================================== 227 | exports('Exp_XNL_SetInitialXPLevels', function(EXCurrentXP, EXShowRankBar, EXShowRankBarAnimating) 228 | XNL_SetInitialXPLevels(EXCurrentXP, EXShowRankBar, EXShowRankBarAnimating) 229 | print("TEST") 230 | end) 231 | 232 | exports('Exp_XNL_AddPlayerXP', function(EXXPAmount) 233 | XNL_AddPlayerXP(EXXPAmount) 234 | end) 235 | 236 | exports('Exp_XNL_RemovePlayerXP', function(EXXPAmount) 237 | XNL_RemovePlayerXP(EXXPAmount) 238 | end) 239 | 240 | exports('Exp_XNL_GetCurrentPlayerXP', function() 241 | return tonumber(XNL_GetCurrentPlayerXP()) 242 | end) 243 | 244 | exports('Exp_XNL_GetLevelFromXP', function(EXXPAmount) 245 | return XNL_GetLevelFromXP(EXXPAmount) 246 | end) 247 | 248 | exports('Exp_XNL_GetCurrentPlayerLevel', function() 249 | return tonumber(XNL_GetCurrentPlayerLevel()) 250 | end) 251 | 252 | exports('Exp_XNL_GetXPFloorForLevel', function(IntLvl) 253 | return tonumber(XNL_GetXPFloorForLevel(IntLvl)) 254 | end) 255 | exports('Exp_XNL_GetXPCeilingForLevel', function(IntLvl) 256 | return tonumber(XNL_GetXPCeilingForLevel(IntLvl)) 257 | end) 258 | 259 | --=================================================================================== 260 | -- Client Trigger Events (so it can PARTIALLY be used server sided :) ) 261 | -- as requested by createdbyeric: 262 | -- https://forum.fivem.net/t/release-xnlrankbar-fully-working-original-gta-rankbar-xp-bar-natively-with-original-gta-levels/318839/15?u=venomxnl 263 | --=================================================================================== 264 | RegisterNetEvent("XNL_NET:XNL_SetInitialXPLevels") 265 | AddEventHandler("XNL_NET:XNL_SetInitialXPLevels", function(NetCurrentXP, NetShowRankBar, NetShowRankBarAnimating) 266 | XNL_SetInitialXPLevels(NetCurrentXP, NetShowRankBar, NetShowRankBarAnimating) 267 | end) 268 | 269 | RegisterNetEvent("XNL_NET:AddPlayerXP") 270 | AddEventHandler("XNL_NET:AddPlayerXP", function(NetXPAmmount) 271 | XNL_AddPlayerXP(NetXPAmmount) 272 | end) 273 | 274 | RegisterNetEvent("XNL_NET:RemovePlayerXP") 275 | AddEventHandler("XNL_NET:RemovePlayerXP", function(NetXPAmmount) 276 | XNL_RemovePlayerXP(NetXPAmmount) 277 | end) 278 | 279 | 280 | --=================================================================================== 281 | -- These are functions you could/can use to make this script 'ready to use' and to 282 | -- (make it ) interface with your own scripts, game modes etc :) 283 | --=================================================================================== 284 | function XNL_SetInitialXPLevels(CurrentXP, ShowRankBar, ShowRankBarAnimating) 285 | -- This function sets the 'inital XP level' (when the player first spawns for example) 286 | -- When you set ShowRankBar to true, it will show the rankbar on initial setup/spawn 287 | -- When you set ShowRankBarAnimating it will 'animate' the currentlevel from 288 | -- the bottom of that rank to the amount of XP the player has for that rank 289 | 290 | 291 | -- You can ofcourse also use the normal MP0_CHAR_XP_FM stats to set and get the XP 292 | -- just like I do myself, but for the purpose of releasing this (portion of my) 293 | -- script I have made sure to use an other 'different variable' to ensure that I would 294 | -- "not just f*ck up" stats or so on your server :) 295 | XNL_CurrentPlayerXP = CurrentXP 296 | 297 | if ShowRankBar then 298 | CurLevel = XNL_GetLevelFromXP(CurrentXP) 299 | AnimateFrom = CurrentXP 300 | if ShowRankBarAnimating then 301 | AnimateFrom = XNL_GetXPFloorForLevel(CurLevel) 302 | end 303 | CreateRankBar(XNL_GetXPFloorForLevel(CurLevel), XNL_GetXPCeilingForLevel(CurLevel), AnimateFrom, XNL_CurrentPlayerXP, CurLevel, false) 304 | end 305 | end 306 | 307 | function XNL_GetCurrentPlayerXP() 308 | -- Like the name suggests: This function simply returns the current TOTAL player xp amount 309 | -- NOTE: Which is set in MY variable in THIS SCRIPT! if you use other variables 310 | -- like MP0_CHAR_XP_FM for example, you would need to change that ofcourse! 311 | return XNL_CurrentPlayerXP 312 | end 313 | 314 | function XNL_GetCurrentPlayerLevel() 315 | -- Like the name suggests: This function simply returns the current player level 316 | -- NOTE: Which is set in MY variable in THIS SCRIPT! if you use other variables 317 | -- like MP0_CHAR_XP_FM for example, you would need to change that ofcourse! 318 | return XNL_GetLevelFromXP(XNL_CurrentPlayerXP) 319 | end 320 | 321 | function XNL_OnPlayerLevelUp() 322 | -- This function is called when the played has leveled up while getting the XP 323 | -- On my server I use this 'XNL Event' to make an 'extra save' to the database 324 | -- with the (new) player stats, we DO NOT do that on every change to prevent to 325 | -- much unneeded server traffic. 326 | 327 | -- You can for example also use this function to play a sound effect or show a pop up 328 | -- when a player has leveled up (for example to show which new jobs became availible) 329 | 330 | -- NOTE: These are just SUGGESTIONS/IDEA'S for YOU to implement, I have NOT included 331 | -- these 'features' in this script 332 | end 333 | 334 | function XNL_OnPlayerLevelsLost() 335 | -- This function is called when the played has LOST a level or levels while losing XP 336 | -- for example by an 'admin punishment'! 337 | 338 | -- On my server I use this 'XNL Event' to make an 'extra save' to the database 339 | -- with the (new) player stats, we DO NOT do that on every change to prevent to 340 | -- much unneeded server traffic. 341 | 342 | -- You can for example also use this function to check if a player has a weapon in his/here 343 | -- inventory which should be removed due to losing the level required for it, or for example 344 | -- check if the player needs to be 'kicked' from a vehicle which requires his previously 345 | -- higher level to use/drive it 346 | 347 | -- NOTE: These are just SUGGESTIONS/IDEA'S for YOU to implement, I have NOT included 348 | -- these 'features' in this script 349 | end 350 | 351 | function XNL_AddPlayerXP(XPAmount) 352 | --====================================================================================== 353 | -- "The Command" to give the player new XP (Well documented/commented) 354 | --====================================================================================== 355 | if not is_int(XPAmount) then 356 | print("=====================================================================================================") 357 | print("XNL WARNING: You have an error in one of your scripts calling the function 'XNL_AddPlayerXP'") 358 | print("XNL WARNING: The script which is calling this function is not passing an integer!") 359 | print("=====================================================================================================") 360 | return 361 | end 362 | 363 | if XPAmount < 0 then 364 | print("=====================================================================================================") 365 | print("XNL WARNING: You have an error in one of your scripts calling the function 'XNL_AddPlayerXP'") 366 | print("XNL WARNING: is trying to TAKE XP from a player, use 'XNL_RemovePlayerXP' instead!") 367 | print("=====================================================================================================") 368 | return 369 | end 370 | 371 | local CurrentLevel = XNL_GetLevelFromXP(XNL_CurrentPlayerXP) -- Remembers the CURRENT level of the player BEFORE adding the new XP 372 | local CurrentXPWithAddedXP = XNL_CurrentPlayerXP + XPAmount -- Remembers the NEW XP amount (with the new xp added to the already 'owned XP') 373 | local NewLevel = XNL_GetLevelFromXP(CurrentXPWithAddedXP) -- Remembers the NEW level which the player will get after adding the new XP (IF there would be a new level) 374 | local LevelDifference = 0 -- This variable will 'later on' remember how many levels the player has leveled up (at once) 375 | 376 | -- This section is 'my build in level cap' which can be set in the variables at the top of the script 377 | if NewLevel > XNL_MaxPlayerLevel - 1 then 378 | NewLevel = XNL_MaxPlayerLevel -1 379 | CurrentXPWithAddedXP = XNL_GetXPCeilingForLevel(XNL_MaxPlayerLevel - 1) 380 | end 381 | 382 | -- This section detects if there is a difference in level due to player gaining XP 383 | if NewLevel > CurrentLevel then 384 | LevelDifference = NewLevel - CurrentLevel 385 | end 386 | 387 | if LevelDifference > 0 then 388 | -- If we detect that the player has reached a new level we will need to make sure it also 389 | -- shows this progress in the rank bar. This function/section even supports leveling up multiple 390 | -- levels at once :) 391 | StartAtLevel = CurrentLevel 392 | CreateRankBar(XNL_GetXPFloorForLevel(StartAtLevel), XNL_GetXPCeilingForLevel(StartAtLevel), XNL_CurrentPlayerXP, XNL_GetXPCeilingForLevel(StartAtLevel), StartAtLevel, false) 393 | 394 | -- Make a loop to go through all the levels the player has received from this xp gain (if he/she received (multiple) new level(s)) 395 | for i = 1, LevelDifference ,1 396 | do 397 | StartAtLevel = StartAtLevel + 1 398 | 399 | if i == LevelDifference then 400 | -- If we have reached the 'final new level' in the loop we'll make sure it the actual current XP Total (including the newly added amount) 401 | CreateRankBar(XNL_GetXPFloorForLevel(StartAtLevel), XNL_GetXPCeilingForLevel(StartAtLevel), XNL_GetXPFloorForLevel(StartAtLevel), CurrentXPWithAddedXP, StartAtLevel, false) 402 | else 403 | -- If we to do 'multiple bar animations' we will need to make sure that it will only 'animate' to the maximum amount of XP per bar for the level it is showing, 404 | -- in MOST cases we don't even need this section since most of the time players will only level up one level at a time, but I wanted it to be '100% compatible' with 405 | -- situations where it would happen that a player skips one or multiple levels at once by gaining new XP 406 | CreateRankBar(XNL_GetXPFloorForLevel(StartAtLevel), XNL_GetXPCeilingForLevel(StartAtLevel), XNL_GetXPFloorForLevel(StartAtLevel), XNL_GetXPCeilingForLevel(StartAtLevel), StartAtLevel, false) 407 | end 408 | end 409 | else 410 | -- Here we just create the normal rankbar without the need to make it 're-appear' with the 'level up animation' 411 | CreateRankBar(XNL_GetXPFloorForLevel(NewLevel), XNL_GetXPCeilingForLevel(NewLevel), XNL_CurrentPlayerXP, CurrentXPWithAddedXP, NewLevel, false) 412 | end 413 | 414 | -- Update the variable to make it work properly the next time XP update is requested 415 | XNL_CurrentPlayerXP = CurrentXPWithAddedXP 416 | 417 | -- This function is called when the played has leveled up while getting the XP 418 | -- this is only called ONCE even when receiving enough XP to level up multiple levels at once :) 419 | if LevelDifference > 0 then 420 | XNL_OnPlayerLevelUp() 421 | end 422 | end 423 | 424 | function XNL_RemovePlayerXP(XPAmount) 425 | --====================================================================================== 426 | -- "The Command" to give the player new XP (Well documented/commented) 427 | --====================================================================================== 428 | if not is_int(XPAmount) then 429 | print("=====================================================================================================") 430 | print("XNL WARNING: You have an error in one of your scripts calling the function 'XNL_RemovePlayerXP'") 431 | print("XNL WARNING: The script which is calling this function is not passing an integer!") 432 | print("=====================================================================================================") 433 | return 434 | end 435 | 436 | if XPAmount < 0 then 437 | print("=====================================================================================================") 438 | print("XNL WARNING: You have an error in one of your scripts calling the function 'XNL_RemovePlayerXP'") 439 | print("XNL WARNING: is trying to give 'negative' XP by passing a negative value, If you for example ") 440 | print("XNL WARNING: want to remove 100XP just use: 'XNL_RemovePlayerXP(100)' to remove 100XP from the player") 441 | print("=====================================================================================================") 442 | return 443 | end 444 | 445 | local CurrentLevel = XNL_GetLevelFromXP(XNL_CurrentPlayerXP) -- Remembers the CURRENT level of the player BEFORE adding the new XP 446 | local CurrentXPWithRemovedXP = XNL_CurrentPlayerXP - XPAmount -- Remembers the NEW XP amount (with the xp removed to the already 'owned XP') 447 | local NewLevel = XNL_GetLevelFromXP(CurrentXPWithRemovedXP) -- Remembers the NEW level which the player will get after adding the new XP (IF there would be a new level) 448 | local LevelDifference = 0 -- This variable will 'later on' remember how many levels the player has leveled up (at once) 449 | 450 | -- This section makes sure that the player doesn't get bellow level 1 (to prevent game crashes or weird sh*t from happening (I DID NOT tested what happens if you try to set it bellow 1!) 451 | if NewLevel < 1 then 452 | NewLevel = 1 453 | end 454 | 455 | if CurrentXPWithRemovedXP < 0 then 456 | CurrentXPWithRemovedXP = 0 457 | end 458 | 459 | 460 | -- This section detects if there is a difference in level due to player losing XP 461 | if NewLevel < CurrentLevel then 462 | LevelDifference = math.abs(NewLevel - CurrentLevel) -- Math(ematical) function gets the absolute difference between the Current and new level (counting the 'level loss') 463 | end 464 | 465 | if LevelDifference > 0 then 466 | -- If we detect that the player has reached a new level we will need to make sure it also 467 | -- shows this progress in the rank bar. This function/section even supports leveling up multiple 468 | -- levels at once :) 469 | StartAtLevel = CurrentLevel 470 | CreateRankBar(XNL_GetXPFloorForLevel(StartAtLevel), XNL_GetXPCeilingForLevel(StartAtLevel), XNL_CurrentPlayerXP, XNL_GetXPFloorForLevel(StartAtLevel), StartAtLevel, true) 471 | 472 | -- Make a loop to go through all the levels the player has received from this xp gain (if he/she received (multiple) new level(s)) 473 | for i = 1, LevelDifference ,1 474 | do 475 | StartAtLevel = StartAtLevel - 1 476 | 477 | if i == LevelDifference then 478 | -- If we have reached the 'final new level' in the loop we'll make sure it the actual current XP Total (including the newly added amount) 479 | CreateRankBar(XNL_GetXPFloorForLevel(StartAtLevel), XNL_GetXPCeilingForLevel(StartAtLevel), XNL_GetXPCeilingForLevel(StartAtLevel), CurrentXPWithRemovedXP, StartAtLevel, true) 480 | else 481 | -- If we to do 'multiple bar animations' we will need to make sure that it will only 'animate' to the maximum amount of XP per bar for the level it is showing, 482 | -- in MOST cases we don't even need this section since most of the time players will only level up one level at a time, but I wanted it to be '100% compatible' with 483 | -- situations where it would happen that a player skips one or multiple levels at once by gaining new XP 484 | CreateRankBar(XNL_GetXPFloorForLevel(StartAtLevel), XNL_GetXPCeilingForLevel(StartAtLevel), XNL_GetXPCeilingForLevel(StartAtLevel), XNL_GetXPFloorForLevel(StartAtLevel), StartAtLevel, true) 485 | end 486 | end 487 | else 488 | -- Here we just create the normal rankbar without the need to make it 're-appear' with the 'level animation' 489 | CreateRankBar(XNL_GetXPFloorForLevel(NewLevel), XNL_GetXPCeilingForLevel(NewLevel), XNL_CurrentPlayerXP, CurrentXPWithRemovedXP , NewLevel, true) 490 | end 491 | 492 | -- Update the variable to make it work properly the next time XP update is requested 493 | XNL_CurrentPlayerXP = CurrentXPWithRemovedXP 494 | 495 | -- This function is called when the played has leveled up while getting the XP 496 | -- this is only called ONCE even when receiving enough XP to level up multiple levels at once :) 497 | if LevelDifference > 0 then 498 | XNL_OnPlayerLevelsLost() 499 | end 500 | end 501 | 502 | --====================================================================================== 503 | --====================================================================================== 504 | -- Basicaly if you're a 'standard user/implementor' of my script, you would not need 505 | -- to use, change or 'worry about' the functions bellow and they should have no 506 | -- (direct) use to you, the functions bellow just ensure proper functioning of the 507 | -- script and rankbar :) 508 | --====================================================================================== 509 | --====================================================================================== 510 | 511 | --====================================================================================== 512 | -- This function calculates (or gets while still bellow level 100!) 513 | -- the 'floor level' XP amount for the level you're asking it for 514 | -- this is required to set the 'start position' of the rankbar to animate 515 | -- 516 | -- NOTE: Technically you DO NOT NEED to interface or 'mess' with this function! 517 | -- This function is CRUCIAL for proper rank bar animations and has NOTHING 518 | -- todo with setting user ranks, levels, rp or whatever you want to call it! 519 | -- You do NOT need to change this function or so to set level limits or so, 520 | -- you would only need to if you want to make different XP levels than the 521 | -- original game has! 522 | --====================================================================================== 523 | function XNL_GetXPFloorForLevel(intLevelNr) 524 | if is_int(intLevelNr) then 525 | 526 | -- This is some 'basic build in security' JUST IN CASE people DO think it'scaleform 527 | -- a good idea to mess with these functions! 528 | if intLevelNr > 7999 then 529 | intLevelNr = 7999 530 | print("=====================================================================================================") 531 | print("XNL WARNING: You have an error in one of your scripts which is trying to get the floor level XP for") 532 | print("XNL WARNING: an player level beyond level 7999, which is the game limit!") 533 | print("XNL WARNING: Script has prevented this and set the 'limit' to 7999!") 534 | print("=====================================================================================================") 535 | end 536 | 537 | -- If the level is set bellow 2 (so basically level 1 since level 0 doesn't exist!) 538 | -- we will automatically return that the 'floor' of this level is 0XP (since it's not in the list) 539 | if intLevelNr < 2 then 540 | return 0 541 | end 542 | 543 | if intLevelNr > 100 then 544 | BaseXP = RockstarRanks[99] -- Get the 'base XP' from the last known original rockstar level (100) in my table 545 | ExtraAddPerLevel = 50 -- This is the amount which rockstar ADDS on the amount required for the next level PER next level 546 | MainAddPerLevel = 28550 -- This is the amount of XP required for level 100 ***MINUS 50 so my "formula" will work correctly!*** 547 | -- I'll try to explain in easy words: When going from level 100 to level 101 you'll need 28600XP, 548 | -- when going from level 101 to level 101 you will need 28650XP .... So Notice the extra 50 XP here? 549 | 550 | BaseLevel = intLevelNr - 100 -- Here we make sure that the first 100 levels are 'excluded' from the loop since we already have a base offset. 551 | CurXPNeeded = 0 -- This variable will remember the total XP for the level (and adds to it during the loop below) 552 | for i = 1, BaseLevel ,1 553 | do 554 | MainAddPerLevel = MainAddPerLevel + 50 -- Adding 50 extra XP per new level we pass in the loop 555 | CurXPNeeded = CurXPNeeded + MainAddPerLevel -- Adding the total + XP for the current passed Level in the loop (including the +50 per level) 556 | end 557 | 558 | return BaseXP + CurXPNeeded -- Returning the Base XP from the last known 'rockstar rank' and adding the new extra rank(s) XP to it 559 | end 560 | 561 | -- IF the level we're requesting the "floor xp" from is level 100 or bellow we'll take the amount of XP 562 | -- required from the table I've put in this script which uses the original rockstar XP levels 563 | return RockstarRanks[intLevelNr - 1] 564 | else 565 | print("=====================================================================================================") 566 | print("XNL WARNING: You have an error in one of your scripts calling the function 'XNL_GetXPFloorForLevel'") 567 | print("XNL WARNING: The script which is calling this function is not passing an integer!") 568 | print("=====================================================================================================") 569 | return 0 -- YES this MIGHT cause an XP bar which will not show xp drawing for a moment IF there is an error in the script, but it will prevent crashing! 570 | end 571 | end 572 | 573 | --====================================================================================== 574 | -- This function calculates (or gets while still bellow level 99!) 575 | -- the 'ceiling level' XP amount for the level you're asking it for 576 | -- this is required to set the 'end position' of the rankbar to animate AND it's used 577 | -- to show the second part of the progress: the "1500/2000" bellow the rankbar 578 | -- 579 | -- NOTE: Technically you DO NOT NEED to interface or 'mess' with this function! 580 | -- This function is CRUCIAL for proper rank bar animations and has NOTHING 581 | -- todo with setting user ranks, levels, rp or whatever you want to call it! 582 | -- You do NOT need to change this function or so to set level limits or so, 583 | -- you would only need to if you want to make different XP levels than the 584 | -- original game has! 585 | --====================================================================================== 586 | function XNL_GetXPCeilingForLevel(intLevelNr) 587 | if is_int(intLevelNr) then 588 | 589 | -- This is some 'basic build in security' JUST IN CASE people DO think it'scaleform 590 | -- a good idea to mess with these functions! 591 | if intLevelNr > 7999 then 592 | intLevelNr = 7999 593 | print("=====================================================================================================") 594 | print("XNL WARNING: You have an error in one of your scripts which is trying to get the ceiling level XP") 595 | print("XNL WARNING: for an player level beyond level 7999, which is the game limit!") 596 | print("XNL WARNING: Script has prevented this and set the 'limit' to 7999!") 597 | print("=====================================================================================================") 598 | end 599 | 600 | -- If the level is set bellow 2 (so basically level 1 since level 0 doesn't exist!) 601 | -- we will automatically return that the 'floor' of this level is 0XP (since it's not in the list) 602 | if intLevelNr < 1 then 603 | print("=====================================================================================================") 604 | print("XNL WARNING: You have an error in one of your scripts which is trying to get the ceiling level XP") 605 | print("XNL WARNING: for an player level BELLOW level 1, which is the game limit!") 606 | print("XNL WARNING: Script has prevented this and set the 'limit' back to 1!") 607 | print("=====================================================================================================") 608 | return 800 -- NOTE: If you have changed the "original Rockstar Level Table" you will need to change this one to! 609 | end 610 | 611 | if intLevelNr > 99 then 612 | BaseXP = RockstarRanks[99] 613 | ExtraAddPerLevel = 50 -- This is the amount which rockstar ADDS on the amount required for the next level PER next level 614 | MainAddPerLevel = 28550 -- This is the amount of XP required for level 100 ***MINUS 50 so my "formula" will work correctly!*** 615 | -- I'll try to explain in easy words: When going from level 100 to level 101 you'll need 28600XP, when going from level 101 to level 101 616 | -- you will need 28650XP .... So Notice the extra 50 XP here? 617 | 618 | -- NOTE: This section bellow is 'well documented' in the function XNL_GetXPFloorForLevel above, so no need to comment it all twice :) 619 | BaseLevel = intLevelNr - 99 620 | CurXPNeeded = 0 621 | for i = 1, BaseLevel ,1 622 | do 623 | MainAddPerLevel = MainAddPerLevel + 50 624 | CurXPNeeded = CurXPNeeded + MainAddPerLevel 625 | end 626 | 627 | return BaseXP + CurXPNeeded 628 | end 629 | 630 | -- IF the level we're requesting the "ceiling xp" for is level 99 or bellow we'll take the amount of XP 631 | -- required from the table I've put in this script which uses the original rockstar XP levels 632 | return RockstarRanks[intLevelNr] 633 | else 634 | print("=====================================================================================================") 635 | print("XNL WARNING: You have an error in one of your scripts calling the function 'XNL_GetXPCeilingForLevel'") 636 | print("XNL WARNING: The script which is calling this function is not passing an integer!") 637 | print("=====================================================================================================") 638 | return 0 -- YES this MIGHT cause an XP bar which will not show xp drawing for a moment IF there is an error in the script, but it will prevent crashing! 639 | end 640 | end 641 | 642 | function XNL_GetLevelFromXP(intXPAmount) 643 | --====================================================================================== 644 | -- This function 'converts' the XP amount you 'put in' to the level belongs to/in 645 | -- NOTE: This function does NOT have an 'upper limit' or 'error handling' on entering 646 | -- INSANE amounts since it should NOT happen if the scripts using these features 647 | -- are scripted normally! Especially not when considering that the maximum level 648 | -- "supported" is 7999! ;) 649 | --====================================================================================== 650 | if is_int(intXPAmount) then 651 | local SearchingFor = intXPAmount 652 | 653 | if SearchingFor < 0 then return 1 end -- Just return level 1 if an XP level BELLOW 0 is given 654 | 655 | if SearchingFor < RockstarRanks[99] then -- Check if the XP amount is smaller than the last item (level 100) in my 'Rockstar XP Requirements level list' 656 | local CurLevelFound = -1 657 | 658 | local CurrentLevelScan = 0 659 | for k,v in pairs(RockstarRanks)do -- And if it's bellow the 'maximum known rockstar XP requirement' scan the table here 660 | CurrentLevelScan = CurrentLevelScan + 1 -- Just keep counting +1 for each level that doesn't match the xp level 661 | if SearchingFor < v then break end -- when we found it, break the loop and report the level we've found :) 662 | end 663 | 664 | return CurrentLevelScan 665 | else 666 | -- If the amount of XP you're trying to get the level from is above the maximum XP amount in the rockstar XP requirements list (level 100) 667 | -- then we'll make our own loop to find the correct level here :) 668 | BaseXP = RockstarRanks[99] 669 | ExtraAddPerLevel = 50 -- This is the amount which rockstar ADDS on the amount required for the next level PER next level 670 | MainAddPerLevel = 28550 -- This is the amount of XP required for level 100 ***MINUS 50 so my "formula" will work correctly!*** 671 | -- I'll try to explain in easy words: When going from level 100 to level 101 you'll need 28600XP, when going from level 101 to level 101 672 | -- you will need 28650XP .... So Notice the extra 50 XP here? 673 | 674 | CurXPNeeded = 0 675 | local CurLevelFound = -1 676 | for i = 1, XNL_MaxPlayerLevel - 99 ,1 -- The - 99 in this loop ensures that the for loop result excludes the first 99 levels which are 677 | do -- already 'covered by' the table at the top 678 | MainAddPerLevel = MainAddPerLevel + 50 679 | CurXPNeeded = CurXPNeeded + MainAddPerLevel 680 | CurLevelFound = i 681 | if SearchingFor < (BaseXP + CurXPNeeded) then break end 682 | end 683 | 684 | return CurLevelFound + 99 685 | end 686 | else 687 | print("=====================================================================================================") 688 | print("XNL WARNING: You have an error in one of your scripts calling the function 'XNL_GetLevelFromXP'") 689 | print("XNL WARNING: The script which is calling this function is not passing an integer!") 690 | print("=====================================================================================================") 691 | return 1 -- YES this MIGHT return the incorrect level... BUT will prevent possible crashes! 692 | end 693 | end 694 | 695 | --=================================================================================== 696 | -- This is the function that actually 'generates' the Rankbar and sets the variables 697 | -- for it to make it function like it should 698 | --=================================================================================== 699 | function CreateRankBar(XP_StartLimit_RankBar, XP_EndLimit_RankBar, playersPreviousXP, playersCurrentXP, CurrentPlayerLevel, TakingAwayXP) 700 | RankBarColor = 116 -- The Normal Online Ranbar color (IS NOT used for the globes!) 701 | if TakingAwayXP and XNL_UseRedBarWhenLosingXP then 702 | RankBarColor = 6 -- Dark Red 703 | end 704 | 705 | 706 | -- Although some sites note that the RankBar is hud ID 40, this does not work when we want to 707 | -- call it for drawing, we actually need to call id 19 (which is the WeaponWheel) 708 | --[[ 709 | I have also located AND CONFIRMED (instead of just assuming internet data!) the following other components: 710 | WANTED_STARS = 1 711 | WEAPON_ICON = 2 712 | CASH = 3 713 | MP_CASH = 4 714 | MP_MESSAGE = 5 715 | VEHICLE_NAME = 6 716 | AREA_NAME = 7 717 | VEHICLE_CLASS = 8 718 | STREET_NAME = 9 719 | HELP_TEXT = 10 720 | FLOATING_HELP_TEXT_1 = 11 721 | FLOATING_HELP_TEXT_2 = 12 722 | CASH_CHANGE = 13 723 | RETICLE = 14 724 | SUBTITLE_TEXT = 15 725 | RADIO_STATIONS = 16 726 | SAVING_GAME = 17 727 | GAME_STREAM = 18 728 | WEAPON_WHEEL = 19 <-- This sameone is also used to call the rankbar! 729 | WEAPON_WHEEL_STATS = 20 730 | HUD_COMPONENTS = 21 731 | HUD_WEAPONS = 22 732 | ]] 733 | if not HasHudScaleformLoaded(19) then -- Here we check if the scaleform has been loaded or not 734 | RequestHudScaleform(19) -- If it's not loaded we will request (load) it 735 | while not HasHudScaleformLoaded(19) do -- here we will wait until it has loaded 736 | Wait(1) -- you will HAVE to put this wait here to prevent script hang and game freezing! 737 | end 738 | end 739 | 740 | -- Currently i can't find any links to change the colors of the rank logo's (the globes on both sides) effectively 741 | -- i have tried setting component color id's with functions like ApplyHudColour, Colourise and other functions like that, 742 | -- (NOPE! those where NOT just 'guesses' but actual functions found in the data files regarding the HUD/Rankbar) 743 | -- tried addressing thm at HUD item 19, 40 (since some websites state that this is the rankbar ID, however! i could/can 744 | -- not find any logical evidence for this in hud.gfx! (or i might have overlooked it) 745 | -- 746 | -- Also tried using loading and preparing scale forms etc with for loops etc, but for now I will just leave it at what it is 747 | -- I'm eventually planning on using the "Rank Globe Color's" for prestige players in my server so I MIGHT come back to it and 748 | -- do more research but for now this rather 'unimportant feature' is holding back to much other development to keep researching. 749 | -- IF someone else finds or knows the solution them please don't hesitate to notify me so I can add it to my functionality and update 750 | -- this 'public release' script to :) 751 | -- 752 | -- But what i DID notice is that the rankbar somewhat has ID 140! This can be seen/found in: 753 | -- sprite652(_Packages.com.rockstargames.gtav.hud.NEW_HUD) 754 | -- 755 | -- HOWERVER: My appologies but I WILL NOT copy/publish these lines since I'm not taking any risks on publishing 756 | -- copyrighted lines/decompiled code ;) People whom would actually need this data are also well aware on how 757 | -- they can obtain or view that data ;) .... IF you don't know it, then you don't need that data either ;) 758 | 759 | -- This function sets the color of the rankBAR (NOT the globes) 760 | -- This function is called inside hud.gfx and only takes ONE parameter 761 | -- The globe color needs to be set differently 762 | BeginScaleformMovieMethodHudComponent(19, "SET_COLOUR") 763 | PushScaleformMovieFunctionParameterInt(RankBarColor) -- 116 is the "normal multiplayer rankbar color" 764 | EndScaleformMovieMethodReturn() 765 | 766 | 767 | --[[ 768 | PURE_WHITE = 0 769 | WHITE = 1 770 | BLACK = 2 771 | GREY = 3 772 | GREYLIGHT = 4 773 | GREYDARK = 5 774 | RED = 6 775 | REDLIGHT = 7 776 | REDDARK = 8 777 | BLUE = 9 778 | BLUELIGHT = 10 779 | BLUEDARK = 11 780 | YELLOW = 12 781 | YELLOWLIGHT = 13 782 | YELLOWDARK = 14 783 | ORANGE = 15 784 | ORANGELIGHT = 16 785 | ORANGEDARK = 17 786 | GREEN = 18 787 | GREENLIGHT = 19 788 | GREENDARK = 20 789 | PURPLE = 21 790 | PURPLELIGHT = 22 791 | PURPLEDARK = 23 792 | PINK = 24 793 | BRONZE = 107 794 | SILVER = 108 795 | GOLD = 109 796 | PLATINUM = 110 797 | FREEMODE = 116 -- This is the 'normal blue color' for the Rankbar 798 | ]] 799 | 800 | -- This function calls the function SET_RANK_SCORES inside HUD GFX (MP_RANK_BAR) 801 | -- and takes a maximum of 7 parameters which I have described bellow 802 | BeginScaleformMovieMethodHudComponent(19, "SET_RANK_SCORES") -- The HUD/Movie Component we want to use to draw the Rankbar 803 | PushScaleformMovieFunctionParameterInt(XP_StartLimit_RankBar) -- This sets the 'absolute begin limit' for the bar where it can start drawing from (includes the blue "you already had this XP" bar) 804 | PushScaleformMovieFunctionParameterInt(XP_EndLimit_RankBar) -- This sets the 'end limit' for the current level bar AND the 'top value' of the displayed XP text beneath the bar 805 | PushScaleformMovieFunctionParameterInt(playersPreviousXP) -- This sets where the previous XP 'was located' at the bar and thus from where to start drawing the 'white/new xp bar' 806 | PushScaleformMovieFunctionParameterInt(playersCurrentXP) -- This sets the current players XP (to 'where' the bar has to move!) 807 | PushScaleformMovieFunctionParameterInt(CurrentPlayerLevel) -- This one Determines the LEFT 'globe', so the CURRENT player's level! 808 | PushScaleformMovieFunctionParameterInt(100) -- This one sets the opacity (visibility %) from 0 (invisible) to 100 (fully visible) 809 | --PushScaleformMovieFunctionParameterInt(8) -- This CAN be used to set the 'end level' when making ONE bar to level up multiple levels 810 | -- This can then make it look like this for example (5)==========----------(8) 811 | -- when leveling up from level 5 to level 8 at once. BUT we CHOOSE to make it like i did now 812 | -- (making multiple bars fill), so IF you want to change it you can just adapt the code and 813 | -- set this 'extra' pushscale parameter :) 814 | EndScaleformMovieMethodReturn() -- "Ends" the current command/function handler 815 | end 816 | 817 | --=================================================================================== 818 | -- This is a 'small function' which is basically not needed (IF there are no errors 819 | -- made when using my script!) BUT i've put it in here anyway since I have added some 820 | -- 'extra error handling' to some functions to make it a bit easier and 'less crash 821 | -- prone' when new users/scripters try to use it or adapt it. 822 | --=================================================================================== 823 | function is_int(n) 824 | if type(n) == "number" then 825 | if math.floor(n) == n then 826 | return true 827 | end 828 | end 829 | return false 830 | end 831 | --------------------------------------------------------------------------------