PDA

View Full Version : Shared Variables


Kujira
07-16-2005, 04:18 PM
I'm am currently working on a multiplayer game.

What i am trying to do is that for each player that connects to the game, i will assign that player a unique id. (first player is 0, second player is 1 and so on)

This is what i am doing now
Flash Comm sharing:

comm_game = SharedObject.getRemote("game", client_nc.uri, false);
comm_game.onSync = function(list) {
noPlayers = comm_game.data.noPlayers;
}


Actionscript:

playerId = comm_game.data.noPlayers;
comm_game.data.noPlayers++;


But when I run the programs, what happens is that everyone who connects gets the Id 0.

If anyone knows the problem with my code, or knows a better way to do this, please tell me. Thanks in advance