💎 Giving Diamonds to Players
There are two ways to give diamonds to a player:
Using the in-game command
Updating directly through the database
🔹 Method 1 — In-Game Command
Use the following command inside the F8:
givemoney [player_id] diamonds [amount]
Example: givemoney 12 diamonds 500
This will give 500 diamonds to the player with ID 12.
🔹 Method 2 — Database Update (SQL)
You can also update a player’s diamonds directly in the database.
This uses the table battle_users.
Example SQL Update
UPDATE battle_users
SET diamonds = GREATEST(diamonds + ?, 0)
WHERE user_id = ?;
🔹 Using oxmysql Export in Lua
If you want to handle this directly in your scripts with oxmysql, you can use:
exports.oxmysql:execute([[
UPDATE battle_users
SET diamonds = GREATEST(diamonds + ?, 0)
WHERE user_id = ?
]], { amount, user_id })
diamonds → The column being updated
GREATEST(diamonds + ?, 0) → Ensures the value never goes below 0
{ amount, user_id } → Parameters passed in order (amount first, then user_id)