Register for your free account! | Forgot your password?

You last visited: Today at 14:14

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Chose a random player

Discussion on Chose a random player within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
dodolinobobo's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 162
Received Thanks: 26
Chose a random player

Now i'm coding a event...but i need to do somethink for to get a Random Player, can i do this random think with a static List? or i must make a variable for every character?
dodolinobobo is offline  
Old 07/25/2010, 11:33   #2
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,223
Received Thanks: 867
Simple!
do something like
Code:
foreach(character C in Game.World._H.Values)
{
//Hmmmmm.......
random code.
}
_DreadNought_ is offline  
Old 07/25/2010, 12:00   #3
 
dodolinobobo's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 162
Received Thanks: 26
i know to do the "foreach part",but i don't know how to chose a random one from the list..
dodolinobobo is offline  
Old 07/25/2010, 12:04   #4
 
elite*gold: 0
Join Date: Sep 2008
Posts: 178
Received Thanks: 62
Quote:
Originally Posted by Eliminationn View Post
Simple!
do something like
Code:
foreach(character C in Game.World._H.Values)
{
//Hmmmmm.......
random code.
}
No comments...

You can do a list and make a random with that list.


List<string> Names = new List<string>();

Every time something join, Names.add(player);

And later,
Quote:
Random N = new Random();
int NumberSelected = N.Next(Names.Count);
But this gives you a number. You need the player.

You need: using System.Linq; for the next action.

string PlayerSelected = Names.ElementAt(NumberSelected);

Done.
.Kob is offline  
Thanks
1 User
Old 07/25/2010, 12:49   #5
 
dodolinobobo's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 162
Received Thanks: 26
thanks,i think i got it
dodolinobobo is offline  
Old 07/25/2010, 15:27   #6
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,223
Received Thanks: 867
Well for events, in my case I have a dictionary for them. When the player signs up they get added to it and if I need to do a random its very easy.
_DreadNought_ is offline  
Reply


Similar Threads Similar Threads
What server i should chose.
03/19/2009 - Metin2 Private Server - 2 Replies
Hello my friends. Can somebody say me what server is best to play? Expirence/Drop/Item shop. Please tell me what server i should chose to play, i mean Private servers. HOW i can register? Tell me this too.
Chose Imbue Hibryd Nuker
01/03/2009 - Silkroad Online - 6 Replies
Hello everyone! I decided i would be a 8:1 Hibryd Int Build lvl 90 Lightning lvl 90 Heuksal lvl 90 Ice lvl 30 Fire 1st Question: Do you guys thinks this is a good choise?
What to chose?!?!
03/09/2008 - Cabal Online - 7 Replies
Hey guys...i will be soon 95 and dunno what to choose.... Procyon or Capella...?!?!Thats the big question Procyon:many players but low lvls... Capella:few players but high levels... I want different opinions... P.S. If u add me to buddy-Server Mars-Channel14-BloodyIceD3vil



All times are GMT +2. The time now is 14:14.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.