> ## Documentation Index
> Fetch the complete documentation index at: https://docs.resrant-scripts.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> Unlock the full potential of the FFA script by fine-tuning its options in `config.lua`.

import {
  AccordionGroup,
  Accordion,
  Tip,
  Info,
  Callout,
} from "nextra-theme-docs";

# Mastering Your FFA Script: Configuration Guide

The FFA Script offers extensive customization options via its configuration files, primarily `config.lua` and `discord.lua`. This guide will walk you through each section to help you tailor the script perfectly to your server's needs.

<Callout type="warning">
  Always create a backup of your configuration files before making significant
  changes to avoid losing your settings.
</Callout>

## Framework Integration

These settings control how the FFA script integrates with your server's framework (ESX or QBCore).

<AccordionGroup>
  <Accordion title="Framework Selection">
    ### Basic Framework Setup

    Choose between ESX and QBCore frameworks:

    ```lua theme={null}
    -- Framework Selection
    Config.FrameWork = "ESX"  -- Options: "ESX" or "QBCORE"
    Config.GiveWeaponsServerSideFrameWork = "esx"  -- Options: "esx" or "qbcore"

    -- Only required if using a custom ESX prefix
    Config.CustomESXPrefixEvents = "esx"
    ```

    ### Framework Initialization Functions

    ```lua theme={null}
    -- Server-side initialization
    Config.InitServer = function()
        if Config.FrameWork == "ESX" then
            ESX = nil
            ESX = exports["es_extended"]:getSharedObject()
        else
            QBCore = exports["qb-core"]:GetCoreObject()
        end
    end

    -- Client-side initialization
    Config.InitClient = function() 
        if Config.FrameWork == "ESX" then
            ESX = nil
            ESX = exports["es_extended"]:getSharedObject()
        else
            QBCore = exports["qb-core"]:GetCoreObject()
        end
    end
    ```

    <Tip>
      If you're using an older version of ESX that uses events instead of exports, modify the initialization functions to use `TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)` instead.
    </Tip>
  </Accordion>

  <Accordion title="Custom Inventory Integration">
    ### Inventory System Options

    Configure how weapons are given and handled with your inventory system:

    ```lua theme={null}
    -- For ESX with QS Inventory
    Config.QSInventory = false

    -- Controls whether weapons are given server-side or client-side
    Config.GiveWeaponsServerSide = true

    -- Weapon giving function for server-side
    Config.GiveWeaponServerSideEvent = function(source, weapon, ammo)
        if Config.GiveWeaponsServerSideFrameWork == "esx" then
            local xPlayer = ESX.GetPlayerFromId(source)
            xPlayer.addWeapon(weapon, ammo)
            
            -- For QS Inventory, you might use:
            -- xPlayer.addInventoryItem(weapon, 1)
        else
            -- QBCore inventory method
            local Player = QBCore.Functions.GetPlayer(source)
            local info = {ammo = ammo}
            Player.Functions.AddItem(weapon, 1, false, info)
        end
    end
    ```

    <Info>
      Different inventory systems require different approaches for handling weapons. If you're using a custom inventory system, you may need to modify these functions to match your system's requirements.
    </Info>

    ### Inventory Clearing Functions

    ```lua theme={null}
    Config.ClearInventoryFunction = function()
        if Config.FrameWork == "ESX" then
            if Config.QSInventory then
                TriggerServerEvent('ffa:clearQSInventory')
            else
                RemoveAllPedWeapons(PlayerPedId())
            end
        else
            SetCurrentPedWeapon(PlayerPedId(), GetHashKey("WEAPON_UNARMED"), true)
            TriggerServerEvent('ffa:clearQBInventory2')
        end
    end
    ```
  </Accordion>
</AccordionGroup>

## General Settings

Configure the core functionality and behavior of the FFA script.

<AccordionGroup>
  <Accordion title="Basic Configuration">
    ### Server and Debug Settings

    ```lua theme={null}
    Config.Debug = true  -- Enable for additional debugging information
    Config.AdvancedDebug = true  -- Enable for more detailed debugging

    Config.ServerName = "Your Server"  -- Your server name displayed in various messages
    Config.SavePlayerTime = 60000  -- How often player data is saved (in milliseconds)

    Config.OpenMenuKey = 38  -- Key code for opening the FFA menu (38 = E)
    Config.OpenTimeout = 100  -- Cooldown between menu opens (in milliseconds)
    ```

    ### Money and Economy Settings

    ```lua theme={null}
    -- Money handling options
    Config.GiveMoneyOnKillToBank = false  -- If true, kill rewards go to bank instead of cash
    Config.RemoveMoneyFromBankOnJoin = false  -- If true, join fee is taken from bank instead of cash
    ```

    <Tip>
      Find key codes for `Config.OpenMenuKey` in the [FiveM documentation](https://docs.fivem.net/docs/game-references/controls/).
    </Tip>
  </Accordion>

  <Accordion title="Player Experience Settings">
    ### Respawn Configuration

    ```lua theme={null}
    -- Respawn screen settings
    Config.RespawnScreen = true  -- Show respawn countdown screen
    Config.RespawnCountdown = 4  -- Respawn countdown in seconds
    Config.RespawnInstant = false  -- Instantly respawn without countdown
    Config.SameRespawnCoords = false  -- Prevent respawning at the same coordinates twice

    -- Out of zone settings
    Config.OutZoneScreen = true  -- Show out-of-zone countdown screen
    Config.OutZoneCountdown = 5  -- Out-of-zone countdown in seconds
    Config.OutZoneRespawnInstant = false  -- Instantly respawn when out of zone

    -- In-game HUD settings
    Config.IngameHud = true  -- Show the in-game HUD for FFA
    ```

    ### Combat Settings

    ```lua theme={null}
    -- Anti-combat logging
    Config.AntiCombat = true  -- Enable anti-combat logging protection
    Config.AntiCombatTimeout = 3000  -- Combat status duration in milliseconds
    ```

    ### Default Player Options

    ```lua theme={null}
    Config.DefaultPlayerOptions = {
        notifications = true,  -- Show notifications
        anonym = false,  -- Anonymous mode
        hud = true,  -- Show HUD
        fullplaytime = true,  -- Track full playtime
        crosshair = false,  -- Show crosshair
        hitmarker = false  -- Show hitmarker
    }

    Config.AlwaysShowCrosshair = true  -- If true, crosshair is always shown when enabled
    Config.LeaderboardMaxPlayers = 99  -- Maximum players shown on leaderboard
    ```
  </Accordion>

  <Accordion title="Weapon Configuration">
    ### Weapon Settings

    ```lua theme={null}
    -- Weapon ammo settings
    Config.WeaponAmmo = 5000  -- Amount of ammo given when spawning
    Config.LeaveAmmo = 200  -- Amount of ammo given when leaving FFA

    -- Give weapon once on spawn or every respawn
    Config.GiveWeapon1TimeOnSpawn = true
    ```

    <Info>
      Weapon settings control how and when players receive weapons in FFA zones, along with ammo quantities. Adjust these based on your server's gameplay style.
    </Info>
  </Accordion>
</AccordionGroup>

## Gameplay Features

Configure special gameplay features like killstreaks, hitmarkers, and special event handlers.

<AccordionGroup>
  <Accordion title="Killstreaks & Rewards">
    ### Killstreak Configuration

    ```lua theme={null}
    -- Killstreak thresholds that trigger notifications
    Config.KillStreak = {
        3, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60,
    }

    -- Custom notification function for killstreaks
    Config.KillStreakNotification = function(streak)
        TriggerEvent("esx:showNotification", "KILLSTREAK: " .. streak)
        
        -- Example of giving reward for specific streaks
        if streak == 12 then
            GiveWeaponToPed(PlayerPedId(), GetHashKey("WEAPON_ASSAULTRIFLE"))
        end
    end
    ```

    <Tip>
      You can customize killstreak rewards to offer special weapons, armor, or other bonuses at specific streak milestones.
    </Tip>
  </Accordion>

  <Accordion title="Visual Feedback">
    ### Hitmarker & Notification Settings

    ```lua theme={null}
    -- Hitmarker configuration
    Config.HitMarkerColor = {120, 0, 0}  -- RGB color for hitmarkers

    -- Custom hitmarker sound (if desired)
    Config.OnHitmarker = function()
      -- Requires InteractSound resource
      -- TriggerEvent("InteractSound_CL:PlayOnOne", "hitmarker", 1)
    end

    -- Standard notification function
    Config.Notification = function(text)
      TriggerEvent("esx:showNotification", text)
    end

    -- Help bar notification
    Config.showInfoBar = function(text)
      SetTextComponentFormat("STRING")
      AddTextComponentString(text)
      DisplayHelpTextFromStringLabel(0, 0, 1, -1)
    end
    ```
  </Accordion>
</AccordionGroup>

## Map Locations & Zones

Configure FFA markers on the map and define combat zones with their properties.

<AccordionGroup>
  <Accordion title="FFA Markers">
    ### Map Marker Configuration

    FFA markers are the points where players interact to enter FFA zones:

    ```lua theme={null}
    Config.FFAMarker = {
        FFA1 = {
            ShowMarker = true,  -- Show the 3D marker in the world
            ShowBlip = true,    -- Show on the minimap/map

            UseJob = false,     -- Restrict to specific job
            Jobname = "police", -- Job name if UseJob = true

            -- Marker appearance and location
            Marker = {
                Coords = vector3(-420.356, 1142.452, 324.8536),  -- Location
                DrawDistance = 20.0,   -- Distance at which marker becomes visible
                Scale = vector3(1.5, 1.5, 1.0),  -- Size
                Colour = {r = 102, g = 102, b = 204},  -- Color
                Alpha = 100,     -- Transparency
                Type = 1,        -- Marker type
                MSG = "Press ~INPUT_CONTEXT~ to open the menu",  -- Interaction hint
            },

            -- Map blip configuration
            Blip = {
                Coords = vector3(-420.356, 1142.452, 324.8536),  -- Location
                Sprite = 175,    -- Blip icon ID
                Display = 4,     -- Display behavior
                Scale = 1.0,     -- Size
                Colour = 2,      -- Color
                Name = "FFA",    -- Label on map
            },
        },

        -- You can add more markers by adding FFA2, FFA3, etc.
    }
    ```

    <Tip>
      For marker and blip types, colors, and other options, refer to the [FiveM documentation on markers](https://docs.fivem.net/docs/game-references/markers/) and [blips](https://docs.fivem.net/docs/game-references/blips/).
    </Tip>
  </Accordion>

  <Accordion title="FFA Zones">
    ### Combat Zone Configuration

    FFA zones define the combat areas where players fight:

    ```lua theme={null}
    Config.Zones = {
        Zone0 = {
            Name = "Only Pistol",  -- Zone name displayed to players
            Desc = "Pistols only zone with limited weapons.",  -- Description
            AddedDate = "29.06.2022",  -- When the zone was added

            MaxPlayers = 10,  -- Maximum players allowed in this zone

            -- Dimension settings (requires OneSync Infinity)
            Dimension = true,  -- Use separate dimension for this zone
            DimensionID = 10000,  -- Unique dimension ID (must be different for each zone)

            -- Visual representation of zone boundaries
            ShowZone = true,  -- Show zone boundaries
            ZoneHeight = 25,  -- Height of zone visualization
            ZoneAlpha = 90,   -- Transparency
            ZoneColor = {r = 69, g = 255, b = 141},  -- RGB color

            -- Zone boundary coordinates (vertices of the zone)
            ZoneCoords = {
                {-154.50605773926, -937.58984375, 253.3971862793},
                {-157.92643737793, -948.24786376953, 252.89315795898},
                -- Additional coordinates...
            },

            -- Spawn points within the zone
            Spawnpoints = {
                {-159.85989379883, -990.80316162109, 254.13130187988},
                {-185.45248413086, -1008.3400268555, 254.33544921875},
                -- Additional spawn points...
            },

            -- Weapon settings for this zone
            OwnWeapons = false,  -- Allow players to use their own weapons
            Weapons = {  -- Available weapons in this zone
                "WEAPON_PISTOL",
                "WEAPON_PISTOL_MK2",
                "WEAPON_COMBATPISTOL",
                -- Additional weapons...
            },
        },

        -- You can add more zones by adding Zone1, Zone2, etc.
    }
    ```

    <Info>
      Each zone should have a unique DimensionID to prevent players in different zones from seeing each other. Make sure your server has OneSync Infinity enabled for the dimension feature to work.
    </Info>
  </Accordion>
</AccordionGroup>

## Game Modes & Economy

Configure different game modes with their own rules and economy settings.

<AccordionGroup>
  <Accordion title="Game Mode Configuration">
    ### Available Game Modes

    ```lua theme={null}
    Config.Gamemode = {
        Gamemode1 = {
            Name = "Hardcore",
            Desc = "Es gelten die selben Regeln wie im normalen Spielmodus, stirbst du, verlierst du <span>ALL</span> dein <span>GELD</span> was du dabei hast! Für jede Eliminierung die du erzielst, erhälst du <span>$90,000</span> auf deinem Konto gut geschrieben!",
            Death = "Alles Geld Verlieren",

            JoinPrice = 20000,  -- Cost to join this game mode
            KillReward = 90000,  -- Money reward per kill
        },

        Gamemode2 = {
            Name = "Normal",
            Desc = "Es gelten die typischen FFA Regeln! Du kannst durch das spielen von FFA auszeichnungen erhalten. Durch das erbringen von Auszeichnungen erhälst du weitere Belohnungen!",
            Death = "Garnichts :)",

            JoinPrice = 10000,
            KillReward = 35000,
        },

        // Add more game modes as needed
    }
    ```

    <Tip>
      Create game modes with different risk/reward profiles to appeal to different player types. High-risk modes like Hardcore can create exciting tension, while Normal modes can be more accessible.
    </Tip>
  </Accordion>
</AccordionGroup>

## Discord Integration

Configure Discord webhook integration for announcements and logging.

<AccordionGroup>
  <Accordion title="Discord Webhook Settings">
    ### Basic Discord Setup

    ```lua theme={null}
    Config.DiscordLogs = true

    Config.LeaderBoard = true
    Config.LeaderBoardColor = 65280
    Config.LeaderBoardWebhook = ""
    Config.LeaderBoardSendTimeout = 18000000 --Every 5 hours
    Config.LeaderBoardTop = 10

    Config.KillWebhook = ""
    Config.KillStreakWebhook = ""
    Config.JoinWebhook = ""
    Config.LeaveWebhook = ""

    Config.KillColor = 65280
    Config.StreakColor = 65280
    Config.JoinColor = 65280
    Config.LeaveColor = 65280

    Config.Username = "Dein Server"
    Config.Avatar = "https://cdn.discordapp.com/attachments/428282615720706048/1038175444685561946/logo2.png"
    Config.Title = "Dein Server"
    Config.CommuntiyLogo = "https://cdn.discordapp.com/attachments/428282615720706048/1038175444685561946/logo2.png"
    Config.FooterIcon = "https://cdn.discordapp.com/attachments/428282615720706048/1038175444685561946/logo2.png"
    Config.Thumbnail = "https://cdn.discordapp.com/attachments/428282615720706048/1038175444685561946/logo2.png"
    Config.FooterText = "FFA Logs"

    ```

    <Info>
      Discord webhooks allow your server to automatically post FFA events,
      leaderboards, and other important information to your Discord server. This
      helps keep your community engaged and aware of in-game activities.
    </Info>
  </Accordion>
</AccordionGroup>

## 🚀 Pro Tips for Optimization

Take your FFA setup to the next level with these advanced strategies:

* **Balance Game Modes**: Create a mix of high-risk/high-reward and low-risk/low-reward game modes to appeal to different player preferences.
* **Strategic Zone Placement**: Place FFA zones away from important roleplay areas to avoid disrupting RP experiences.
* **Weapon Progression**: Consider creating zones with progressively better weapons that cost more to enter, creating a sense of progression.
* **Custom Rewards**: Use the `Config.KillStreakNotification` function to give unique rewards for impressive killstreaks.
* **Seasonal Events**: Temporarily modify zone settings, game modes, or rewards to create special seasonal events.

<Callout>
  Remember to restart the resource after making configuration changes for them
  to take effect.
</Callout>
