🧢XTASK.trigger
The actual code that will be ran to track the achievement.
Will be deprecated in the future. Replaced with:
XTASK.onShared
XTASK.onClient
XTASK.onServer
▸ Data Type
function
▸ Description
The trigger is a vital part to an achievement. It is the code that will be ran and determines what is tracked for a specific achievement.
To make your own, you must know Lua.
Triggers look like the following:
Typically the trigger function will be used in combination with Garry's Mod hooks built into the game to track certain things.
As an example, to track when a player spawns on the map; you can use the following:
The above code triggers when a player spawns onto the map. It counts how many players are currently on the server and determines if you should earn the achievement if enough players are connected.
This should be ran on player spawn because the number of players on a server changes constantly, and you do not want the server always running the check due to it being taxing on performance. So we use a player's spawning as a time to check to see if they meet the requirements.
The trigger function provided above goes to the achievement Who Keeps Giving Birth?
On a previous page, we explained what XTASK.maxreq does; which is determine how many times an action must take place before the player earns the achievement. In the above code, we only need it to occur once.
However, there's an addtitional requirement specified by XTASK.param_extra which tells the code above that there must be 60 players on the server in order to obtain the achievement.
Last updated