Player statistics that are similar to GTAO?

Hi there everyone!

My friends and I are brand new to FiveM and even more so to running our own server. Our hope is to add a lot of the GTAO experience into the server. One thing we miss is the leveling of the stats. I’ve done quite a bit of searching and it seems according to this thread that an update to the game server allows for this mechanic.

I haven’t been able to find a resource that adds the GTAO style stats that increase as you shoot, headshot, swim underwater, run, etc. Maybe I am just missing it?

Does such a resource exist and if it doesn’t, how hard would it be to write something like this? The server we would be running this on is rented from Zap and has ES, ESX, MySQL Async installed.

Thanks for your time!

Wouldn’t be that hard to make. Here are the stats I use in vMenu.

// Manage other stats.
StatSetInt((uint)GetHashKey("MP0_STAMINA"), 100, true);
StatSetInt((uint)GetHashKey("MP0_STRENGTH"), 100, true);
StatSetInt((uint)GetHashKey("MP0_LUNG_CAPACITY"), 100, true);
StatSetInt((uint)GetHashKey("MP0_WHEELIE_ABILITY"), 100, true);
StatSetInt((uint)GetHashKey("MP0_FLYING_ABILITY"), 100, true);
StatSetInt((uint)GetHashKey("MP0_SHOOTING_ABILITY"), 100, true);
StatSetInt((uint)GetHashKey("MP0_STEALTH_ABILITY"), 100, true);

You’d just have to save stats for each player when they join/disconnect, and keep track of the stat changes.

Hi there Vespura and thanks very much for taking the time to help me out. I intend on trying my hand at making a resource for this(I can’t find anything similar) and not knowing a thing about creating one, I’m going to do it in baby steps.

I imagine that I also would have to update the database periodically during gameplay. For instance if someone were to get 15 headshots and 20 kills within a time period, it would be best if they were saved during gameplay so that progress wouldn’t be lost if the client disconnected unexpectedly.

To keep the overhead down, it might be best to tackle it in a manner that every 30 or 60 seconds, if the numbers stored have changed, update the database.

Does that sound like the way to tackle this? I don’t know how to do any of this yet but it will give me a direction in which to work.

Thanks for your time!

yes, even better: save a few changes on the client, and if there are either too many changes or some time has passed, send it to the server. Then the server will keep it saved in run-time, and only once every minute or so will it update the actual database to prevent a lot of database changes when a lot of players are online.

Hi there again Vespura,

I have been doing some searching hoping to learn how the system works. My intention is to convert the example [ESX]Boilerplate to write the addon.

First, I figured I should have the sql to base it off of. This is what I ended up with, thanks to your paste above:

CREATE TABLE `playerstats` ( `id` int(11) NOT NULL AUTO_INCREMENT, `owner` varchar(255) NOT NULL, `stamina` int(3) NOT NULL, `strength` int(3) NOT NULL, `lung_capacity` int(3) NOT NULL, `wheel_ability` int(3) NOT NULL, `flying_ability` int(3) NOT NULL, `shooting_ability` int(3) NOT NULL, `stealth_ability` int(3) NOT NULL, PRIMARY KEY (`id`) );

My intention is to bind the tables to the Steam ID.

I think my next step is to write the code that checks for the existence of a table relating to the user’s steamID and if it exists, load the data or creating a new table with the starter stat data if it doesn’t.

I’ve been browsing my server resource files to see if I can take something from them to kickstart this but I’m not smart enough to recognize the relevant code.

Can you(or anyone for that matter) help me in getting this part of the code started? I can post the boiler plate resource’s code if that’s something that can be built off of.

Thanks!

1 Like

I’d love to see the solution to this as well if you have time. Thanks

I’ve never used esx or vrp myself, so you’ll have to ask someone else for that.

I see but maybe I can ask you this. I was leaning toward esx because it looked like it was handling syncing and remembering character data well. Would it be as easy to do this without relying on that framework? I’ve seen a lot of your resources so I know it can be done but haven’t come across a resource that I could use to learn from or fork to modify. A lot of them use compiled eleme ts that I can’t work with.

Sorry if this is too broad but I appreciate your help thus far.

Hi, I know this is a while back, but was wondering if you ever managed to complete this? As I’m currently using esx and am starting on this road.

Hi there Teelia,

I’ve made almost no progress on it, unfortunately. I’m not good enough at lua yet to make it on my own and there was no assistance to be had in the channels I asked for help in.

I still plan on tackling it when I"m better prepared but that’s a ways down the road, I figure.

Sorry it’s not better news.

its all good. the thing is I do know that it has been implemented… ive played ina server that has this…so its driving me nuts hahaha

1 Like

but when using esx, i would put a column in user as playerstats.
not have a different table. just dont know how you would add the stats lol