Download
LonexDiscordAPI is available via GitHub.- Visit the repository: https://github.com/LonexLabs/LonexDiscordAPI
- Click Code → Download ZIP
Discord Bot Setup
LonexDiscordAPI requires a Discord bot to function correctly. Create a Discord Application- Go to the Discord Developer Portal
- Click New Application
- Give your application a name and create it
- Open your application
- Navigate to the Bot tab
- Click Create Bot
- Server Members Intent
- Presence Intent
- In the Bot section, click Reset Token (if needed)
- Copy the token - you’ll need this later.
Note: Keep this token secret. Do not share it.
- Manage Roles
- Manage Nicknames
- View Channels
- Move Members (only required if using voice channel features)
Important Role Hierarchy Notice
Discord bots can only manage roles that are below their highest role.
Discord bots can only manage roles that are below their highest role.
- The bot has its own role
- The bot’s role is placed above any roles you want it to manage
Installing LonexDiscordAPI
Resource Installation- Place the resource in your server’s
resourcesfolder - Ensure the folder name is exactly:
LonexDiscordAPI
server.cfg:
- YOUR_BOT_TOKEN → The bot token copied from the Discord Developer Portal
- YOUR_GUILD_ID → Your Discord server ID (enable Developer Mode in Discord to copy this)
Configuration Guide
This guide explains all configuration options available inconfig.lua.
General Settings
| Option | Type | Default | Description |
|---|---|---|---|
Debug | boolean | false | Enable debug mode for verbose logging |
LogLevel | string | 'info' | Log level: 'error', 'warn', 'info', 'debug' |
LogCacheRefresh | boolean | false | Log when guild/roles cache refreshes (set false to reduce console spam) |
CheckUpdates | boolean | true | Check GitHub for new releases on startup |
Force Default Ped
Forces all players to spawn as a specific ped model. Useful for servers with character selection systems.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable/disable this feature |
Ped | string | 'a_m_y_hipster_02' | Ped model name to spawn players as |
Cache Settings
Controls how long Discord data is cached to reduce API calls.| Option | Type | Default | Description |
|---|---|---|---|
RolesTTL | number | 300 | Seconds to cache role data |
GuildTTL | number | 600 | Seconds to cache guild data |
MemberTTL | number | 60 | Seconds to cache member data |
UserTTL | number | 300 | Seconds to cache user data |
MaxMembers | number | 500 | Maximum members to keep in cache |
Rate Limiting
Prevents hitting Discord API rate limits.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | true | Enable rate limiting |
MaxRequestsPerSecond | number | 40 | Maximum API requests per second |
MaxQueueSize | number | 100 | Maximum queued requests |
RetryOnLimit | boolean | true | Retry requests that hit rate limits |
MaxRetries | number | 3 | Maximum retry attempts |
RetryDelay | number | 1000 | Delay between retries (ms) |
Startup Options
Controls what happens when the resource starts.| Option | Type | Default | Description |
|---|---|---|---|
FetchGuildInfo | boolean | true | Fetch guild info on startup |
FetchRoles | boolean | true | Fetch and cache roles on startup |
InitDelay | number | 2000 | Delay before initialization (ms) |
ValidateToken | boolean | true | Validate bot token on startup |
Permissions
Assigns FiveM ACE permissions based on Discord roles. Permissions are synced during player connection, ensuring compatibility with vMenu and other ACE-based resources.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | true | Enable permission system |
RefreshOnFetch | boolean | true | Refresh permissions when member data is fetched |
LogAssignments | boolean | false | Log permission assignments to console |
Role Mappings
TheRoles table maps Discord Role IDs to FiveM ACE groups. Define this at the bottom of your config.lua:
Setting Up ACE Groups
In yourlonexperms.cfg or server.cfg, define what permissions each group has:
How It Works
- Player connects to server
- LonexDiscordAPI fetches their Discord roles during connection
- Matching roles are converted to ACE groups using the
Rolestable - Groups are assigned using
identifier.discord:IDformat - Player loads in with all permissions ready (vMenu, etc.)
Webhooks
Send messages to Discord channels via webhooks.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | true | Enable webhook system |
RateLimit | number | 1000 | Minimum ms between webhook messages |
MaxQueueSize | number | 50 | Maximum queued webhook messages |
DefaultColor | number | 5793266 | Default embed color (decimal) |
IncludeTimestamp | boolean | true | Include timestamp in embeds |
Adding Webhook URLs
Templates
Pre-defined embed templates with placeholder support:{placeholder} syntax for dynamic values.
Weapon Permissions
Restrict weapons based on Discord roles.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable weapon restrictions |
CheckInterval | number | 1000 | How often to check (ms) |
RemoveWeapon | boolean | true | Remove unauthorized weapons |
NotifyPlayer | boolean | true | Show notification when weapon removed |
NotifyMessage | string | '...' | Notification message |
Configuring Weapon Roles
Restricted Weapons List
Vehicle Permissions
Restrict vehicles based on Discord roles.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable vehicle restrictions |
CheckInterval | number | 1000 | How often to check (ms) |
EjectPlayer | boolean | true | Eject player from unauthorized vehicle |
DeleteVehicle | boolean | false | Delete vehicle after ejecting player |
NotifyPlayer | boolean | true | Show notification when ejected |
EjectDelay | number | 0 | Delay before ejecting (ms) |
Configuring Vehicle Roles
Restricted Vehicles List
Ped Permissions
Restrict ped models (uniforms) based on Discord roles.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable ped restrictions |
CheckInterval | number | 1000 | How often to check (ms) |
ResetPed | boolean | true | Reset player to default ped if unauthorized |
NotifyPlayer | boolean | true | Show notification when reset |
DefaultPed | string | 'a_m_y_hipster_02' | Ped to reset unauthorized players to |
Configuring Ped Roles
Restricted Peds List
Tags (Head Tags, Chat Tags & Voice Tags)
Unified tag system with NUI menu for head tags, chat prefixes, and pma-voice integration.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable tags system |
MenuCommand | string | 'tags' | Command to open the tag menu |
MenuPosition | string | 'left' | Menu position: 'left' or 'right' |
DefaultShowOthers | boolean | true | Show other players’ tags by default |
DefaultShowOwn | boolean | true | Show own tag by default |
Head Tags Options
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | true | Enable head tags |
MaxDistance | number | 20.0 | Maximum distance to see tags |
HeightOffset | number | 1.0 | Height above player’s head |
Font | number | 4 | GTA font ID |
Scale | number | 0.4 | Text scale |
Chat Tags Options
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | true | Enable chat role prefixes |
Voice Tags Options (pma-voice)
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | true | Enable voice tags (requires pma-voice) |
ShowSelf | boolean | true | Show your own voice tag |
Default Tag
Displayed for players without any configured Discord roles:Configuring Tag Roles
| Property | Type | Description |
|---|---|---|
roleId | string | Discord Role ID |
text | string | Tag text displayed |
color | table | RGB color { r = 0-255, g = 0-255, b = 0-255 } |
chatColor | string | Chat color code (e.g., '^2' for green) |
Chat Color Codes
| Code | Color | Code | Color |
|---|---|---|---|
^0 | White | ^5 | Cyan |
^1 | Red | ^6 | Pink |
^2 | Green | ^7 | White |
^3 | Yellow | ^8 | Orange |
^4 | Blue | ^9 | Grey |
Player Menu
Players can type/tags to open a NUI menu where they can:
- Toggle visibility of other players’ tags
- Toggle visibility of their own tag
- Select which tag to display (from their available roles)
Emergency Calls (911/311 System)
Players can make emergency calls that are sent to Discord and displayed to on-duty responders.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable emergency calls system |
Cooldown | number | 60 | Seconds between calls (per player) |
Duty System
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Require duty status to receive calls |
Command | string | 'duty' | Command to toggle duty status |
DefaultOnDuty | boolean | false | Default duty status on join |
Call Types Configuration
| Option | Type | Description |
|---|---|---|
Enabled | boolean | Enable/disable this call type |
Command | string | Command to make this type of call |
Label | string | Display name for the call type |
Color | number | Discord embed color (hex) |
ChannelId | string | Discord channel ID for call logs |
ResponderRoles | table | Discord role IDs that can see/respond |
Prefix | string | Chat prefix for in-game notifications |
Response Command
Use/resp <call_id> to set a waypoint to the caller’s location.
Area of Play (AOP)
Set and display the current area of play for your server.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable AOP system |
Command | string | 'aop' | Command to change AOP |
Default | string | 'All of San Andreas' | Default AOP on server start |
AllowedRoles | table | {} | Discord role IDs that can change (empty = all) |
PeaceTime
Toggle PeaceTime mode with weapon restrictions and speed limits.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable PeaceTime system |
Commands | table | {...} | Commands to toggle PeaceTime |
Default | boolean | false | Default state on server start |
AllowedRoles | table | {} | Discord role IDs that can toggle (empty = all) |
Restrictions
| Option | Type | Default | Description |
|---|---|---|---|
DisableWeapons | boolean | true | Prevent weapon use during PeaceTime |
SpeedLimit.Enabled | boolean | true | Enable speed limit warnings |
SpeedLimit.Limit | number | 65 | Speed limit value |
SpeedLimit.Unit | string | 'mph' | Speed unit: 'mph' or 'kmh' |
SpeedLimit.WarningInterval | number | 5 | Seconds between warning notifications |
Announcements
Send server-wide announcements displayed on all players’ screens.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable announcements system |
Command | string | 'announce' | Command to send announcements |
AllowedRoles | table | {} | Discord role IDs that can announce (empty = all) |
Header | string | '~b~[~p~Server Announcement~b~]' | Header text with GTA color codes |
Duration | number | 10 | Seconds to display announcement |
Position | number | 0.3 | Y position (0 = top, 0.5 = center) |
Postals
Navigate to postal codes using waypoints.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable postal system |
Command | string | 'postal' | Command to set/cancel postal waypoint |
/postal 123- Set waypoint to postal 123/postal- Cancel current postal waypoint
Moderation Commands
Server moderation tools with Discord role-based access control.Delete Vehicle
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | true | Enable delete vehicle command |
Command | string | 'dv' | Command to delete vehicle |
AllowedRoles | table | {} | Discord role IDs that can use (empty = all) |
SearchRadius | number | 5.0 | Radius to search for nearby vehicle (meters) |
/dv - Deletes the vehicle you’re in, or the closest vehicle within range.
Delete All Vehicles
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | true | Enable delete all vehicles command |
Command | string | 'dvall' | Command to delete all vehicles |
AllowedRoles | table | {} | Discord role IDs that can use (empty = all) |
Countdown | number | 20 | Seconds before deletion (with warnings) |
OnlyUnoccupied | boolean | true | Only delete vehicles with no occupants |
/dvall - Starts a 20-second countdown, then deletes all unoccupied vehicles.
Clear Chat
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | true | Enable clear chat command |
Command | string | 'clearchat' | Command to clear chat |
AllowedRoles | table | {} | Discord role IDs that can use (empty = all) |
ShowClearedBy | boolean | true | Show who cleared the chat |
/clearchat - Clears the chat for all players.
Activity System
Comprehensive duty tracking system for emergency services with blips, loadouts, database logging, and HTTP API.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable the activity system |
AutoOffDutyOnDisconnect | boolean | true | Automatically clock out when player disconnects |
Commands
| Option | Type | Default | Description |
|---|---|---|---|
Duty | string | 'duty' | Command to clock in/out |
BlipTag | string | 'bliptag' | Command to change displayed tag |
Units | string | 'units' | Command to list on-duty players |
Database (Optional)
Requiresoxmysql to be installed. Run activity_schema.sql to create tables.
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable database logging |
TablePrefix | string | 'lonex_' | Prefix for database tables |
lonex_duty_sessions- Individual clock-in/out recordslonex_duty_totals- Aggregated totals per player per department
HTTP API (Optional)
REST API for external access (websites, Discord bots, dashboards).| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable HTTP API |
Endpoint | string | '/lonex/activity' | Base URL path |
AuthToken | string | '' | Secret token for auth |
GET /lonex/activity/online- Current on-duty players with department countsGET /lonex/activity/history?discord_id=XXX&days=7- Player duty historyGET /lonex/activity/leaderboard?department=leo&days=30&limit=10- Top players by hours
Authorization: your-token header for authentication.
Blips
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | true | Enable blips for on-duty players |
OnlyForOnDuty | boolean | true | Only show blips to other on-duty players |
Scale | number | 0.85 | Blip scale |
ShowName | boolean | true | Show player name on blip |
ShowDepartment | boolean | true | Show department tag on blip |
ShowHeading | boolean | true | Show direction cone (which way they’re facing) |
RefreshInterval | number | 2000 | How often to sync blip positions (ms) |
- Different sprites for on-foot vs in-vehicle
- Flashing red/blue when sirens are active
- Direction indicator showing which way player is facing
Discord Logs
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable Discord logging |
DefaultChannelId | string | '' | Default channel (if department has none) |
Departments
Configure each department with role access, blips, loadouts, and logging.| Property | Type | Description |
|---|---|---|
Label | string | Full department name |
ShortLabel | string | Short name for blip tag |
AllowedRoles | table | Discord role IDs (empty = everyone) |
BlipSpriteOnFoot | number | Blip sprite when on foot |
BlipSpriteInVehicle | number | Blip sprite when in vehicle |
BlipColor | number | Blip color ID |
LogChannelId | string | Discord channel for clock-in/out logs |
Loadout | table | Weapons/armor given on duty |
Loadout Configuration
| ID | Color |
|---|---|
| 0 | Normal |
| 1 | Green |
| 2 | Gold |
| 3 | Pink |
| 4 | Army |
| 5 | LSPD |
| 6 | Orange |
| 7 | Platinum |
| Component | Description |
|---|---|
COMPONENT_AT_PI_FLSH | Pistol Flashlight |
COMPONENT_AT_PI_SUPP | Pistol Suppressor |
COMPONENT_AT_AR_FLSH | Rifle Flashlight |
COMPONENT_AT_AR_SUPP | Rifle Suppressor |
COMPONENT_AT_AR_AFGRIP | Rifle Grip |
COMPONENT_AT_SCOPE_SMALL | Small Scope |
COMPONENT_AT_SCOPE_MEDIUM | Medium Scope |
COMPONENT_AT_SCOPE_LARGE | Large Scope |
Blip Sprites Reference
| Sprite | Icon |
|---|---|
| 1 | Circle/Dot |
| 56 | Car |
| 60 | Police Car |
| 61 | Ambulance |
| 64 | Helicopter |
| 226 | Motorcycle |
| 436 | Fire Truck |
Blip Colors Reference
| ID | Color |
|---|---|
| 0 | White |
| 1 | Red |
| 2 | Green |
| 3 | Blue |
| 5 | Yellow |
| 17 | Orange |
| 19 | Purple |
Activity System Exports
Activity System Events
Command Usage
/duty [department] - Clock in/out of duty
- If only one department available, auto-selects it
- If multiple departments, shows list or specify department name
- If already on duty, clocks out
/bliptag [id] - Change your displayed blip tag
- For players with access to multiple departments
- Shows list of available tags if no argument provided
/units - List all on-duty players
- Shows players grouped by department
- Displays player name, ID, and time on duty
Server HUD
Configurable on-screen HUD with compass, street, postal, AOP, and player info displays.| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Enable Server HUD |
ToggleCommand | string | 'togglehud' | Command to toggle HUD on/off |
Watermark Options
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | boolean | false | Show/hide the watermark |
Text | string | '...' | Server name, discord link, etc. |
x | number | 0.165 | X position (0.0 = left) |
y | number | 0.825 | Y position (0.0 = top) |
scale | number | 0.4 | Text scale |
Display Options
| Option | Type | Description |
|---|---|---|
x | number | X position (0.0 = left, 1.0 = right) |
y | number | Y position (0.0 = top, 1.0 = bottom) |
display | string | Text with placeholders and color codes |
scale | number | Text size |
enabled | boolean | Show/hide this display |
Placeholders
| Placeholder | Description |
|---|---|
{COMPASS} | Direction (N, NE, E, SE, S, SW, W, NW) |
{STREET} | Current street name |
{ZONE} | Current zone/area name |
{POSTAL} | Nearest postal code |
{POSTAL_DIST} | Distance to nearest postal (meters) |
{AOP} | Current Area of Play |
{PEACETIME} | PeaceTime status ( |
{ID} | Player’s server ID |
{PLAYERS} | Online player count |
{TAG} | Player’s current tag |
GTA Color Codes
| Code | Color | Code | Color |
|---|---|---|---|
~w~ | White | ~p~ | Purple |
~r~ | Red | ~c~ | Grey |
~g~ | Green | ~o~ | Orange |
~b~ | Blue | ~y~ | Yellow |
Console Commands
Server console commands for debugging and administration.| Command | Description |
|---|---|
lonex_roles | List all configured role mappings |
lonex_syncall | Manually sync permissions for all players |
lonex_debug_player <id> | Full diagnostic for player permissions |
lonex_debug_vehicles <id> | Debug vehicle permissions for player |
lonex_discord_perms <id> | Show player’s current groups and permissions |
lonex_discord_test <id> | Test Discord API for a player |
lonex_discord_testid <discord> | Test Discord API with a Discord ID |
lonex_discord_syncperms <id> | Force resync permissions for a player |
lonex_discord_testwebhook <name> | Send a test message to a webhook |
lonex_update | Check for updates |
Badger_Discord_API Bridge
Drop-in compatibility layer for scripts using the Badger_Discord_API export functions. Located inextras/Badger_Discord_API/, this bridge allows existing scripts to work without modification.
Installation
-
Copy
extras/Badger_Discord_APIto your resources folder -
Add to your
server.cfgafter LonexDiscordAPI:
Supported Functions
All standard Badger_Discord_API exports are supported:GetDiscordId(player)GetDiscordName(player)GetGuildIcon()GetGuildName()CheckEqual(player, role)CheckGreater(player, role, includeEqual)CheckLess(player, role, includeEqual)GetRoles(player)GetRoleName(roleId)IsPlayerInServer(player)
Quick Reference
Getting Discord IDs
- Open Discord Settings → Advanced → Enable Developer Mode
- Server ID: Right-click server icon → Copy Server ID
- Role ID: Server Settings → Roles → Right-click role → Copy Role ID
- User ID: Right-click user → Copy User ID
Admin Bypass
For any permission system (weapons, vehicles, peds), use an empty table to grant full access:Testing Configuration
- Set
Config.Debug = truefor verbose logging - Set
Config.LogLevel = 'debug'for detailed output - Check server console for errors on startup
- Use
lonex_debug_player <id>to diagnose permission issues

