All resources
Requires rsg-core rsg-inventory oxmysql
★ 0Updated 2026-12-050 open issues

rsg-scratchcards3.0.1 - Technical Documentation#

Summary#

Western themed "match three" scratch cards. Players use an item and scratch nine panels for cash. All results and payments are decided by the server.

Version3.0.1
Dependenciesrsg-core, rsg-inventory, oxmysql
Optionalrsg-log
Database tablesrsg_scratchcards
ExportsNone
CommandsNone
InterfaceNUI

1. Installation#

  1. Copy rsg-scratchcards into resources/[framework].
  2. Add the line in installation/shared_items.lua to rsg-core/shared/items.lua.
  3. Copy installation/scratchcard.png to rsg-inventory/html/images/.
  4. Add scratchcard to a shop (price about $1) in your shop resource.
  5. ensure rsg-scratchcards after oxmysql, rsg-core and rsg-inventory, then restart the server.

The table is created on first start. For a manual install set Config.AutoDatabase = false and import install.sql.

2. Architecture#

FileSidePurpose
shared/config.luasharedSettings
server/database.luaserverTable creation
server/server.luaserverItem use, rolling, payment
client/client.luaclientNUI focus and callbacks
html/NUICard and scratching

3. How it works#

Using the item removes one card, rolls the result and saves it. The server builds a 3x3 grid: a winner has exactly three of one symbol, a loser never has three. The prize is claimed when all panels are revealed or the card is closed. Wins not claimed (disconnect, restart) are paid 5 seconds after the character next loads, or when the player next uses a card.

SymbolPrizeChance
Horseshoe$115%
Wagon wheel$28%
Whiskey bottle$53%
Hat$101.2%
Sheriff star$250.4%
Gold bars$1000.08%

27.68% of cards win. The average payout is $0.76 per card, so sell cards for about $1 to keep it a money sink.

4. Configuration#

OptionDefaultDescription
Config.AutoDatabasetrueCreate the table on start
Config.AllowPushToTalkWhileOpentrueKeep push-to-talk working while the card is open
Config.PushToTalkControls{ 0x4BC9DABB }Controls left enabled
Config.Item'scratchcard'Usable item name
Config.UseCooldown3Seconds between cards
Config.PayType'cash'Money type for prizes
Config.LogWinsFrom25Log prizes of this size or more (0 = never)
Config.TotalWeight10000Total used for chances
Config.Prizessix prizessymbol, prize (whole number), weight

5. Items and commands#

Item scratchcard (usable, consumed, no metadata). No commands, keys or targets.

6. Exports#

None. This resource has no exports.

7. Events and callbacks#

NameDirectionArgumentsNotes
rsg-scratchcards:client:openserver to client{ id, grid, prizes, win }Internal
rsg-scratchcards:server:claimclient to serveridInternal. Checks owner and unclaimed

NUI callbacks: revealed, close. No server callbacks.

8. Data and database#

Table rsg_scratchcards: id, citizenid, prize, claimed, created_at. One row per card used.

9. Security#

The client only sends a card id. The server checks that the card belongs to the character and marks it claimed before paying, so it pays once. Item removal, odds and prize amounts are all server-side. The client is sent the result when the card opens, so a cheat could read it early but cannot change it. Scripts that give or sell cards must do their own checks.

10. Integration examples#

-- placeholder: call from your own server-side reward code, with a real player source
if exports['rsg-inventory']:CanAddItem(src, 'scratchcard', 1) then
    exports['rsg-inventory']:AddItem(src, 'scratchcard', 1, nil, nil, 'reward')
end

11. Localisation#

en, de, el, es, fr, ja, nl, pl, pt-br, ro, ru. Set with setr rsg:locale de.

12. Server owner how-tos#

  • Change odds or prizes in Config.Prizes; the console prints the win chance and average payout on start.
  • Old claimed rows can be removed with DELETE FROM rsg_scratchcards WHERE claimed = 1;

13. Troubleshooting#

ProblemCause / fix
Using the card does nothingItem missing from shared items, config invalid (see console), dead or handcuffed, or on cooldown
No item pictureCopy scratchcard.png into the inventory images folder

14. Known limitations#

  • Not run in game.
  • Selling is left to your shop resource.
  • Not connected to rsg-economy, rsg-reputation or rsg-skills.
  • Rows are never pruned automatically.

License#

GPL-3.0-or-later. See LICENSE.

Support: https://rexshack.tebex.store

Try GetPlayer, /bandana or weather. ↑↓ to move, Enter to open, Esc to close.