A lightweight standalone groups system.
It allows you to check group memberships, retrieve group details, verify leadership, and dynamically update group data via server-side events.
Client Functions
in_group
Checks if the players is in the specified group.
Function
localfunctionin_group(group_name)for _, group inpairs(client_groups) dofor _, id inipairs(group.members) doif id ==GetPlayerServerId(PlayerId()) thenreturntrueendendendreturnfalseendexports('in_group', in_group)utils.groups.in_group = in_group
Example
--- Define group namelocal group_name ='racing-1'--- Utils objectlocal is_in_group = utils.groups.in_group(group_name)if is_in_group thenprint('Player is in the group.')elseprint('Player is not in the group.')end--- Direct exportexports.boii_utils:in_group(group_name)
get_player_groups
Gets all groups the player is a member of.
Function
localfunctionget_player_groups()local player_groups = {}for group_name, group_data inpairs(client_groups) dofor _, id inipairs(group_data.members) doif id ==GetPlayerServerId(PlayerId()) then player_groups[#player_groups +1] = group_nameendendendreturn player_groupsendexports('get_player_groups', get_player_groups)utils.groups.get_player_groups = get_player_groups
--- Specify group namelocal group_name ='racing-1'--- Utils objectlocal group_exists = utils.groups.group_exists(group_name)if group_exists thenprint('Group exists!')elseprint('Group does not exist.')end--- Direct exportexports.boii_utils:group_exists(group_name)
is_leader
Checks if the player is the leader of a specified group.
Function
localfunctionis_leader(group_name)local group = client_groups[group_name]if group and group.leader ==GetPlayerServerId(PlayerId()) thenreturntrueendreturnfalseendexports('is_leader', is_leader)utils.groups.is_leader = is_leader
Example
--- Specify group namelocal group_name ='racing-1'--- Utils objectlocal is_leader = utils.groups.is_leader(group_name)if is_leader thenprint('Is group leader!')elseprint('Is not group leader.')end--- Direct exportexports.boii_utils:is_leader(group_name)
is_member
Checks if player is a member of a specified group.
Function
localfunctionis_member(group_name)local group = client_groups[group_name]if group thenfor _, id inipairs(group.members) doif id ==GetPlayerServerId(PlayerId()) thenreturntrueendendendreturnfalseendexports('is_member', is_member)utils.groups.is_member = is_member
Example
--- Specify group namelocal group_name ='racing-1'--- Utils objectlocal is_member = utils.groups.is_member(group_name)if is_member thenprint('Is group leader!')elseprint('Is not group leader.')end--- Direct exportexports.boii_utils:is_member(group_name)
get_group_members
Gets all members of a specified group.
Function
localfunctionget_group_members(group_name)local group = client_groups[group_name]if group thenreturn group.membersendreturn {}endexports('get_group_members', get_group_members)utils.groups.get_group_members = get_group_members
Example
--- Specify group namelocal group_name ='racing-1'--- Utils objectlocal members = utils.groups.get_group_members(group_name)if members thenprint('Group members:', json.encode(members))elseprint('No members found.')end--- Direct exportexports.boii_utils:get_group_members(group_name)
get_group_members_by_id
Get all members of a group the player with specified ID is in.
Function
localfunctionget_group_members_by_id(player_id)for group_name, group_data inpairs(client_groups) dofor _, id inipairs(group_data.members) doif id == player_id thenreturn group_data.membersendendendreturn {}endexports('get_group_members_by_id', get_group_members_by_id)utils.groups.get_group_members_by_id = get_group_members_by_id
Example
--- Specify group namelocal player_id ='boii_123456'--- Utils objectlocal members = utils.groups.get_group_members_by_id(player_id)if members thenprint('Group members:', json.encode(members))elseprint('No members found.')end--- Direct exportexports.boii_utils:get_group_members_by_id(group_name)