Due to overwhelming requests (ahum) I decided to release this script.
_stattracking goes in your mod (serverside is preferred) and
ranks_config.txt goes in the scriptdata folder of your fs_game/main folder, serverside only.
Functions you can call within this file:
-init(); CALL THIS FUNCTION ONLY AT THE START OF THE GAME
How to use:
Call [player] addstat(stat,amount) with a statistic and an amount to add to that statistic
Example: self addstat("deaths",1);
Example: attacker addstat("kills",1);
After you added all the stats you wanted to write, call [player] updatestats();
Example: self updatestats();
Example: attacker updatestats();
You can also get a stat from a player, and, to avoid errors, you most likely will use the function i created for this: getstat(stat)
Example: if(self getstat("rank")>30)
Example: if(attacker getstat("xp")>1000)
Do not manually assign values to the self.stats array!
Example of what NOT TO DO: self.stats["kills"]=30;
Example of what NOT TO DO: attacker.stats["deaths"]++;
To add more stats to track: simply add them to the level.stats array in init_stattracking(). Then, write your own script to increase them at given moments :)
[advice] To update huds based on stats that are added, piggyback on the addstat() function. Add a case in the addstat() function, and call whatever you use to update your hud from there.
[advice] To substract certain things from a statfile, just call addstat([stat], [amount]) with a negative amount. Example: self addstat("xp",-1000);
[advice] Due to some shortcuts in the scripting, piggybacking on the addstat to update huds based on rank-changes does not work. Piggyback on the promoted() function to update your rank-dependent huds accordingly.
You can use, modify, distribute the contents of this file.
You cannot sell the contents or the modified contents of this file.
If the file is modified, you MUST publish it if someone asks for it.
You cannot ask money for this file
If this file was sold to you, you were tricked and should get a refund!
If you do not agree with above terms, DO NOT USE THIS FILE!
I took great care of this coding, so if anything breaks, or causes damage (ie. data loss) I will NOT be responsible
If you dont know how to use .gsc files, then you dont know how to call the addstat() stuff, which means you cannot use it in any useful way anyway.