Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Making a lottery system

Hey guys! This is my first tutorial here, so cut me some slack. Now, the other day, while i was developing my life game, i thought of putting in a lottery sytem, so that the player could win some money somehow. So here's how...

For this tutorial, you will need:
6 variables
1 common event
1 item slot

Firstly, open up the database and click on the items tab. There, you need to create a new item. Give it a name of lottery ticket, and whatever graphic you want. (I used no.40-the card.) Then, put the occasion as only from the menu. Then, set the common event to no.1. Then set the price to whatever you like. (I put 5 pounds.).

Next, go onto your common events page, and name your 6 variables:
Lottery 1
Lottery 2
Lottery 3
Winner 1
Winner 2
Winner 3
Then name the first common event, Lottery ticket. Then, put in the following things...
@>Control Variables : [0001: Lottery 1] = Random No. (1...9)
@>Control Variables : [0002: Lottery 2] = Random No. (1...9)
@>Control Variables : [0003: Lottery 3] = Random No. (1...9)
@>Text: Your lottery number is \v[001]\v[002]\v[003].
@>Would you like to find out if you've won the lottery?
@> Show choices: Yes, No
:When [Yes]
@>Control Variables : [0004: Winner 1] = Random No. (1...9)
@>Control Variables : [0005: Winner 2] = Random No. (1...9)
@>Control Variables : [0006: Winner 3] = Random No. (1...9)
@>The winning Lottery numbers are...\v[004]\v[005]\v[006]
@>Conditional Branch: Variable [0001: Lottery 1] == Variable [0004: Winner 1]
@>Conditional Branch: Variable [0001: Lottery 1] == Variable [0004: Winner 1]
@>Conditional Branch: Variable [0001: Lottery 1] == Variable [0004: Winner 1]
@>Text:Congratulations! You have won the jackpot! £20,000
: :is yours!
@> Change gold: + 20000
@>
: Else
@>Text: Congratulations! You have won £5000!
@>Change Gold: + 5000
@>
: Branch End
@>
: Else
@>Text: Congratulations! You have won £100!
@>Change Gold: + 100
@>
: Branch End
@>
: Else
@>Text: Sorry, You haven't won anything this time.
@>
: Branch End
@>Control Variables : [0001: Lottery 1] = 0
@>Control Variables : [0001: Lottery 2] = 0
@>Control Variables : [0001: Lottery 3] = 0
@>Control Variables : [0001: Winner 1] = 0
@>Control Variables : [0001: Winner 2] = 0
@>Control Variables : [0001: Winner 3] = 0
@>
: When [No]
@>
: Branch End
@>

So basically, all that does is tell the variables Lottery 1, 2 and 3 to assign themselves as a random number from 1-9, thus giving us a lottery number of Lottery 1, Lottery 2, Lottery 3.

Then It tells the varibales Winner 1, 2 and 3 to assign themselves as random variables again. This gives us the winning combination of Winner 1, Winner 2, and winner 3.

So I hear you asking, why didnt he just put the lottery ticket as a random variable from 1-999? Well, That is because when you play the lottery, if you match just 1 or 2 of the numbers, you win a prize. So therefor, if Lottery 1 is equal to Winner 1, you get a prize and a chance to win more. You get my train of thought?

And then lastly, you change all the variables to 0 so that on the next time you play, the variables dont get all mixed up and annoying.

So there you have it. If you wanted, you could make a common event so that you could only use the ticket once a week, (if you have a day and night system) and so on. So thanks for reading and happy gaming!

If you have any questions about the Tutorial, please don't hesitate to ask me. I'm willing to help you know! Cheers
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top