ifdef::env-github[]
:tip-caption: :bulb:
:note-caption: :information_source:
:important-caption: :heavy_exclamation_mark:
:caution-caption: :fire:
:warning-caption: :warning:
endif::[]
:toc: left
:toclevels: 5

= Group

This module adds groups and permissions.

== Extension

=== User

[source,lua]
----
self.cdata.groups

-- return map of groups
User:getGroups()

User:hasGroup(name)

User:addGroup(name)

User:removeGroup(name)

-- get user group by type
-- return group name or nil
User:getGroupByType(gtype)

-- check if the user has a specific permission
User:hasPermission(perm)

-- check if the user has a specific list of permissions (all of them)
User:hasPermissions(perms)
----

=== Server

[source,lua]
----
self.cfg

-- return users list
Group:getUsersByGroup(name)

-- return users list
Group:getUsersByPermission(perm)

-- return title or nil
Group:getGroupTitle(group_name)

-- register a special permission function
-- name: name of the permission -> "!name.[...]"
-- callback(user, params) 
--- params: params (strings) of the permissions, ex "!name.param1.param2" -> ["name", "param1", "param2"]
--- should return true or false/nil
Group:registerPermissionFunction(name, callback)
----

.Events
[horizontal]
`playerJoinGroup(user, name, gtype)`:: called when a player joins a group
`playerLeaveGroup(user, name, gtype)`:: called when a player leaves a group

== Menu

=== group_selector

Group selector menu.

[horizontal]
.data
name:: selector name
groups:: selector table

== Permission

=== not

Negate another permission function.

`!not.<...>`

.Example
[horizontal]
`!not.group.admin`:: check if not an admin

=== group

Group check.

`!group.<name>`

[horizontal]
name:: group name

.Example
[horizontal]
`!group.admin`:: check if an admin
