# How do I make a lottery system?

Get help using Construct 2

### » Sun Sep 18, 2016 12:19 pm

I want to make a lottery system kind of like in the game Basketball where the player puts in a certain amount of tokens (in my case 1) then the system chooses one random item to give the player.
B
26
S
6
G
4
Posts: 173
Reputation: 3,968

### » Sun Sep 18, 2016 2:14 pm

Ayolabi12345 find your answer here

https://www.dropbox.com/sh/eioscti86bpr ... 7YPza?dl=0
B
262
S
49
G
15
Posts: 2,009
Reputation: 42,233

### » Sun Sep 18, 2016 4:28 pm

Lordshiva1948 wrote:Ayolabi12345 find your answer here

https://www.dropbox.com/sh/eioscti86bpr ... 7YPza?dl=0

this link does not work.
B
26
S
6
G
4
Posts: 173
Reputation: 3,968

### » Sun Sep 18, 2016 4:29 pm

Lordshiva1948 wrote:Ayolabi12345 find your answer here

https://www.dropbox.com/sh/eioscti86bpr ... 7YPza?dl=0

this link does not work.
B
26
S
6
G
4
Posts: 173
Reputation: 3,968

### » Mon Sep 19, 2016 12:57 am

This is one way to do it:
Add an instance variable to the items you will use as price.
Each item has a different Integer value starting at zero (e.g. t-shirt=0, baseball cap=1, shoes=2, etc.)
When the player inserts the token to play lottery use floor(random(n)) where n is the largest index
do a for each loop for the prize item and pick the item whose instance variable matches the one chosen by floor(random(n)).
B
29
S
10
G
10
Posts: 97
Reputation: 6,614

Return to How do I....?

### Who is online

Users browsing this forum: mekonbekon, zenox98 and 2 guests