Spectator problems

You think you've found a bug? Please report it here.

Moderators: Lapo, Bax

Post Reply
Xelius
Posts: 70
Joined: 06 Apr 2006, 15:16
Location: Sweden

Spectator problems

Post 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:
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post 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 :)
Lapo
--
gotoAndPlay()
...addicted to flash games
Xelius
Posts: 70
Joined: 06 Apr 2006, 15:16
Location: Sweden

Post by Xelius »

It sure was. I must have been really tired last night. :oops:
The ghosts are gone now, thanks. :)
Post Reply