-
Notifications
You must be signed in to change notification settings - Fork 5
API: Statistics
Statistics are used as a fun way to track what players did over the course of the gamemode. At the end of a game, these are displayed in a highscore table and experience points are awarded.
Statistics have a string key, such as 'Rounds Played', and a number of points associated with them.
Adds a conversion for a given statistics key to amount of XP. This should be called in the RegisterStatsConversions hook, eg:
hook.Add('RegisterStatsConversions', 'AddBombTagStatConversions', function()
GAMEMODE:AddStatConversion('Bomb Passes', 'Bomb Tagged', 0.5)
GAMEMODE:AddStatConversion('Explosions Survived', 'Explosions Survived', 0.25)
end)
By default the maximum amount of XP per category is 25XP. This can be adjusted if needed.
Get the winning player for a given statistic. This is the player with the highest number of points in the given statistic.
Generates an overall statistics table. The keys of this table are the statistic names.
Get the current number of points a given player has in the statistic.
Generate a table tracking all the player statistics. The keys of this table are the statistic names.
Adds a given number of points to a given players statistic.
v:AddStatPoints('Survived Rounds', 1)
v:AddStatPoints('Cubes Collected', 5)
Internal function for loading statistics. Should not be used in gamemodes.
Internal function for saving statistics. Should not be used in gamemodes.
Getting Started Pages:
| Server Hosting
| Mapping
| Lua Development
|