Stats tracking - Does it take up much resource wise?

As the title says, how intensive would it be to create lua based stats tracking; storing things such as kills, deaths, wins, losses and quite a bit of other data on players.

Also, what would be the best way to go about storing the data? I’m not that great at lua but I’d like to improve in the area of storing/retrieving data, so any tips on that would be great.

It wouldnt be very intensive at all. You could simply store your information in a file from a table using util.TableToKeyValues() and file.Write()

The best way to store it would be using one of the MySQL modules and a database, second best would be SQLLite, and third you could use glon.encode to save to a file and glon.decode to load. Don’t bother using util.TableToKeyValues.

What do you need this for?

Thanks for the replies - I just want to practice making a basic stats tracking system in lua.

Any tips on where I should start with MySQL i.e. reading and writing?

EDIT* Taking a look at the wiki tutorials now.


Loures - I just want to make a basic system for tracking player stats and possibly some leaderboards, its as much for learning as it is for actual use.

If you were saving stats for every player in the server in a round based game, would it be a better idea to wait until the end of the round before updating and saving all of the values, or would it not cause any visible performance hit at all?

Usually I save depending on a few things:

When they disconnect.
When something that doesn’t get updated often is updated (Inventory?)

And then save other things on a timer of 60-120 seconds, like kills or money.

It also depends how much data is being saved.

Well I’d say quite a few different bits of data.

I gave a little bit of thought to some of the stuff I’d like to store, probably around 15 or so values, most are to do with kills/deaths. There are plenty more things I could think of which I’d like to store as well, but I want to expand on it when its working.

I think the most appropriate time to save them would be at the end of each round or during the warmup time of the next round. Since the rounds are short (5-10 mins), and the max amount of kills any one player can get is going to be around 9 (Which will be rare), I think it would be reasonable just to save at the end since very little would be lost if the player gets disconnected.

Saving at round ends would also be less work for me, since the gamemode already stores alot of the data I need which I can just add onto the totals, rather than having to gather all of the data myself.

Well, you could always save at the end AND when the player disconnects. :slight_smile:

Or even check if there’s a round going on when they leave and then save if there is.

Another thing, what would be the best way to handle the kills and stuff myself? Adding a hook for PlayerDeath then doing my checks and adding one onto the networked kills variable for the attacker?

Also then at round end creating a for loop with all the players and go through saving them?

Yea basically, I would use DTInts though.

For what reason? And would I just use them in the same way I’d use NWInt?

They’re more optimized! :smiley: