How It Works
How It Works
System Architecture
The GOD - ATM Owner system operates through a client-server architecture that ensures synchronized ATM data, transaction processing, and real-time updates across all players.
Core Mechanics
1. ATM Ownership System
Purchase Flow
When a player purchases an ATM:
Validation: System checks if ATM is available and player has sufficient funds
Ownership Limit Check: Verifies player hasn't exceeded
Config.MaxATMsPerPlayerPayment Processing: Deducts payment from cash or bank (based on selection)
Database Update: Sets owner, initializes rent period (15 days), updates utilization text
Transaction Log: Creates purchase transaction record
Client Sync: All clients receive updated ATM list
Rent System
Initial Period: 15 days from purchase date
Payment Method: Bank account only
Auto-Expiry: If rent expires, ATM becomes available after 10 days
Rent Payment: Extends ownership by another 15 days
Cancellation: Owner can cancel rental, making ATM available immediately
2. Tax Collection System
Automatic Detection
The system uses proximity-based detection to automatically tax transactions:
Detection Process:
Proximity Check: Player must be within
Config.ProximityRadius(default: 1.0m) of an ATMBalance Monitoring: System continuously monitors bank and cash balance changes
Delta Calculation: Detects when bank balance decreases and cash increases (withdraw) or vice versa (deposit)
Transaction Type Detection: Identifies withdraw vs deposit based on balance deltas
Tax Calculation: Applies configured tax rate to transaction amount
Tax Payment: Deducts tax from appropriate source (cash for withdraw, bank for deposit)
Revenue Update: Adds tax amount to ATM revenue
Tax Payment Logic:
Withdraw (bank → cash): Tax paid from cash
Deposit (cash → bank): Tax paid from bank
Manual Transaction Processing
The system also supports manual transaction logging via ProcessATMTransaction() function for custom integrations.
3. Level & XP System
XP Calculation
Player XP is calculated based on:
ATM Ownership: 250 XP per owned ATM
Transaction Volume: 150 XP per $25,000 in transaction volume
Revenue Generated: 40 XP per $2,000 in total revenue
Level Thresholds
Tax Rate Limits
Tax rates are restricted based on owner level:
Level 1: 0-10%
Level 2: 0-20%
Level 3: 0-30%
Level 4: 0-35%
Level 5+: 0-39%
4. Employee Management
Hiring Process
Owner/Manager Action: Owner or employee with
managepermission initiates hireServer ID Input: Player enters target player's server ID
Validation: System verifies player is online and not already an employee
Permission Setup: Initial permissions can be set during hire
Database Insert: Creates employee record with permissions JSON
Logging: Admin log entry created for audit trail
Permission System
Employees can have the following permissions:
manage: Can access management UI and add/remove employeeswithdraw: Can withdraw revenue from ATMmanage_tax: Can change tax rate (ifConfig.AllowTaxChangeByManagers = true)view_logs: Can view transaction and admin logsemployees: Can manage employee list (subset of manage)
Permission Hierarchy
Owner: Full access to all features
Manager (
manage = true): Can manage employees and settingsEmployee (specific permissions): Limited access based on granted permissions
5. Revenue System
Revenue Accumulation
Tax amounts from transactions are automatically added to
revenuefieldRevenue is stored per ATM in the database
All-time revenue is calculated from transaction history
Revenue Statistics
The system tracks:
Current Revenue: Available balance in ATM
All-Time Revenue: Total revenue from all transactions
Last Week Revenue: Revenue from past 7 days
Daily Revenue: Revenue breakdown by day (14-day history)
Recent Transactions: Last 20 transactions with details
Revenue Withdrawal
Owner or employee with
withdrawpermission can withdraw revenueWithdrawal can be to cash or bank account
Transaction is logged in database
Revenue balance is decremented
6. Coordinate Synchronization
Chunked Streaming
To prevent network overflow, ATM coordinates are sent in chunks:
Server-Side Process:
Request Queue: Player requests trigger queue system
Chunk Size: Dynamic based on total ATM count (75-200 per chunk)
Latent Events: Uses
TriggerLatentClientEventfor efficient transmissionCompletion Signal: Final event signals completion
Client-Side Process:
Buffer Accumulation: Client accumulates chunks in buffer
Vector Parsing: Coordinates parsed into vector3 format
Cache Update: Updates proximity detection cache
Blip Creation: Creates map blips if enabled
7. ATM Manager NPC
NPC Features
Spawn Location: Configurable via
Config.ATMNpc.CoordsInteraction: Press
Enear NPC to open management UIBlip: Optional map blip showing NPC location
Text UI: ox_lib text UI shows interaction prompt
NPC Configuration
8. Database Structure
Core Tables
owned_atms: Main ATM data (owner, location, coords, tax, revenue, rent)atm_transactions: Transaction history (type, amount, tax_amount, timestamp)atm_employees: Employee records (permissions, hire date)atm_admin_logs: Audit trail for all admin actions
Data Relationships
ATMs have one owner (nullable)
ATMs can have multiple employees
Transactions belong to one ATM
Admin logs track all ownership changes
9. Framework Integration
QBCore / Qbox
Uses
qb-coreexports for framework objectiLib.framework.getIdentifier()for player identifiersiLib.framework.getBank()/getCash()for balancesiLib.framework.removeBank()/removeCash()for paymentsiLib.framework.addBank()/addCash()for deposits
ESX
Uses
es_extendedexports for framework objectSame abstraction layer via
ic3d_libAutomatic detection of framework type
10. UI System
NUI Architecture
HTML/CSS/JavaScript: Modern web-based interface
Real-Time Updates: WebSocket-like communication via NUI callbacks
State Management: Client-side state with server synchronization
Responsive Design: Works on all screen resolutions
UI Features
ATM List: Filterable, searchable list of all ATMs
Management Panel: Multi-tab interface (Permissions, Revenues, Employees, Settings)
Interactive Map: Click to view ATM location
Charts: Revenue visualization with daily/weekly data
Permission Editor: Toggle permissions for employees
Transaction Logs: Filterable transaction history
Performance Optimization
Network Optimization
Chunked Streaming: Prevents reliable overflow on large ATM counts
Queue System: Throttles coordinate requests to prevent spam
Latent Events: Uses bandwidth-efficient event system
Throttling: Minimum 5-second interval between coordinate pushes
Database Optimization
Indexed Queries: Proper indexes on frequently queried columns
Efficient Joins: Optimized SQL queries with proper relationships
Batch Operations: Bulk imports use chunked inserts
Connection Pooling: Uses oxmysql connection pooling
Client Optimization
Caching: Client caches ATM coordinates to reduce server requests
Proximity Checks: Only processes ATMs within detection radius
Debouncing: Prevents rapid-fire transaction detection
Efficient Loops: Optimized distance calculations
Security Features
Permission Validation
All server callbacks validate player permissions
Owner checks prevent unauthorized access
Employee permissions verified on every action
Admin logs track all sensitive operations
Input Validation
Server ID parsing with normalization
Tax rate bounds checking (0-100%)
Amount validation (positive numbers only)
Coordinate format validation
Audit Trail
All ownership changes logged
Employee actions tracked
Tax changes recorded with old/new values
Transaction history maintained
This system provides a robust, performant, and secure solution for ATM ownership and management in FiveM roleplay servers.
Last updated