Commands#
Lottery Creator registers a single command. Everything else happens at the machines, in the inventory and on the phone.
Command | Where | Description |
|---|---|---|
| In game | Opens the creator: every machine on the server, to create, edit, teleport to or delete. Framework admins and |
There are no console commands. For a look inside, Config.Debug = true prints extra lines in the server console. Lottery Creator exposes no exports either: your own scripts drive it through the events and callbacks below.
Client Events#
For opening a machine from your own scripts — a radial menu, a keybind, a laptop prop. The server still runs every check: whether the machine is in service, its stock, the player's money.
Buy a ticket from a machine
-- The same as picking "Buy <name>" on the target:
-- the hand-over gesture plays, then the server sells the ticket.
TriggerEvent('lottery:client:buyFromVendor', { vendorId = 12 })Open a machine's ownership panel
-- The buy screen for an unowned machine that is for sale,
-- the manage screen for its owner or an admin, nothing for anyone else.
TriggerEvent('lottery:client:openMachine', { vendorId = 12 })Only while Config.Ownership.enabled is on.
vendorId is the machine's id — the number the creator shows as Edit Vendor #12 when you open it.
Server Events#
A prize was claimed
Fired on the server when a winning card is claimed at a machine, and whenever a card is finished in the phone app — a losing phone card reports an amount of 0. For Discord logs, achievements or a jackpot of your own.
AddEventHandler('lottery:internal:afterClaim', function(source, amount, slots, fromPhone)
-- source the player's server id
-- amount what the card paid
-- slots the six labels printed on the card, e.g. { 'NO WIN', '$10', ... }
-- fromPhone true for a card scratched in the phone app, nil at a machine
if amount >= 1000 then
print(('%s won $%s on the lottery'):format(GetPlayerName(source), amount))
end
end)Giving scratchcards from another script
A ticket is an ordinary item, so a reward, a daily login or a shop hands one out through your inventory or framework. It opens a card when used, like one bought at a machine.
exports.ox_inventory:AddItem(source, 'scratchcard', 1)local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addInventoryItem('scratchcard', 1)local Player = QBCore.Functions.GetPlayer(source)
Player.Functions.AddItem('scratchcard', 1)Phone Callbacks#
The Lottery app in Quasar Smartphone is built on five ox_lib callbacks. An app for another phone can call the same ones from its client. They are registered only while Config.Phone.enabled is on.
Callback | Takes | Returns |
|---|---|---|
| — |
|
|
|
|
| — |
|
| — |
|
| — |
|
local snapshot = lib.callback.await('lottery:phone:getSnapshot', false)
if snapshot.ok and snapshot.ticketCount == 0 then
lib.callback.await('lottery:phone:buyTicket', false, { quantity = 1 })
end
local card = lib.callback.await('lottery:phone:useTicket', false) -- consumes one scratchcard
if card.ok then
-- show card.slots and let the player scratch...
local result = lib.callback.await('lottery:phone:claimPrize', false)
-- result.won, result.amount
endAbout the Errors#
Every server answer that can refuse comes back as { ok = false, error = '<code>' } — not_enough_money, no_ticket, remote_purchase_disabled — and at a machine the player usually sees a notification in their own language as well. Log the code in your scripts; what each one means is in Common Errors → Error Codes.



