> For the complete documentation index, see [llms.txt](https://docs.av-scripts.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.av-scripts.com/laptop-pack-v3/groups/exports.md).

# Exports

{% hint style="info" %}
All the exports listed here are **server side** and should be triggered from your **own resource**, this will NOT work if av\_laptop is not installed and running in your server.
{% endhint %}

## 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.
>
> ```lua
> 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, maxMembers, 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`
>
> ```lua
> 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.
>
> ```lua
> local playerId = source
> local resource = "av_boosting"
> local group = "group_identifier"
> local password = "123"
> local nickName = "Avilchiis"
> local joined = exports['av_groups']:joinGroup(playerId, resource, 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.
>
> ```lua
> 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.
>
> ```lua
> 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 identifier
> * **group** `string`: The group identifier
>
> **returns:**
>
> * **removed** `boolean`
>
> ```lua
> local resource = "av_boosting"
> local identifier = exports['av_laptop']:getIdentifier(source)
> local group = "group_identifier"
> local removed = exports['av_groups']: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`
>
> ```lua
> 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`
>
> ```lua
> 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
> ```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.av-scripts.com/laptop-pack-v3/groups/exports.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
