Configurations

Advanced Starterpack Configurations

Config = {}

--[[
▀█▀ █▀▀ █▀▀ ▀█ █▄█   █▀▀ █▀█ █▀█ █▀▀   █▀▄ █▀▀ █░█ █▀▀ █░░ █▀█ █▀█ █▀▄▀█ █▀▀ █▄░█ ▀█▀
░█░ ██▄ ██▄ █▄ ░█░   █▄▄ █▄█ █▀▄ ██▄   █▄▀ ██▄ ▀▄▀ ██▄ █▄▄ █▄█ █▀▀ █░▀░█ ██▄ █░▀█ ░█░

    Documentation: https://tcdev.gitbook.io/tcd-documentation/free-release/advanced-starterpack-system
]]

Config.Debug = false                      -- enable debug mode to see more information in the console
Config.CheckVersion = true                -- check for the latest version of the script

Config.TargetResource = 'ox_target'       -- supported: ox_target, qb-target
Config.InventoryResource = 'ox_inventory' -- supported: ox_inventory, qb-inventory, ps-inventory, qs-inventory
Config.SQLResource = 'oxmysql'            -- supported: oxmysql, mysql-async, ghmattimysql

Config.UsePlayerLicense = true            -- if you want to use player license to check if they have received the starter pack or not

Config.UseTarget = true                   -- enable target system to interact with the peds

Config.CommandConfig = {                  -- command to give the starter package
    enable           = true,
    command          = 'starterpack',
    command_help     = 'Get your starter pack',
    starterpack_type = 'normal',
    starter_vehicle  = {
        enable = true,
        model = 'adder',
        parking = "pillboxgarage",
    }
}

Config.Locations = {
    ["1"] = {                                                                       -- Unique identifier for the location
        starterpack_type = 'normal',                                                -- Type of starter pack given to the player (set to false if you don't want to give a starter pack item)
        label            = 'Get your starter pack',                                 -- Target label (shown to the player)
        icon             = 'fa-solid fa-gift',                                      -- Target icon (from FontAwesome)

        coords           = vec4(-1040.479126, -2731.582520, 20.164062, 238.110229), -- Coordinates and heading of the NPC (ped)

        ped              = {                                                        -- Settings for the ped (NPC)
            show_only_for_newbie = false,                                           -- Show the ped only for the player who hasn't received the starter pack
            model = 'a_m_y_business_03',                                            -- Ped model (see the FiveM ped model list)
            scenario = 'WORLD_HUMAN_CLIPBOARD',                                     -- Ped scenario (animation/behavior)
            heading = 238.110229,                                                   -- Direction the ped is facing
        },

        safezone         = { -- Safe zone settings (optional)
            enable = false,  -- Enable or disable the safe zone
            zone_points = {} -- Define safe zone points (if enabled) using vector3
        },

        starter_vehicle  = {           -- Vehicle settings for players receiving a starter vehicle
            enable = true,             -- Enable or disable the starter vehicle
            model = 'adder',           -- Vehicle model (from FiveM vehicle model list) will be ignored if random_vehicle is set to true
            random_vehicle = true,     -- Spawn a random vehicle from the list (true/false)
            teleport_player = false,   -- Teleport player to the vehicle (true/false)
            parking = "pillboxgarage", -- Parking location name for storing the vehicle in the database (set to nil if your garage system doesn't support parking)
            vehicle_spawns = {         -- Spawn points for the vehicle (multiple spawn locations)
                vec4(-1039.02, -2727.53, 19.65, 243.17),
                vec4(-1043.3, -2725.09, 19.65, 241.12),
                vec4(-1047.57, -2722.66, 19.65, 240.54),
                vec4(-1034.38, -2719.0, 19.65, 240.52),
                vec4(-1038.51, -2716.53, 19.64, 240.34),
            },
            fuel = 100.0, -- Fuel level of the vehicle when spawned
        },

        receiving_radius = 20.0, -- Radius around the location where players can receive the starter pack
        distance         = 2.0,  -- Distance from the ped to interact with it
    },
    -- add more locations here
}

Config.RandomVehicles = { -- list of vehicles to be given randomly to the player
    vehicles = {
        "adder",
        "zentorno",
        "t20",
        "osiris",
        "reaper",
        "tempesta",
        "italigtb",
        "italigtb2",
        "nero",
        -- add more vehicles here
    }
}

Config.StarterPackItems = { -- items that will be given to player
    ["normal"] = {
        { item = 'burger',   amount = 5 },
        { item = 'sprunk',   amount = 5 },
        { item = 'phone',    amount = 1 },
        { item = 'lockpick', amount = 5 },
        { item = 'money',    amount = 5000 },
    },
    -- add more starter pack types here
}

---@param vehicle any
---@param fuel number
---@decription Set fuel level of the vehicle using the fuel resources
Config.SetFuel = function(vehicle, fuel)
    if GetResourceState("LegacyFuel") == "started" then
        exports['LegacyFuel']:SetFuel(vehicle, fuel)
    elseif GetResourceState("cdn-fuel") == "started" then
        exports['cdn-fuel']:SetFuel(vehicle, fuel)
    elseif GetResourceState("ps-fuel") == "started" then
        exports['ps-fuel']:SetFuel(vehicle, fuel)
    elseif GetResourceState("lj-fuel") == "started" then
        exports['lj-fuel']:SetFuel(vehicle, fuel)
    else
        warn("Fuel resource not found, please set your fuel resource in the config.lua")
    end
end

---@param vehicle any
---@return string
---@decription If you have a custom vehicle key system you can give the key to the player
Config.GiveKey = function(vehicle)
    local Core, Framework = GetCore()
    if Framework == "esx" then
        -- ESX Vehicle Key System
    else
        TriggerEvent("vehiclekeys:client:SetOwner", Core.Functions.GetPlate(vehicle))
    end
end

---@param message string
---@param type string
---@param is_server boolean
---@decription Send notification to the player
Config.Notification = function(message, type, is_server, src)
    local Core, Framework = GetCore()
    if is_server then
        if Framework == "esx" then
            TriggerClientEvent("esx:showNotification", src, message)
        else
            TriggerClientEvent('QBCore:Notify', src, message, type, 5000)
        end
    else
        if Framework == "esx" then
            TriggerEvent("esx:showNotification", message)
        else
            Core.Functions.Notify(message, type, 5000)
        end
    end
end

Using GetPlayerIdentifiers vs Player.identifier / Player.PlayerData.citizenid


In this section, we'll compare the use of GetPlayerIdentifiers with Player.identifier or Player.PlayerData.citizenid for player identification in scripts. This comparison will highlight the advantages and drawbacks of each approach, especially in multicharacter environments.

1. GetPlayerIdentifiers

  • Overview: Retrieves player identifiers like Rockstar license (license:), Steam ID (steam:), and Discord ID (discord:) from external platforms.

  • Best For: Ensuring a consistent and secure identification method across all characters, as the identifiers are tied to external services.

  • Security: Difficult to exploit, since these identifiers are tied to accounts outside of the game.

  • Drawback: Doesn't differentiate between multiple characters for the same player, as the external identifier remains the same across all characters.

2. Player.identifier or Player.PlayerData.citizenid

  • Overview: These are server framework-dependent identifiers (e.g., identifier in ESX and citizenid in QBCore) tied to either the player or specific characters.

  • Best For: Multi-character servers where each character needs a unique identifier.

  • Drawback: In multi-character setups, it can be exploited. For example, players could delete and recreate characters to bypass mechanisms like starter packs, since these identifiers can change with each new character.

Comparison Table


AspectGetPlayerIdentifiersPlayer.identifier / Player.PlayerData.citizenid

Source

External (Rockstar, Steam, Discord)

Internal (Server Framework - ESX, QBCore, etc.)

Consistency

Consistent across all characters

Unique to each character (in multi-character setups)

Security

Harder to spoof, tied to external accounts

Easier to exploit, especially in multi-character setups

Multi-Character Support

Not ideal for differentiating between characters

Ideal for differentiating between characters

Exploits (e.g., Starter Pack)

Hard to exploit (external ID remains the same)

Players can delete and recreate characters to exploit

Framework Dependency

Framework-agnostic

Dependent on specific server framework

Best For

Reliable identification across all characters

Differentiating between characters in multi-character servers


  • Use GetPlayerIdentifiers for more secure, consistent player identification across all characters.

  • Use Player.identifier or Player.PlayerData.citizenid to uniquely identify individual characters in multi-character servers, but ensure you have additional measures to prevent exploitation.

EnableConfig.UsePlayerLicense (set to true) for secure and consistent player identification across all characters. This ensures that the player's external identifier (like Rockstar license, Steam ID, or Discord ID) remains the same, preventing exploits like recreating characters to claim rewards again.

SetConfig.UsePlayerLicense to false if you want to uniquely identify individual characters in multi-character servers. However, you should implement additional safeguards (e.g., using external identifiers for backup checks) to prevent players from exploiting mechanisms by deleting and recreating characters.

Last updated