#Managing player groups

Player groups are a way to organize players into groups, and then assign permissions to those groups. This way, you can easily manage permissions for multiple players at once.

#Attaching player to a group Async

To attach a player to a group, you can use the useAccount, useCharacter and useVirtual functions. All of them have a groups property that you can use to attach a player to a group.

import { useRebar } from '@Server/index.js'; const Rebar = useRebar(); async function makeAdmin(player: alt.Player) { const character = Rebar.document.character.useCharacter(player); await character.groups.add('admin'); }
1
2
3
4
5
6
7
8

#Removing player from a group Async

To remove a player from a group, you can use the useAccount, useCharacter and useVirtual functions. All of them have a groups property that you can use to remove a player from a group.

import { useRebar } from '@Server/index.js'; const Rebar = useRebar(); async function removeAdmin(player: alt.Player) { const character = Rebar.document.character.useCharacter(player); await character.groups.remove('admin'); }
1
2
3
4
5
6
7
8

#Clearing all groups Async

To clear all groups from a player, you can use the useAccount, useCharacter and useVirtual functions. All of them have a groups property that you can use to clear all groups from a player.

import { useRebar } from '@Server/index.js'; const Rebar = useRebar(); async function clearGroups(player: alt.Player) { const character = Rebar.document.character.useCharacter(player); await character.groups.clear(); }
1
2
3
4
5
6
7
8

#Getting a list of groups

To get a list of groups that a player is in, you can use the useAccount, useCharacter and useVirtual functions. All of them have a groups property that you can use to get a list of groups.

import { useRebar } from '@Server/index.js'; const Rebar = useRebar(); function getGroups(player: alt.Player) { const character = Rebar.document.character.useCharacter(player); return character.groups.get(); }
1
2
3
4
5
6
7
8

#Check group membership

To check if a player is a member of a group, you can use the useAccount, useCharacter and useVirtual functions. All of them have a groups property that you can use to check if a player is a member of a group.

import { useRebar } from '@Server/index.js'; const Rebar = useRebar(); function isMemberOfAdminGroup(player: alt.Player) { const character = Rebar.document.character.useCharacter(player); return character.groups.memberOf('admin'); }
1
2
3
4
5
6
7
8