libraries/thirdparty/sh_cami¶
Source: gamemode/framework/libraries/thirdparty/sh_cami.lua
defines the charactaristics of a usergroup
Documented functions: 13
Functions¶
CAMI.GetPrivilege(privilegeName)CAMI.GetPrivileges()CAMI.GetUsergroup(usergroupName)CAMI.GetUsergroups()CAMI.InheritanceRoot(usergroupName)CAMI.RegisterPrivilege(privilege)CAMI.RegisterUsergroup(usergroup, source)CAMI.SignalSteamIDUserGroupChanged(steamId, old, new, source)CAMI.SignalUserGroupChanged(client, old, new, source)CAMI.UnregisterPrivilege(privilegeName)CAMI.UnregisterUsergroup(usergroupName, source)CAMI.UsergroupInherits(usergroupName, potentialAncestor)CAMI_PRIVILEGE:HasAccess(actor, target)
CAMI.GetPrivilege(privilegeName)¶
Receives information about a privilege.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
privilegeName |
string |
- |
Returns
CAMI_PRIVILEGE: | nil
CAMI.GetPrivileges()¶
Retrieves all registered privileges.
Realm: shared
Returns
CAMI_PRIVILEGE[]: @All privileges indexed by their names.
CAMI.GetUsergroup(usergroupName)¶
Receives information about a usergroup.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
usergroupName |
string |
- |
Returns
CAMI_USERGROUP: | nil @Returns nil when the usergroup does not exist.
CAMI.GetUsergroups()¶
Retrieves all registered usergroups.
Realm: shared
Returns
CAMI_USERGROUP[]: @Usergroups indexed by their names.
CAMI.InheritanceRoot(usergroupName)¶
Find the base group a usergroup inherits from.
This function traverses down the inheritence chain, so for example if you have
user -> group1 -> group2
this function will return user if you pass it group2.
ℹ NOTE: All usergroups must eventually inherit either user, admin or superadmin.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
usergroupName |
string |
@The name of the usergroup |
Returns
"'user'": | "'admin'" | "'superadmin'" @The name of the root usergroup
CAMI.RegisterPrivilege(privilege)¶
Registers an addon privilege with CAMI.
⚠ Warning: This should only be used by addons. Admin mods must NOT register their privileges using this function.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
privilege |
CAMI_PRIVILEGE |
- |
Returns
CAMI_PRIVILEGE: @The privilege given as argument.
CAMI.RegisterUsergroup(usergroup, source)¶
Registers a usergroup with CAMI.
Use the source parameter to make sure CAMI.RegisterUsergroup function and the CAMI.OnUsergroupRegistered hook don't cause an infinite loop
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
usergroup |
CAMI_USERGROUP |
@The structure for the usergroup you want to register |
source |
any |
@Identifier for your own admin mod. Can be anything. |
Returns
CAMI_USERGROUP: @The usergroup given as an argument
CAMI.SignalSteamIDUserGroupChanged(steamId, old, new, source)¶
Signify that your admin mod has changed the usergroup of a disconnected player. This communicates to other admin mods what it thinks the usergroup of a player should be.
Listen to the hook to receive the usergroup changes of other admin mods.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
steamId |
string |
@The steam ID of the player for which the usergroup is changed |
old |
string |
@The previous usergroup of the player. |
new |
string |
@The new usergroup of the player. |
source |
any |
@Identifier for your own admin mod. Can be anything. |
CAMI.SignalUserGroupChanged(client, old, new, source)¶
Signify that your admin mod has changed the usergroup of a player. This function communicates to other admin mods what it thinks the usergroup of a player should be.
Listen to the hook to receive the usergroup changes of other admin mods.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
client |
GPlayer |
@The player for which the usergroup is changed |
old |
string |
@The previous usergroup of the player. |
new |
string |
@The new usergroup of the player. |
source |
any |
@Identifier for your own admin mod. Can be anything. |
CAMI.UnregisterPrivilege(privilegeName)¶
Unregisters a privilege from CAMI. This will call a hook that will notify any admin mods of the removal.
⚠ Warning: Call only when the privilege is to be permanently removed.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
privilegeName |
string |
@The name of the privilege. |
Returns
boolean: @Whether the unregistering succeeded.
CAMI.UnregisterUsergroup(usergroupName, source)¶
Unregisters a usergroup from CAMI. This will call a hook that will notify all other admin mods of the removal.
⚠ Warning: Call only when the usergroup is to be permanently removed.
Use the source parameter to make sure CAMI.UnregisterUsergroup function and the CAMI.OnUsergroupUnregistered hook don't cause an infinite loop
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
usergroupName |
string |
@The name of the usergroup. |
source |
any |
@Identifier for your own admin mod. Can be anything. |
Returns
boolean: @Whether the unregistering succeeded.
CAMI.UsergroupInherits(usergroupName, potentialAncestor)¶
Checks to see if potentialAncestor is an ancestor of usergroupName. All usergroups are ancestors of themselves.
Examples:
* user is an ancestor of admin and also superadmin
* admin is an ancestor of superadmin, but not user
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
usergroupName |
string |
@The usergroup to query |
potentialAncestor |
string |
@The ancestor to query |
Returns
boolean: @Whether usergroupName inherits potentialAncestor.
CAMI_PRIVILEGE:HasAccess(actor, target)¶
Optional function to check if a player has access to this privilege (and optionally execute it on another player)
⚠ Warning: This function may not be called by all admin mods
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
actor |
GPlayer |
@The player |
target |
GPlayer |
| nil @Optional - the target |
Returns
boolean: @If they can or notstring: | nil @Optional reason