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.

Available Exports

ExportDescriptionReturn Type
getZoneDataGet information about the current zonetable
getGamemodeDataGet information about the current gamemodetable
isScriptStartedCheck if the FFA script has successfully initializedboolean
getCurrentKillStreakGet the player’s current killstreak countnumber
isInGameCheck if the player is currently in an FFA zoneboolean
isDeadCheck if the player is currently dead in FFAboolean
inCombatCheck if the player is currently in combatboolean

Usage Examples

    Export Details

    getZoneData

    Returns a table containing all information about the current zone the player is in.
    local zoneData = exports['ffa']:getZoneData()
    
    Return Value:
    {
        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.
    local gamemodeData = exports['ffa']:getGamemodeData()
    
    Return Value:
    {
        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.
    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.
    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.
    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.
    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).
    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:
    -- 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:
    -- 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)