AZ Framework
Economy and Department System for FiveM Servers
Framework Overview
The AZ Framework implements a comprehensive economy and department (job) system for FiveM servers. It uses Discord IDs as unique identifiers and integrates with in-game HUD elements to provide real-time updates on player cash and job status.
Designed for flexibility and performance, the framework includes admin money controls, automated paychecks, and robust client synchronization. All data is persistently stored in MySQL with support for optional extensions like player levels, vehicles, and more.
Discord Integration
Uses Discord IDs as unique player identifiers with Discord-based admin permissions.
Real-time HUD
Provides real-time updates to player cash and job status through in-game HUD elements.
Paycheck System
Automated paycheck distribution at configurable intervals based on player departments.
Current version: 1.0.0 | Documentation updated: June 24, 2025
Key Features
Comprehensive features for FiveM economy and department management
Department/Job System
Organize players into departments with role-based permissions and automated paychecks
Persistent Economy
All player economy data stored in MySQL with auto-created tables
Discord Admin Permissions
Role-based admin permissions integrated with Discord
Webhook Logging
Comprehensive logging for transactions and admin commands via Discord webhooks
Full NUI HUD
Customizable HUD for displaying job status and money with real-time updates
Exportable Functions
API for integrating with other resources and custom scripts
Database Tables
Structure of the MySQL database tables used by the framework
Core Tables
Table Name | Description | Key Columns |
---|---|---|
econ_user_money | Stores player financial information | cash, bank, last_daily, card_info |
econ_departments | Stores department information | job_name, paycheck |
econ_admins | Stores admin login credentials | username, password_hash |
Optional Extension Tables
Table Name | Description |
---|---|
econ_accounts | Extended account information |
econ_cards | Credit/debit card information |
econ_payments | Payment transaction history |
econ_profile | Player profile information |
user_levels | Player progression levels |
user_vehicles | Player-owned vehicles |
Server Events
Events used for communication between client and server
Core Events
Event Name | Description | Direction |
---|---|---|
'hud:requestDepartment' | Client requests department and cash information | Client → Server |
'az-fw-money:requestMoney' | Synchronize money HUD | Client → Server |
'az-fw-departments:updateUserMoney' | Set user money | Server → Client |
'az-fw-departments:attemptAdminLogin' | Admin panel login attempt | Client → Server |
'az-fw-departments:requestUsers' | Get all user money entries | Client → Server |
Client Integration
How to integrate the framework with your client scripts
Receiving Data
Job Information
Clients receive job updates via:
- 'az-fw-departments:refreshJob'
- 'hud:setDepartment'
Money Information
Clients receive money updates via:
- 'updateCashHUD'
Client Commands
'movehud' Command
Allows players to reposition the HUD in-game:
/movehud
Spawn Sequence
On player spawn, the client should call:
-- On player spawn
TriggerServerEvent('az-fw-money:requestMoney')
TriggerServerEvent('hud:requestDepartment')
Departments Module
Manage player departments and job assignments
Exports Reference
Export Name | Description | Parameters | Returns |
---|---|---|---|
getDepartments | Fetch all departments from database | callback(rows) | invokes callback with rows |
getPlayerJob | Get player's current job | playerId, callback | invokes callback with job data |
Example Usage
lua-- Get all departments
exports[Az-Framework']:getDepartments(function(depts)
for k, v in pairs(depts) do
print("Department:", v.name, "Paycheck:", v.paycheck)
end
end)
-- Get a player's job
exports[Az-Framework']:getPlayerJob(playerId, function(job)
if job then
print("Player job:", job.name)
else
print("Player has no job assignment")
end
end)
Economy Module
Manage player finances and transactions
Exports Reference
Export Name | Description | Parameters | Returns |
---|---|---|---|
addMoney | Add cash to player | source, amount | void |
deductMoney | Remove cash, min 0 | source, amount | void |
modifyMoney | Set cash exactly | source, amount | void |
depositMoney | Move cash to bank | source, amount | void |
withdrawMoney | Move bank to cash | source, amount | void |
transferMoney | Transfer cash player→player | source, target, amount | void |
claimDailyReward | Grant daily reward | source, rewardAmount | void |
getDiscordID | Get player's Discord ID | source | string | null |
getDiscordRoleList | Get player's Discord roles | source, cb | invokes callback |
isAdmin | Check if player is admin | source, cb | invokes callback |
getMoney | Fetch cash, bank, last_daily | discordID, callback | invokes callback |
updateMoney | Update player money | discordID, data, cb | invokes callback |
logAdminCommand | Log admin command usage | name, src, args, success | void |
Example Usage
lua-- Add $500 to player
exports['Az-Framework']:addMoney(source, 500)
-- Deposit money to bank
exports['Az-Framework']:depositMoney(source, 200)
-- Transfer money to another player
exports['Az-Framework']:transferMoney(source, targetId, 300)
-- Get player money
local discordID = exports['Az-Framework']:getDiscordID(source)
exports['Az-Framework']:getMoney(discordID, function(moneyData)
print("Cash:", moneyData.cash, "Bank:", moneyData.bank)
end)
-- Daily reward system
exports['Az-Framework']:claimDailyReward(source, 1000)
Paycheck System
Automated paycheck distribution based on department assignments
Paycheck Logic
The framework runs a Citizen thread that executes distributePaychecks every Config.paycheckInterval milliseconds.
For each user in econ_departments, their paycheck amount is added to their cash. Players receive a notification using ox_lib.
Implementation Example
lua-- Paycheck distribution thread
Citizen.CreateThread(function()
while true do
Citizen.Wait(Config.paycheckInterval) -- e.g., 30 * 60 * 1000 for 30 minutes
-- Fetch all users with department assignments
MySQL.Async.fetchAll('SELECT * FROM econ_departments', {}, function(users)
for _, user in ipairs(users) do
local player = GetPlayerFromDiscordId(user.discord_id)
if player then
-- Add paycheck to player's cash
exports['Az-Framework']:addMoney(player, user.paycheck)
-- Notify player
TriggerClientEvent('ox_lib:notify', player, {
title = 'Paycheck Received',
description = 'You received $' .. user.paycheck,
type = 'success'
})
end
end
end)
end
end)
Admin System
Admin commands and permissions management
Admin Commands
Command | Description | Usage |
---|---|---|
/addmoney | Add money to player | /addmoney [amount] |
/deductmoney | Remove money from player | /deductmoney [amount] |
/setmoney | Set player's money amount | /setmoney [amount] |
/transfer | Transfer money to another player | /transfer [id] [amount] |
/deposit | Deposit cash to bank | /deposit [amount] |
/withdraw | Withdraw money from bank | /withdraw [amount] |
/dailyreward | Set daily reward amount | /dailyreward [amount] |
Important Notes
- Ensure Discord identifiers are correctly captured using 'discord:' in identifiers
- Admin permissions rely on correct Config.AdminRoleId and bot token setup
- All admin commands are logged via webhook for accountability
- Admin login is handled through 'az-fw-departments:attemptAdminLogin' event