LuaBeans Bridge
LuaBeans Bridge is the core FiveM integration resource that connects your server to LuaBeans - Community Manager. It handles API communication, duty state management, and provides exports for other resources.
Overview
LuaBeans Bridge acts as the communication layer between your FiveM server and the LuaBeans web panel. It:
Manages player duty state (on/off duty)
Fetches player departments and ranks from the web panel
Provides exports for other resources to check duty status
Caches player data to reduce API calls
Handles authentication via API token
Installation
Step 1: Copy Resource
Copy the luabeans resource folder into your FiveM server's resources directory:
# From your FiveM server directory
cp -r /path/to/luabeans fivem-server/resources/Or extract from the distribution ZIP if you downloaded it.
Step 2: Configure Server
Add to your server.cfg:
Important: The LUABEANS_LEO_API_TOKEN must match the LEO_API_TOKEN value in your web panel's .env file.
Step 3: Verify Installation
Start your FiveM server
Check console for LuaBeans Bridge startup messages
Join the server and test duty commands
Configuration
Required Convars
LUABEANS_API_BASE
Yes
Base URL of your LuaBeans web panel
https://hub.yourserver.com
LUABEANS_LEO_API_TOKEN
Yes
API token (must match LEO_API_TOKEN in web panel)
abc123...
Optional Configuration
Edit config.lua to customize behavior:
Integrations
rcore_police Integration
Automatically sync duty state with rcore_police:
When enabled, LuaBeans Bridge will call:
ESX Integration
Automatically sync job assignments with ESX:
When on duty, the player's job is set to the department slug. When off duty, it reverts to the fallback job.
Client Exports
LuaBeans Bridge provides several client exports for other resources to use.
IsPlayerOnDuty()
Check if a player is currently on duty.
Returns: boolean - true if on duty, false if off duty
GetDutyOptions()
Get all available duty options for the player.
Returns: Table with:
ok(boolean) - Whether the request succeededdepartments(table) - Array of available departmentsselectedDeptId(number) - Currently selected department IDonDuty(boolean) - Whether player is currently on duty
Each department entry has a setActive() method to set it as the active department.
UpdatePlayerDuty(status)
Go on or off duty.
Parameters:
status(boolean) -trueto go on duty,falseto go off duty
Note: If going on duty, you must first select a department using GetDutyOptions().departments[index].setActive().
Server Events
luabeans:server:playerOnDuty
Fired when a player goes on duty.
Parameters:
source(number) - Player server IDdepartmentId(number) - Department IDrankId(number) - Player's rank ID in department
luabeans:server:playerOffDuty
Fired when a player goes off duty.
Parameters:
source(number) - Player server ID
Client Events
These events are emitted by LuaBeans Bridge for UI resources to listen to.
luabeans:client:profile
Fired when player profile data is loaded or refreshed.
Profile Structure:
luabeans:client:deptData
Fired when department data is loaded (vehicles, uniforms, etc.).
luabeans:client:offDuty
Fired when player goes off duty (client-side notification).
API Endpoints Used
LuaBeans Bridge makes API calls to these endpoints:
GET /api/leo/user/:discordId/departments
Fetches player's departments and ranks.
Headers:
Authorization: Bearer <LUABEANS_LEO_API_TOKEN>
Response:
POST /api/leo/duty/:action
Updates player duty state.
Actions: on or off
Headers:
Authorization: Bearer <LUABEANS_LEO_API_TOKEN>Content-Type: application/json
Body (for on action):
Troubleshooting
Resource Not Starting
Issue: LuaBeans Bridge won't start
Solutions:
Check
server.cfghasensure luabeansVerify resource folder name is exactly
luabeansCheck console for error messages
Verify
fxmanifest.luais present
API Connection Failed
Issue: Cannot connect to web panel API
Solutions:
Verify
LUABEANS_API_BASEis correct and accessible from serverCheck
LUABEANS_LEO_API_TOKENmatches web panelLEO_API_TOKENVerify web panel is running and accessible
Check firewall rules allow connection from FiveM server
Verify SSL certificate is valid (if using HTTPS)
No Departments Showing
Issue: Player sees no departments in duty menu
Solutions:
Verify player has
discord:identifierCheck player is assigned to departments in web panel
Verify
DISCORD_GUILD_IDmatches in web panelCheck player has active department memberships
Use
/dutyrefreshcommand to refresh player data
Duty State Not Persisting
Issue: Duty state resets on disconnect/reconnect
Solutions:
This is expected behavior - duty state is session-based
Players must go on duty each time they join
Duty state is not saved between sessions
Permission Issues
Issue: Player has incorrect permissions
Solutions:
Refresh player data:
/dutyrefreshorRefresh rolesin web panelVerify rank permissions in web panel
Check department assignment in web panel
Verify Discord role syncing is working
Performance Considerations
API Rate Limiting
LuaBeans Bridge caches player data for 5 minutes (configurable)
API calls are rate-limited to prevent spam
Consider increasing
Config.RefreshIntervalMsif experiencing rate limits
Network Optimization
Uses connection pooling for HTTP requests
Implements request timeouts (default 5 seconds)
Handles network errors gracefully
Resource Dependencies
LuaBeans Bridge has no hard dependencies but integrates with:
ESX (optional) - For job sync
rcore_police (optional) - For duty bridge
Discord identifiers - Required for all players
Advanced Usage
Custom Duty Logic
You can listen to duty events and implement custom logic:
Integration with Other Resources
Other resources can check duty status:
Configuration Files
config.lua
Main configuration file for integrations and API settings.
Location: luabeans/config.lua
Note: This file is excluded from escrow by default so you can edit it.
fxmanifest.lua
Resource manifest defining files and dependencies.
Support
For issues with LuaBeans Bridge:
Check console logs for error messages
Verify API connectivity
Review Troubleshooting section
Check web panel logs for API errors
Ensure player has proper Discord identifier
Related Documentation
LuaBeans Duty - UI/menu layer for duty system
LEO Duty System - Web panel configuration
FiveM API Documentation - Complete API reference
Last updated
