Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2016-04-05 14:34:55

PATRIK
Member
From: Czech Republic
Joined: 2015-02-20
Posts: 57

Help someone :)

Hello guys i just have problem with making random system. Based on choosing 1 random player from my listbox how do i make that ? thx //forums.everybodyedits.com/img/smilies/smile


QvDTHaA.png
pkpSoTa.png
gF3kMbs.png
l1skAPB.png
                                                ^ Made by Bobithan thx. ^

Offline

#2 2016-04-05 15:31:39

SmittyW
Member
Joined: 2015-03-13
Posts: 2,085

Re: Help someone :)

Create a Random object

Random rnd = new Random();

Then use it in your list index to select a random player item

playerlist[rnd.Next(0, playerlist.Count)]

Offline

#3 2016-04-05 15:47:16

den3107
Member
From: Netherlands
Joined: 2015-04-24
Posts: 1,025

Re: Help someone :)

Notice on that: Don't make a random object just to use it right after.
Why? Because it will then always return the same value, which isn't very random, is it?

Preferable make the random object somewhere at the start of the method or in the constructor. Just some up front from when you use it.

Offline

Wooted by:

#4 2016-04-05 20:21:20

Tomahawk
Forum Mod
From: UK
Joined: 2015-02-18
Posts: 2,847

Re: Help someone :)


One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.

Offline

Tomahawk1459884080593762

Board footer

Powered by FluxBB

[ Started around 1732251570.1376 - Generated in 0.059 seconds, 12 queries executed - Memory usage: 1.39 MiB (Peak: 1.49 MiB) ]