-
Notifications
You must be signed in to change notification settings - Fork 0
Users
For most operations that use users in Skript-LuckPerms, we need a user. We get this via the load player effect:
function example(p: offlineplayer):
get luckperms user {_p} and store it in {_lp}
(The effect supports online & offline players). This will load the user into {_lp} which allows for modification of the user later on.
Getting/setting a prefix/suffix of a user is quite simple (ish).
First we need a builder. We do this via
set {_m} to a new prefix builder:
value: "<red>VIP"
priority: 5
duration: 7 days
This sets {_m} to a prefix builder with value "VIP" priority 5 and expires in 7 days. To apply it to a player, we simply:
add {_m} to prefixes of {_lp}
Now the user's prefix will be "VIP" for 7 days unless they have a prefix that has higher priority. So simple!
Getting is much easier, all we need to do is:
set {_prefix} to formatted luckperms prefix of {_lp}
set {_prefixes::*} to luckperms prefixes of {_lp}
{_prefix} = the user's primary prefix (one with highest priority). {_prefixes::*} = all of the user's prefixes. If you want to get source/priority of either of these use the chat meta source/chat meta priority expression.
To get/set suffixes of a user just follow this guide but replace prefix with suffix
Now, I won't explain every user event as there is a lot but here is a few:
Basic event called when a user gets a permission.
on user receive permission:
send "You just got the permission %event-permission% for %event-duration%" to player
(Note that for events that have %event-duration% duration will be 0 seconds if the group is set to be FOREVER (never expire)).
Basically same as above but called when a user loses a permission.
on user lose permission:
send "You just lost %event-permission%!" to player
Called when a user gets a group.
on user receive group:
send "You just received %event-group% for %event-duration%!" to player
Explains itself at this point.
on user lose group:
send "You just lost %event-group% ;c" to player
And yeah, that sums up some basic events. You may have some questions like: Why are events player based and not user based? This is to prevent needless loading. Although async its still performance wasted to load a possibly un cached player & you'd have to deal with converting a user to a player for certain things like eg sending a message.