Skip to content

CAU_xChat_fnc_role

Connor edited this page Nov 8, 2020 · 4 revisions

Arguments: Global Effect: Global

Definition:

Contains all code required for the role system to work.

Syntax:

  • Command: String - keyword used to call the command
    Supported Commands:
    • create
      Argument:
      0 : STRING - Name of the role
      1 : ARRAY or STRING - RGBA color array or hex code (Optional, default: mention color defined in settings)
      2 : ARRAY - Array of unit owner ids to add to the role on creation (Optional, default: [])
      Return: NUMBER - New role id, -1 if a role with that name already exists
    • delete
      Argument: NUMBER - Role ID
      Return: BOOL - true if role was successfully deleted
    • add
      Argument:
      0 : NUMBER - Role ID
      1 : NUMBER or ARRAY - Owner ID of unit(s) to add to role
      Return: BOOL - true if IDs were successfully added
    • remove
      Argument:
      0 : NUMBER - Role ID
      1 : NUMBER or ARRAY - Owner ID of unit(s) to remove from role
      Return: BOOL - true if IDs were successfully removed
    • getAllRoles
      Argument: NOTHING
      Return: ARRAY - All roles in role data format [role id,name,color,owner ids]
    • getRole
      Argument: NUMBER - Role ID
      Return: ARRAY - Role data format
    • getUnitRoles
      Argument: OBJECT - Unit to get roles of
      Return: ARRAY - All roles unit is part of in role data format
    • getOwnerIDRoles
      Argument: NUMBER - Owner ID to get roles of
      Return: ARRAY - All roles owner id is part of in role data format

Example 1:

["create",["My Role",[0,1,0,1],[clientOwner]]] call CAU_xChat_fnc_role;
// 0

Example 2:

["delete",0] call CAU_xChat_fnc_role;
// true/false

Example 3:

["add",[0,clientOwner]] call CAU_xChat_fnc_role;
["add",[0,[3,4,5]]] call CAU_xChat_fnc_role;
// true/false

Example 4:

["remove",[0,clientOwner]] call CAU_xChat_fnc_role;
["remove",[0,[3,4,5]]] call CAU_xChat_fnc_role;
// true/false

Example 5:

["getAllRoles"] call CAU_xChat_fnc_role;
// [[0,"My Role","#FF00FF00",[3]],...]

Example 6:

["getRole",0] call CAU_xChat_fnc_role;
// [0,"My Role","#FF00FF00",[3]]

Example 7:

["getUnitRoles",player] call CAU_xChat_fnc_role;
// [[0,"My Role","#FF00FF00",[3]],...]

Example 8:

["getOwnerIDRoles",clientOwner] call CAU_xChat_fnc_role;
// [[0,"My Role","#FF00FF00",[3]],...]