# Missions

The script only includes a dummy mission used for testing where you can see the code to learn how it works.

* Missions config is located in **server/editable/missions.lua** to prevent any player from dumping the files and see the info.
* Config.Missions is the table with all available missions, the one included is just a test mission that only triggers the server event **'av\_gangs:testmission'** and nothing else.

## Adding Missions

* Use the following export server side to add a new mission:

```lua
local mission = {
    name = "test_robbery", -- an unique identifier, keep it simple
    label = "Test Robbery", -- shown in app as mission title
    price = 2500, -- number or false
    difficulty = 1, -- from 0 to 5
    cops = 0, -- min cops online to start mission
    level = 0, -- min gang level required
    image = "https://r2.fivemanage.com/QmVAYSlqeAlD4IxVbdvu5/laundromat.png",
    description = "A short description for your heist",
    isClient = false, -- true it will trigger "event" client side, false will trigger it server side
    event = "av_gangs:testmission", -- server event to trigger or false to use onTrigger function
    autoStarted = true, -- set the mission status to "started" as soon as it's activated
    canStart = function(playerId, gang)
      -- run your own server check and return true to allow player to start mission
      -- this function runs before any removeMoney or cops check
      return true
    end,
    onTrigger = function(playerId, gang) -- This is triggered server side and only available if event = false
      -- You can use this to trigger an export or event
      -- EXAMPLE
      --[[
        exports['my_heist_script']:StartHeist(playerId)
      ]]--
    end,
}
exports['av_gangs']:registerMission(mission)
```

* The following event will make the mission available/unavailable for everyone:

```lua
-- mission:string = the mission identifier
-- started:boolean = true or false, true will make it available
TriggerEvent('av_gangs:updateMission', "test_robbery", true)
```

<figure><img src="/files/fZJqSXOlKoLXRHuJoB9x" alt=""><figcaption></figcaption></figure>

### Mission Crew

> You can enable this feature in `av_gangs/config/crew.lua > Config.UseCrew`
>
> There's a little panel where you can create a group (requires **av\_groups**), this panel only generates the group + handle invites, for a complete control of the group please check [Groups](/laptop-pack-v3/groups.md) page for a list of available exports you can use on your own resources.

* If using the **av\_gangs crew** make sure to always set **'av\_gangs'** as your resource in the **av\_groups exports**, example retrieving all crew members:

```lua
-- This will return a table with all crew members
local playerId = 1 -- player server id
local resourceName = 'av_gangs' -- resource name the group belongs to
local playerGroup = exports['av_groups']:getPlayerGroup(playerId, resourceName)
```


---

# Agent Instructions: 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:

```
GET https://docs.av-scripts.com/laptop-pack-v3/gangs/missions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
