> ## 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.

# Exports

> Integrate the FFA system with other scripts using these exports.

import { Callout, Steps, Tabs } from "nextra-theme-docs";

# FFA Script Exports

The FFA script provides several exports that allow other resources to interact with and retrieve information from the FFA system. This enables seamless integration with your server's other scripts.

<Callout>
  All exports are client-side only and can be used by other client scripts to
  get information about the current player's FFA status.
</Callout>

## Available Exports

| Export                 | Description                                          | Return Type |
| ---------------------- | ---------------------------------------------------- | ----------- |
| `getZoneData`          | Get information about the current zone               | table       |
| `getGamemodeData`      | Get information about the current gamemode           | table       |
| `isScriptStarted`      | Check if the FFA script has successfully initialized | boolean     |
| `getCurrentKillStreak` | Get the player's current killstreak count            | number      |
| `isInGame`             | Check if the player is currently in an FFA zone      | boolean     |
| `isDead`               | Check if the player is currently dead in FFA         | boolean     |
| `inCombat`             | Check if the player is currently in combat           | boolean     |

## Usage Examples

<Tabs items={['Lua', 'JavaScript']}>
  <Tabs.Tab>
    ```lua theme={null}
    -- Check if player is in FFA before doing something
    if exports['ffa']:isInGame() then
        -- Player is in FFA, handle accordingly
        TriggerEvent('my-script:disableFeature')
    else
        -- Player is not in FFA, proceed normally
        TriggerEvent('my-script:enableFeature')
    end

    -- Get player's current zone data
    local zoneData = exports['ffa']:getZoneData()
    if zoneData then
        print("Player is in zone: " .. zoneData.Name)
        print("Max players allowed: " .. zoneData.MaxPlayers)
    end

    -- Check player's killstreak
    local currentStreak = exports['ffa']:getCurrentKillStreak()
    if currentStreak >= 5 then
        -- Player has 5+ killstreak, maybe give a reward
        TriggerEvent('my-script:giveKillstreakReward', currentStreak)
    end
    ```
  </Tabs.Tab>

  <Tabs.Tab>
    ```js theme={null}
    // Check if player is in FFA
    const isInFFA = global.exports['ffa'].isInGame();
    if (isInFFA) {
        // Player is in FFA
        emitNet('my-script:disableFeature');
    }

    // Get gamemode data
    const gamemodeData = global.exports['ffa'].getGamemodeData();
    if (gamemodeData) {
        console.log(`Current gamemode: ${gamemodeData.Name}`);
        console.log(`Kill reward: ${gamemodeData.KillReward}`);
    }

    // Check if player is dead in FFA
    const isPlayerDead = global.exports['ffa'].isDead();
    if (isPlayerDead) {
        // Handle dead player state
    }
    ```
  </Tabs.Tab>
</Tabs>

## Export Details

### getZoneData

Returns a table containing all information about the current zone the player is in.

```lua theme={null}
local zoneData = exports['ffa']:getZoneData()
```

**Return Value:**

```lua theme={null}
{
    Name = "Zone Name", -- Name of the zone
    Desc = "Zone Description", -- Description of the zone
    AddedDate = "Date", -- When the zone was added
    MaxPlayers = 10, -- Maximum players allowed
    Dimension = true, -- Whether dimension is enabled
    DimensionID = 10000, -- Zone dimension ID
    -- ... other zone properties
}
```

### getGamemodeData

Returns a table containing all information about the current gamemode the player is using.

```lua theme={null}
local gamemodeData = exports['ffa']:getGamemodeData()
```

**Return Value:**

```lua theme={null}
{
    Name = "Gamemode Name", -- Name of the gamemode
    Desc = "Gamemode Description", -- Description of the gamemode
    Death = "Death Penalty", -- What happens on death
    JoinPrice = 10000, -- Price to join this gamemode
    KillReward = 30000 -- Reward for each kill
}
```

### isScriptStarted

Returns a boolean indicating whether the FFA script has successfully initialized.

```lua theme={null}
local scriptReady = exports['ffa']:isScriptStarted()
```

**Return Value:** `true` if script is initialized, `false` otherwise

### getCurrentKillStreak

Returns the player's current killstreak count as a number.

```lua theme={null}
local streak = exports['ffa']:getCurrentKillStreak()
```

**Return Value:** Number representing current killstreak (e.g., `5`)

### isInGame

Returns a boolean indicating whether the player is currently in an FFA zone.

```lua theme={null}
local inFFA = exports['ffa']:isInGame()
```

**Return Value:** `true` if player is in FFA, `false` otherwise

### isDead

Returns a boolean indicating whether the player is currently dead in FFA.

```lua theme={null}
local playerDead = exports['ffa']:isDead()
```

**Return Value:** `true` if player is dead, `false` otherwise

### inCombat

Returns a boolean indicating whether the player is currently in combat (recently dealt or received damage).

```lua theme={null}
local playerInCombat = exports['ffa']:inCombat()
```

**Return Value:** `true` if player is in combat, `false` otherwise

## Integration Examples

### Disable Features When in FFA

This example shows how to disable certain features of your server when a player is in FFA:

```lua theme={null}
-- Run this check periodically
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(1000) -- Check every second

        if exports['ffa']:isInGame() then
            -- Disable features that shouldn't work in FFA
            TriggerEvent('my-hud:hideElements')
            TriggerEvent('my-jobs:pause')
            TriggerEvent('my-phone:disable')
        else
            -- Re-enable features when not in FFA
            TriggerEvent('my-hud:showElements')
            TriggerEvent('my-jobs:resume')
            TriggerEvent('my-phone:enable')
        end
    end
end)
```

### Custom Killstreak Rewards

This example shows how to create custom rewards for killstreaks:

```lua theme={null}
-- Track previous streak to detect changes
local previousStreak = 0

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(1000)

        if exports['ffa']:isInGame() then
            local currentStreak = exports['ffa']:getCurrentKillStreak()

            -- Only process if streak increased
            if currentStreak > previousStreak then
                if currentStreak == 5 then
                    TriggerEvent('myserver:giveArmor')
                elseif currentStreak == 10 then
                    TriggerEvent('myserver:giveSpecialWeapon')
                elseif currentStreak == 20 then
                    TriggerServerEvent('myserver:broadcastAchievement', GetPlayerName(PlayerId()), currentStreak)
                end

                previousStreak = currentStreak
            end
        else
            -- Reset when not in FFA
            previousStreak = 0
        end
    end
end)
```

<Callout type="info">
  Remember that these exports only work client-side. If you need to access FFA
  data on the server, you'll need to create your own client-to-server event
  system.
</Callout>

{" "}
