Page 1 of 1

Spectator problems

Posted: 14 Jul 2006, 22:31
by Xelius
I'm running a zone extension.
When a user enters a room as spectator, the userJoin event is fired and he is added to a user array.

Code: Select all

var u = evt["user"]
var rId = r.getId()
var rm = rl[rId] //array with the rooms
rm.users[u.getUserId()] = u
But when he leaves he dosn't get removed from the user array, because the userExit event isn't fired for spectators, which I think it should be.
If the user now creates a game of his own, he will still recieve the game moves from the room he was previously watching as spectator, which made my testers think there was a ghost player in the game. :lol:

Posted: 15 Jul 2006, 09:41
by Lapo
The event for spectators IS fired.
Check our PRO SFSTRIS tutorial (chap 8.8) ... the game handles both players and spectators.

If you scroll down to the event handler you will see this:

Code: Select all

var oldPid = evt["oldPlayerIndex"]
this is the playerID of the user in the room that he's just left
If this value == -1 then the user was a spectator

Hope it helps :)

Posted: 15 Jul 2006, 13:16
by Xelius
It sure was. I must have been really tired last night. :oops:
The ghosts are gone now, thanks. :)