# RedStudio - red-lottery
`red-lottery` is a VORP lottery script for RedM with:
- 50-number pool
- 6-number ticket selection
- hourly automated draws
- unique draw codes
- NUI with countdown, promo banner, and last draw display
## Main Features
- Buy tickets from lottery NPC(s)
- Select exactly `6` unique numbers from `1..50`
- Hourly draw generation with offline catch-up
- Draw announce in chat + console
- Unique draw code format: `RL-YYYYMMDD-HHMM`
- NUI includes:
- countdown to next draw
- promo message strip (configurable)
- `Last Draw` block (code + extracted numbers)
- `Check Tickets` button
- Tickets are inventory items (`lotteryticket`) with metadata
- Ticket item DB entry can be auto-created/updated (weight included)
- Verify via item use or NUI button
- Verified tickets are consumed by default
## Dependencies
- `vorp_core`
- `vorp_inventory`
- `oxmysql`
## Installation
1. Place folder in:
- `resources/[redstudio]/red-lottery`
2. Ensure dependency order in `server.cfg` (dependencies first):
```cfg
ensure vorp_core
ensure vorp_inventory
ensure oxmysql
ensure red-lottery
```
3. Restart resource or server:
```cfg
restart red-lottery
```
## Database
Tables are auto-created on resource start:
- `red_lottery_draws`
- `red_lottery_tickets`
The script also auto-checks schema and upgrades `draw_date` to `DATETIME` if needed.
Manual SQL files:
- `sql/install.sql`
- `sql/items.sql`
## Player Flow
1. Go to lottery vendor.
2. Open menu and choose 6 numbers.
3. Buy ticket.
4. Wait for draw.
5. Verify ticket using:
- inventory item (`lotteryticket`), or
- NUI `Check Tickets` button.
Default behavior:
- `consumeTicketOnVerify = true` -> ticket is removed after valid verification (draw exists).
- With current defaults, winning ticket verification also pays automatically.
## Configuration
Everything is in `config.lua`.
Important blocks:
`Config.Starts` / `Config.Start`: vendor locations
- `Config.Lottery`:
- `poolSize` (`50`)
- `numbersPerTicket` (`6`)
- `ticketPrice`
- `drawIntervalSeconds` (`3600`)
- `consumeTicketOnVerify`
- `autoClaimOnUse`
- `announceDrawInChat`
- `payoutByMatches`
- `Config.Database`:
- `itemName`
- `itemWeight`
- `ensureItemInDb`
- `Config.Security`:
- anti-spam + vendor distance validation
- `Config.Admin`:
- ace permission for admin commands
- `Config.Locale.ui.promoLines`:
- promo lines with placeholders:
- `{maxPayout}`
- `{ticketPrice}`
- `{numbersPerTicket}`
## Admin Commands
- `redlottery_drawinfo`
- current draw status, next draw, pending count
- `redlottery_drawnow`
- forces current draw and resolves pending rows
ACE example:
```cfg
add_ace group.admin redstudio.lottery allow
```
## Notes
- Last draw data shown in NUI is the most recent completed draw from DB.
- Draw code is also stored in ticket metadata.
- Keep `config.lua` public if you encrypt server/client Lua files.
Video :The MOST PROFITABLE RedM Lottery Script Ever Made
Discord : https://discord.gg/fYpXSYSqj6