lottery
Players can buy tickets for a lottery, and the winner is chosen at random.
Commands
- /buyTicket - Buy a lottery ticket.
- /viewTickets - View your lottery tickets.
- /nextDraw - View when the next draw is.
Cron Jobs
- drawLottery - Temporal Value: 0 0 * * *
Config variables
- profitMargin number - The profit margin the server takes from the lottery.
Overview
The lottery system works by:
- Players can purchase tickets using server currency
- A scheduled draw determines winners automatically
- Winners receive a prize pool based on ticket sales
- Configurable profit margin for the server
- Daily automated draws
Commands
Command | Description | Arguments |
---|---|---|
/buyTicket | Purchase lottery tickets | amount : Number of tickets to buy |
/viewTickets | View your currently held tickets | None |
/nextDraw | Check when the next lottery draw will occur | None |
Permissions
The module includes two main permissions that can be assigned to roles:
- LOTTERY_BUY: Allows players to purchase lottery tickets
- LOTTERY_VIEW_TICKETS: Allows players to view their currently held tickets
Configuration
Module Settings
Setting | Description | Default |
---|---|---|
profitMargin | Percentage of ticket sales kept by the server (0-1) | 0.1 (10%) |
System Configuration
The lottery draw is scheduled using a cron job that runs at 0 0 * * *
(midnight every day).
How It Works
- Ticket Purchase:
- Players use the
/buyTicket
command to purchase tickets - Each ticket costs a configurable amount of currency
- Players can purchase multiple tickets at once
- Tickets are tracked per player until the next draw
- Players use the
- Prize Pool:
- Total prize pool = (Total ticket sales) * (1 - profit margin)
- Server keeps the profit margin percentage
- The remaining amount goes to the winner
- Draw Process:
- Occurs automatically at configured time
- One winner is randomly selected from all ticket holders
- More tickets = higher chance of winning
- Prize is automatically distributed to winner
- All tickets are cleared after each draw
- Safeguards:
- Lottery cancels if only one player bought tickets
- Players receive refunds if lottery is cancelled
- Server announces winner and prize amount to all players
Setup Guide
- Install the Module:
- Navigate to your server's Modules section
- Find "lottery" in the module list
- Click Install
- Configure the profit margin as desired
- Configure Permissions:
- Go to Roles section
- Assign LOTTERY_BUY and LOTTERY_VIEW_TICKETS permissions to appropriate roles
- Set any cost requirements for permissions if desired
- Verify Installation:
- Check that commands are working using
/help lottery
- Ensure draw schedule is active by using
/nextDraw
- Test ticket purchase with
/buyTicket 1
- Check that commands are working using
Best Practices
- Economy Balance:
- Set appropriate ticket costs based on your server's economy
- Adjust profit margin to control prize pool sizes
- Monitor ticket sales and adjust parameters as needed
- Player Communication:
- Announce lottery events in advance
- Use server messages to remind players about upcoming draws
- Celebrate winners to encourage participation
- Permission Management:
- Consider creating specific lottery roles
- Use permission costs to prevent abuse
- Monitor for unusual buying patterns
Troubleshooting
Players can't buy tickets:
- Verify LOTTERY_BUY permission is assigned
- Check if player has sufficient currency
- Ensure economy system is enabled
Notes
- Tickets do not persist between draws
- Players must be online to receive win notifications
- The module requires an active economy system
- All transactions are logged for administrative review