Forum C# finding a player using userid

finding a player using userid

Postby carsonmorton » May 4th, 2012, 10:37 pm

this is my first forray into C# so please forgive my noobiness

how do can I send to a specific player? can I use their userid to find them in the Players list? I've been trying to find the answer via google and these forums, but I'm not finding anything.

I've tried Player[userid] but that doesn't work.
carsonmorton
 
Posts: 39
Joined: April 24th, 2012, 3:12 am

Re: finding a player using userid

Postby fox1980 » May 4th, 2012, 11:38 pm

iterate the Players collection until you find the one with the userid you want:

Code: Select all
foreach (Player pl in Players)
        if (pl.ConnectUserId == "userid") pl.Send("whatever");
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: finding a player using userid

Postby carsonmorton » May 7th, 2012, 5:15 pm

thank you fox!
carsonmorton
 
Posts: 39
Joined: April 24th, 2012, 3:12 am


Return to C#



cron