Forum C# Deleting players when they leave

Deleting players when they leave

Postby mfranzs » September 2nd, 2010, 7:15 pm

When a player leaves, I have my code send a message to all users to delete the player that left.

Code: Select all
public override void UserLeft(Player player)
        {   
            Broadcast("UserLeft", player.Id);
        }


But, when another user joins, the server side code still sends them the info for that player

Code: Select all

Message gamestate = Message.Create("GameState");
                foreach (Player guy in Players)
                {
                    gamestate.Add(DELETED INFO HERE);
                }
Broadcast(gamestate);//tell the player the current game state


How do i remove them from the Players array?

Thanks for your help :D
mfranzs
 
Posts: 98
Joined: August 29th, 2010, 3:27 am

Re: Deleting players when they leave

Postby Benjaminsen » September 3rd, 2010, 8:37 am

Users should automatically be removed from the Players collection. If your game behaves as you describe, thats most definitly a bug. Can you send me an example where this behavior occurs?

My email would be chris at player.io

/Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Deleting players when they leave

Postby mfranzs » September 3rd, 2010, 11:29 pm

Sure, thanks for your help
mfranzs
 
Posts: 98
Joined: August 29th, 2010, 3:27 am

Re: Deleting players when they leave

Postby mfranzs » September 4th, 2010, 12:21 am

Oops, my bad!

I just realized the problem was with my AS.

So, my fault and there is no bugs :D
mfranzs
 
Posts: 98
Joined: August 29th, 2010, 3:27 am


Return to C#



cron