Exports
createGroup(...)
Create a new group and assign the player as owner.
parameters:
playerId
number
: The player id server from the person who's creating it and will be designed as owner.resource
string
: The resource name that is triggering the export, if not provided it will return false and cancel the process.maxMembers?
number
: The max members allowed for the group, default is 10.name?
string
: The group name, if not defined it will use the group identifier as name.password?
string
: The group password in case you want to make it private, optional.status?
string
: The current group status, "N/A" if not provided.ownerName?
string
: The owner nickname used for the group, if not provided it will use his character name or "User-" with a random number.returns:
identifier false | string: If there's any problem while group creation it will return false, if the group was created it will return the group identifier as string.
local playerId = source local resource = "av_boosting" local maxMembers = 5 local name = "AV Scripts" local password = false local status = "Waiting" local ownerName = "Avilchiis" local identifier = exports['av_groups']:createGroup(playerId, resource, name, password, status, ownerName) if identifier then print("Group created, identifier:"..identifier) else print("Something went wrong, group couldn't be created") end
getGroups(resource)
Get all the groups from an existing resource.
parameters:
resource
string
: Resource name you want to get a list of groups.returns:
groups
table
local boostingGroups = exports['av_groups']:getGroups("av_boosting") print(json.encode(boostingGroups, {indent = true})) -- it will print an empty table if there's no groups or something like this: --[[ boostingGroups = { ["group_identifier"] = { maxMembers: number, identifier: string, owner: string, label: string, password: string or false, status: string, members: { { name: string, identifier: string, playerId: string }, } }, } ]]--
joinGroup(...)
parameters:
playerId
number
: The server id from the player who's joining the group.resource
string
: Resource name where the group belongs.group
string
: Group identifier.password?
string
: User password input, will be compared to group password.nickname?
string
: The name used for player in the group.returns:
result
boolean
: Returns true if player was able to join the group or false.local playerId = source local resource = "av_boosting" local group = "group_identifier" local password = "123" local nickName = "Avilchiis" local joined = exports['av_groups']:joinGroup(playerId, resoource, group, password, nickName) if joined then print("Player joined the boosting group") else print("Something went wrong...") end
leaveGroup(playerId, resource, group)
parameters:
playerId
number
: The server id from the player who's leaving the group.resource
string
: The resource name where the group belongs.group
string
: The group identifier.returns:
result
boolean
: Returns true if player was removed from any group or false.local playerId = source local resource = "av_boosting" local group = "group_identifier" local res = exports['av_groups']:leaveGroup(playerId, resource, group) if res then print("Player was removed from group") else print("Something went wrong...") end
getPlayerGroup(playerId, resource)
Returns a table with the current group info.
parameters:
playerId
number
: The server id from player.resource
string
: The resource name where the group belongs to.returns:
result
boolean | table:
If a group is found it will return a table with all group info, if not then it will return false.local playerId = source local resource = "av_boosting" local group = exports['av_groups']:getPlayerGroup(playerId, resource) if group then print(json.encode(group, {indent = true})) --[[ this will print something like this: { identifier: string, maxMembers: number, owner: string, label: string, password: string or false, status: string, members: { { name: string, identifier: string, playerId: number, }, } } ]]-- else print("Player isn't part of any group") end
removeMember(resource, identifier, group)
Removes the player from a group.
parameters:
resource
string
: The resource name the group belongs to.identifier
string
: The player identifiergroup
string
: The group identifierreturns:
removed
boolean
local resource = "av_boosting" local identifier = exports['av_laptop']:getIdentifier(source) local group = "group_identifier" local removed = exports['av_group']:removeMember(resource, identifier, group) if removed then print("Player removed from group") else print("Something went wrong...") end
deleteGroup(resource, group)
parameters:
resource
string
: The resource name the group belongs to.group
string
: The group identifier.returns:
deleted
boolean
local resource = "av_boosting" local group = "group_identifier" local deleted = exports['av_groups']:deleteGroup(resource, group) print(deleted)
setGroupState(resource,group,status)
Sets the current status for the group, this is just in case you want to display a status in your own UI like "Waiting", "In progres", etc.
parameters:
resource
string
: The resource name the group belongs to.group
string
: The group identifier.status
string
: The status to display.returns:
updated
boolean
local resource = "av_boosting" local group = "group_identifier" local status = "Working" local updated = exports['av_groups']:setGroupState(resource, group, status) if updated then print("Group status got updated") else print("Something went wrong") end
Last updated