Unique ID - PtaxaDev/PyroByte-PtaxaDev-Wiki GitHub Wiki
Unique ID System Documentation
The Unique ID System script is designed to automatically generate and manage unique player IDs on a FiveM server. It provides access control, player activation/deactivation, logging via Discord Webhook, and integration with other resources through exports.
Features
- Automatic generation of unique player IDs.
- Access control with player approval system.
- Player activation/deactivation functionality.
- Logging of player connections via Discord Webhook.
- Export functions for integration with other resources.
Dependencies
- oxmysql: Required for database operations.
- Conflict: If using QBcore, remove the
connectqueue
resource to avoid conflicts.
Installation
- Download the script from https://portal.cfx.re/.
- Move the script to your server's resource folder.
- Add to server.cfg before running the framework:
ensure unique_id
- Start the server and connect to it.
Configuration Setup
The configuration is defined in the Config
table in the script's configuration file. Below is an example configuration with explanations of each parameter:
Config = {}
Config.Debug = false -- Enable debug mode for additional logging (true/false).
Config.Locale = "en" -- Language used for messages.
Config.DefaultStatus = 0 -- Default player status: 0 (inactive, requires approval), 1 (active, auto-approved).
Config.LicenseType = "steam" -- License type for player identification: "steam", "license", or "license2".
Config.LicenseTypeCheckAdmin = "license" -- License type for admin checks (must match admin entries in admins.lua).
Config.CheckDuplicateLicense = true -- Enable duplicate license checking (set to false if using ESX or other frameworks with built-in checks).
Config.Contact = "https://discord.gg/" -- Contact link for players to request approval.
Config.WebhookURL = "" -- Discord Webhook URL for logging player connections.
⚠️ Important: If
Config.LicenseType = "steam"
, you must setset steam_webApiKey "KEY"
inserver.cfg
. Obtain the Steam API key from http://steamcommunity.com/dev/apikey.
Configuration Parameters
Config.Locale
: Sets the language for in-game messages (e.g.,"en"
for English).Config.DefaultStatus
:0
: Players require manual approval via the/allowid
command to join the server.1
: Players are automatically assigned a unique ID and can join without approval.
Config.LicenseType
: Specifies the license type for player identification:"steam"
: Steam ID."license"
: FiveM license."license2"
: Rockstar license.
Config.LicenseTypeCheckAdmin
: Defines the license type for admin checks. Must match the format inadmins.lua
, e.g.:['license:00000000...'] = true
['license2:00000000...'] = true
['steam:00000000...'] = true
Config.CheckDuplicateLicense
: When set totrue
, checks for duplicate licenses. Set tofalse
if using frameworks like ESX that already handle duplicate license checks.Config.Contact
: A link (e.g., Discord) where players can request approval for their unique ID.Config.WebhookURL
: Discord Webhook URL for logging player connection events.
Commands
The script provides the following admin commands for managing player IDs:
/allow {unique_id} {true/false}
: Approves or denies a player’s access based on their unique ID.- Example:
/allow 123 true
to allow player with ID 123.
- Example:
/checkid {unique_id} {true/false}
: Checks the status of a player’s unique ID.
Exports
The script provides export functions for integration with other resources. Below is an example of how to use these exports:
-- Example of using exports
local id = PlayerPedId()
local dynamicId = exports['unique_id']:getDynamicId(id)
local uniqueId = exports['unique_id']:getUniqueId(dynamicId)
local license = exports['unique_id']:getLicenseByUniqueId(uniqueId)
Example Command
Below is an example of a server-side command that retrieves and prints player information using the script’s exports:
-- Server-side command example
RegisterCommand('test', function(source, args, rawCommand)
if not args[1] then
print('Error: ID not provided')
return
end
local id = tonumber(args[1])
local dynamicId = exports['unique_id']:getDynamicId(id)
local uniqueId = exports['unique_id']:getUniqueId(dynamicId)
local license = exports['unique_id']:getLicenseByUniqueId(uniqueId)
print('Unique ID: ' .. uniqueId)
print('Dynamic ID: ' .. dynamicId)
print('License: ' .. json.encode(license, {indent = true}))
end)
Notes
- Ensure all dependencies are properly installed and configured before running the script.
- For Steam-based identification, a valid Steam API key is required in
server.cfg
. - If using frameworks like ESX, disable
Config.CheckDuplicateLicense
to avoid conflicts with existing license checks. - Specify Config.Contact so that players know where to go to get their IDs removed.