MBT Ratio
MBT Ratio is a persistent KD (Kill/Death) ratio tracker for FiveM servers. Every player kill and death is recorded in a MySQL database, and each player can view their personal stats at any time through a toggleable NUI panel.
A custom physical scoreboard prop is placed anywhere in the world and displays a live leaderboard — rendered as a DUI texture on the 3D object — showing all players ranked by their KD ratio.
At the end of each configured period (weekly or monthly), the player with the highest KD ratio is selected as the winner and receives a randomly rolled prize the next time they log in.
Features
- Persistent stats — kills, deaths, headshots and KD ratio stored in MySQL and loaded per-player on join
- Personal NUI panel — toggle your own stats with a configurable hotkey (default
F7) - Physical in-world scoreboard — custom 3D prop with a live DUI leaderboard rendered as a texture on the model; visible within a configurable distance
- Headshot detection — headshot kills are tracked separately (bone 31086)
- Blacklisted death causes — vehicle rotors, run-over, rammed, and suicide are excluded by default; fully configurable
- Prize draw system — weekly or monthly draw; the top-KD player wins a randomly rolled reward from a configurable loot table
- TxAdmin integration — data is automatically saved to the database on scheduled restarts and shutdowns
- Discord names — optionally pull player display names from your Discord server via Bot API
- Multi-framework — ESX and QBCore
Supported Frameworks
| Framework | Supported |
|---|---|
| ESX Legacy | ✅ |
| QBCore | ✅ |
How it works
- On player join, the script loads (or creates) their record from the
mbt_ratioMySQL table - When a player is killed by another player, the client sends death data to the server (killer ID, victim, weapon, bone)
- The server increments the victim's death counter and the killer's kill counter (+ headshot if bone is 31086), then pushes updated stats to both clients via NUI
- Every
MBT.DUI.Refreshseconds the server recalculates the KD leaderboard and broadcasts it to all clients; the DUI on the prop updates automatically when the player is within range - On the configured draw day, the server identifies the player with the highest KD ratio, records the prize result in
server/draws.json, and delivers the reward the next time that player connects - Data is saved to MySQL on every
txAdmin:events:serverShuttingDownortxAdmin:events:scheduledRestartevent (or manually via server event)
The resource name must remain mbt_ratio exactly. The script verifies its own name on startup and stops itself if renamed.