# :gun: Airsoft
Documentation relating to the kd_airsoft.

:::: tabs

::: tab BUY
[Buy the script](https://jumpon-studios.com/fivem/airsoft-game)
:::

::: tab PREVIEW
<iframe width="560" height="315" src="https://www.youtube.com/embed/qNjlH7Z-9ek?si=dAgoUv36ZaZqiRts" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
:::
::::

## 1. Installation

AIRSOFT is a standalone script. So you don't need a specific framework to use it. It's also mean it works with all framework (Esx, QBCore, VRP, DRP, …).
- Drag and drop this 3 resources in your resources folder
  - kd_appmenu
  - kd_hud-event
  - kd_airsoft
- Add this 3 ensures in your server.cfg
  - `ensure kd_appmenu`
  - `ensure kd_hud-event`
  - `ensure kd_airsoft`
- Congratulation, the AIRSOFT script is ready to be use !

## 2. Usage

Airsoft script is very friendly. Just go in the maker visible on the map and create a new lobby to start game.

A few options are available to custom the lobby :
- Different maps
- Duration of the game in minute
- Number of player
- Number of life by player (team life = Number of player * Number of life/player)

When the lobby is created, other players can join it by finding it in the list of lobbies. Players can switch between teams A and B. If necessary, the lobby creator can change the game options after creating it.

The game will be over in once of this two conditions :
- One of team lost all those lives : Other team wins !
- The duration of the game is over : the team with the most of live wins !

## 3. Config.lua
The configuration file is `config.lua` in the resource root. **Do not edit this file directly** as your changes may be lost during updates. Instead, use `overwriteConfig.lua` to store your customizations.

- **`config.lua`** - Default configuration maintained by developers. **Do not modify this file.**
- **`overwriteConfig.lua`** - This is where you place only the values you want to override.

### How to customize the configuration

1. Open `kd_airsoft/overwriteConfig.lua`
2. Find the value you want to change in `config.lua` (e.g., `Config.language`)
3. Copy only that line into `overwriteConfig.lua`
4. Edit the copied value to your liking

The script loads `config.lua` first, then `overwriteConfig.lua` overwrites only the values you redefine. This ensures your customizations are preserved when updating the script.

`kd_airsoft/config.lua`

```lua
Locations = {
  vec3(452.675, -3072.087, 5.099),
  vec3(895.415, -2995.745, 4.90)
}

Maps = {
  {
    nom = "Hangar",
    Sortie = vec3(452.675, -3072.087, 5.099),
    PlayZone = {
      vec3(459.4, -3079.326, 6.070),
      vec3(459.620, -3066.508, 6.071),
      vec3(470.45, -3066.597, 6.070),
      vec3(470.631, -3116.16, 6.070),
      vec3(447.483, -3115.986, 6.070),
      vec3(446.931, -3078.583, 6.070),
    },
    EquipeA = {
      Casque = { id = 125, couleur = 6 },
      Gilet = { idH = 22, idF = 20, couleur = 2 },
      Veste = { idH = 34, idF = 3, couleurH = 0, couleurF = 1 },
      Haut = { idH = 15, idF = 4, couleurH = 0, couleurF = 0 },
      Pantalon = { idH = 130, idF = 30, couleurH = 1, couleurF = 0 },
      Chaussure = { idH = 24, idF = 25, couleurH = 0, couleurF = 0 },
      Main = { idH = 171, idF = 212, couleurH = 0, couleurF = 0 },
      Marker = { r = 100, g = 100, b = 255 },
      Spawn = { x = 464.645, y = -3069.921, z = 5.1, a = 208.241 },
    },
    EquipeB = {
      Casque = { id = 125, couleur = 4 },
      Gilet = { idH = 22, idF = 20, couleur = 0 },
      Veste = { idH = 34, idF = 3, couleurH = 0, couleurF = 1 },
      Haut = { idH = 15, idF = 4, couleurH = 0, couleurF = 0 },
      Pantalon = { idH = 130, idF = 30, couleurH = 1, couleurF = 0 },
      Chaussure = { idH = 24, idF = 25, couleurH = 0, couleurF = 0 },
      Main = { idH = 171, idF = 212, couleurH = 0, couleurF = 0 },
      Marker = { r = 0, g = 255, b = 0 },
      Spawn = { x = 450.338, y = -3110.851, z = 5.1, a = 185.616 },
    },
    WeaponChoisi = GetHashKey("WEAPON_ADVANCEDRIFLE")
  },
  {
    nom = "Aircraft carrier",
    Sortie = vec3(452.675, -3072.087, 5.099),
    PlayZone = {
      vec3(3039.842, -4487.968, 2.077),
      vec3(3142.873, -4812.613, 2.077),
      vec3(3058.991, -4849.718, 2.077),
      vec3(2959.916, -4514.913, 2.077)
    },
    EquipeA = {
      Casque = { id = 125, couleur = 6 },
      Gilet = { idH = 22, idF = 20, couleur = 2 },
      Veste = { idH = 34, idF = 3, couleurH = 0, couleurF = 1 },
      Haut = { idH = 15, idF = 4, couleurH = 0, couleurF = 0 },
      Pantalon = { idH = 130, idF = 30, couleurH = 1, couleurF = 0 },
      Chaussure = { idH = 24, idF = 25, couleurH = 0, couleurF = 0 },
      Main = { idH = 171, idF = 212, couleurH = 0, couleurF = 0 },
      Marker = { r = 100, g = 100, b = 255 },
      Spawn = { x = 3076.443, y = -4647.22, z = 5.076, a = 136.154 },
    },
    EquipeB = {
      Casque = { id = 125, couleur = 4 },
      Gilet = { idH = 22, idF = 20, couleur = 0 },
      Veste = { idH = 34, idF = 3, couleurH = 0, couleurF = 1 },
      Haut = { idH = 15, idF = 4, couleurH = 0, couleurF = 0 },
      Pantalon = { idH = 130, idF = 30, couleurH = 1, couleurF = 0 },
      Chaussure = { idH = 24, idF = 25, couleurH = 0, couleurF = 0 },
      Main = { idH = 171, idF = 212, couleurH = 0, couleurF = 0 },
      Marker = { r = 0, g = 255, b = 0 },
      Spawn = { x = 3100.021, y = -4802.58, z = 1.036, a = 11.352 },
    },
    WeaponChoisi = GetHashKey("WEAPON_ADVANCEDRIFLE")
  }
}

-------------
-- SERVER SIDE
-------------
if IsDuplicityVersion() then
  --Fired when the player select "Start the game"
  ---@param source integer player ID
  ---@param party table setup of the party
  ---@param party.joueurs table list of players in the lobby
  function CanStartParty(source, party)
    --return false to cancel the starting of the game
    return true
  end

  --Fired when the player press 'E' to open the menu
  ---@param source integer player ID
  function CanOpenMenu(source)
    -- TriggerClientEvent("hud:NotifColor", source, "You can't open the menu", 6)
    return true
  end
end
```

`kd_airsoft/lang.lua`

```lua
Lang = {}

Lang['blipName'] = "Airsoft"
Lang['start'] = "Game started";
Lang['hit'] = "~r~You have been touched"
Lang['back_base'] = "Go back to the base"
Lang['exit_zone'] = "~r~Out of zone"
Lang['elimated'] = "~r~You have been eliminated"
Lang['win'] = "~g~You win !"
Lang['lost'] = "~r~You lost"
Lang['life'] = "Remaining Lives"
Lang['time'] = "Remaining time"
Lang['kick'] = "You have been kicked from the lobby"
Lang['kick2'] = "Player kicked"
Lang['menu_resume'] = "~g~Resume the current game"
Lang['menu_start'] = "Start a game"
Lang['menu_join'] = "Join a game"
Lang['menu_join2'] = "Join"
Lang['menu_setup'] = "Game settings"
Lang['menu_zone'] = "Area"
Lang['menu_duration'] = "Duration"
Lang['menu_minutes'] = "minutes"
Lang['menu_maxplayer'] = "Number of player"
Lang['menu_life'] = "Number of life/player"
Lang['menu_validate'] = "~g~Create the game"
Lang['menu_validate2'] = "~g~Validate changes"
Lang['menu_cancel'] = "Cancel"
Lang['menu_progress'] = "Creation in progress"
Lang['menu_error'] = "Error during the creation"
Lang['menu_already_start'] = "Game in progress"
Lang['menu_lobby_number'] = "Lobby n°%s"
Lang['menu_teams'] = "Teams"
Lang['menu_team'] = "Team"
Lang['menu_EquipeA'] = "Team A"
Lang['menu_EquipeB'] = "Team B"
Lang['menu_kick'] = "Kick"
Lang['menu_refrash'] = "Refresh"
Lang['menu_move'] = "Switch team"
Lang['menu_start'] = "Start the game"
Lang['menu_delete'] = "Delete the lobby"
Lang['menu_deleted'] = "Lobby deleted"
Lang['menu_left'] = "Left the lobby"
Lang['menu_list'] = "List of Open lobby"
Lang['menu_full'] = "Full"
Lang['menu_full2'] = "Lobby Full !"
Lang['menu_list0'] = "No game in progress"
Lang['menu_back'] = "Back"
Lang['menu_already_in'] = "You are already in the lobby n°%s"
Lang['press_display'] = "Press ~INPUT_CONTEXT~ to play at Airsoft"
Lang['menu_'] = ""
```

## 4. Add a new map
You can add as many maps as you want. Copy a default map and edit the configuration.
Example :
```lua
{
      nom = "Quarry",
      Sortie = vec3(1452.675,-122.087,15.099),
      PlayZone = {
          vec3(1240.,-1819.,30.),
          vec3(1240.,-4502.,50.),
          vec3(1911.,-4502.,30.),
          vec3(1911.,-1819.,30.)
      EquipeA = {
          Casque = {id = 125,couleur = 6},
          Gilet = {idH = 22,idF=20,couleur = 2},
          Veste = {idH = 34,idF=3,couleurH = 0, couleurF = 1 }, 
          Haut = {idH = 15,idF=4,couleurH = 0, couleurF = 0 }, 
          Pantalon = {idH = 130,idF=30,couleurH = 1, couleurF = 0}, 
          Chaussure = {idH = 24,idF=25,couleurH = 0, couleurF = 0}, 
          Main = {idH = 171,idF=212,couleurH = 0, couleurF = 0},   
          Marker = {r=100,g=100,b=255},
          Spawn = { x = 3076.443, y = -4647.22, z = 5.076, a= 136.154},
      },
      EquipeB = {
          Casque = {id = 125,couleur = 4},
          Gilet = {idH = 22,idF=20,couleur = 0},
          Veste = {idH = 34,idF=3,couleurH = 0, couleurF = 1 }, 
          Haut = {idH = 15,idF=4,couleurH = 0, couleurF = 0 }, 
          Pantalon = {idH = 130,idF=30,couleurH = 1, couleurF = 0}, 
          Chaussure = {idH = 24,idF=25,couleurH = 0, couleurF = 0}, 
          Main = {idH = 171,idF=212,couleurH = 0, couleurF = 0},  
          Marker = {r=0,g=255,b=0},
          Spawn = {x = 3100.021, y = -4802.58, z = 1.036, a= 11.352},
      },
      WeaponChoisi = GetHashKey("WEAPON_ADVANCEDRIFLE")
  }
```
