Comment on page
Scripting
Learn how to script with Abilities
With new abilities v2, we've added scripting support for effects. Variables are are reset with server restarts.
Create a custom variable globally, not per user. To create a variable that could be user for a user, you can include user's name in the variable's name, e.g.
customVar%attacker name%
Invert a custom variable's boolean. If no variable was set before, it will default to
false
Due to nature of these variables and naming, you can create global or per-player variables. To use them in effects and conditions, add a
%custom_
prefix and then name your variable. E.g. if we create a variable:
SET_VARIABLE:myVariable:awesome
We can use this variable in effects later like this:
MESSAGE:You are %custom_myVariable%
This would send a message to the player
You are awesome
.Creating per-player variables is still as simple and easy! Just include the player name variable inside the variable's name, e.g.:
SET_VARIABLE:customValue%attacker name%:50
Then later we can retrieve it in a message like this as well:
MESSAGE:I have %custom_customValue%attacker name%% dollars
This would message
I have 50 dollars
It works the same, but an example would be:
conditions:
- '%custom_customValue%attacker name%% = 50 %allow%'
If an attempt is made to retrieve a variable which doesn't exist, default value will be
0
In this example, we use RIGHT_CLICK trigger to count how many times user right clicks. If they click more than 5 times, they will not be able to activate the message again.
1
RIGHT_CLICK:
2
conditions:
3
- '%custom_nameof%attacker name%% = 5 : %stop%'
4
effects:
5
- 'SET_VARIABLE:clicks%attacker name%:<math>%custom_clicks%attacker name%%+1</math>'
6
- 'MESSAGE:You clicked %custom_clicks%attacker name%% times'
Last modified 5mo ago