[HELP]dont display the gameroom name if the game is started
[HELP]dont display the gameroom name if the game is started
pls someone hepl about this,,,
what i did here was when someone enter the game room and the owner of the game room click the start button will send a roomVariable name:"startgame" val:"ok"
after that i custumized the code on the chat frame where
if(room.isGame()){
if(room.getVariable("startgame")!="ok") // so if the startgame is ok the roomname will not added
{
roomList.addItem(room.getName(),room.getId());
}
}
but still it did not work,, the room is still displaying on the roomlist
please help me
what i did here was when someone enter the game room and the owner of the game room click the start button will send a roomVariable name:"startgame" val:"ok"
after that i custumized the code on the chat frame where
if(room.isGame()){
if(room.getVariable("startgame")!="ok") // so if the startgame is ok the roomname will not added
{
roomList.addItem(room.getName(),room.getId());
}
}
but still it did not work,, the room is still displaying on the roomlist
please help me
yah,, i already tried it,,
it works only to the when
the other player login after a certain game room is started
to make it easier to explain,i have two timeline naming "chat" and "lobby"
the "chat" timeline is where displays the roomlist
the "lobby" timeline is where the players go when they join a certain room and set the roomvariable("startgame")=ok;
here is my code on the onroomlistupdate which is place at "chat" timeline
smartfox.onRoomListUpdate = function(roomList:Object) {
roomID = new Array();
roomName = new Array();
roomCount = new Array();
for (var i:String in roomList)
{
var room:Room = roomList;
if (room.isGame()) {
if(room.getVariable("startgame")!="ok")
{
roomID.push(room.getId());
roomName.push(room.getName());
roomCount.push(room.getUserCount());
}
}
}
displayRoomlist();
this.joinRoom("Scrabble Global Chatroom","");
};
as i say it works only to the player who is newly login
maybe the solution here is when i start the game
i should not only set the roomvariable(startgame)=ok
but also write a code that notify all the users to update their roomlist
my problem is how it can be done?,,,
it works only to the when
the other player login after a certain game room is started
to make it easier to explain,i have two timeline naming "chat" and "lobby"
the "chat" timeline is where displays the roomlist
the "lobby" timeline is where the players go when they join a certain room and set the roomvariable("startgame")=ok;
here is my code on the onroomlistupdate which is place at "chat" timeline
smartfox.onRoomListUpdate = function(roomList:Object) {
roomID = new Array();
roomName = new Array();
roomCount = new Array();
for (var i:String in roomList)
{
var room:Room = roomList;
if (room.isGame()) {
if(room.getVariable("startgame")!="ok")
{
roomID.push(room.getId());
roomName.push(room.getName());
roomCount.push(room.getUserCount());
}
}
}
displayRoomlist();
this.joinRoom("Scrabble Global Chatroom","");
};
as i say it works only to the player who is newly login
maybe the solution here is when i start the game
i should not only set the roomvariable(startgame)=ok
but also write a code that notify all the users to update their roomlist
my problem is how it can be done?,,,
- Carl Lydon
- Posts: 298
- Joined: 12 Nov 2007, 16:15
- Location: NYC
If that variable "startgame" is set by the first player, maybe that makes sense that so the second player sees that as true but not the first, depending on where in the code this happens. A variable can only be set once you've already entered the room, so you may not want that conditional for the first player.
It might also be that if your first player sends some object to the room, it will not receive that message back to himself.
To force all users to do something, use sendObject.
As3 example:
It might also be that if your first player sends some object to the room, it will not receive that message back to himself.
To force all users to do something, use sendObject.
As3 example:
Code: Select all
//
public function sendCommandAll (Subj,Data):void {
var lobj:Object=new Object;
lobj.Subj=Subj;
lobj.Data=Data;
smartFox.sendObject (lobj);
}
//
private function sendCommandUser (Subj,Data,lUser):void {
var lobj:Object=new Object;
lobj.Subj=Subj;
lobj.Data=Data;
var userL:Array=[lUser];
smartFox.sendObjectToGroup (lobj,userL);
}Code: Select all
- Carl Lydon
- Posts: 298
- Joined: 12 Nov 2007, 16:15
- Location: NYC
- Carl Lydon
- Posts: 298
- Joined: 12 Nov 2007, 16:15
- Location: NYC
try sendObject, with the optional room id to specify which room sending object to.
var obj:object = {}
obj.command = "yourCommand"
obj.data = yourData
roomId:int = idNumberOfRoomToSendTo
smartFox.sendObject (obj, roomId);
Or, you can use sendObjectToGroup
The following example shows how to send a simple object with primitive data to two users.
(The 2 numbers in array represent the id numbers of your target users)
var move:Object = new Object()
move.x = 150
move.y = 250
move.speed = 8
smartFox.sendObjectToGroup(move, [11, 12])
var obj:object = {}
obj.command = "yourCommand"
obj.data = yourData
roomId:int = idNumberOfRoomToSendTo
smartFox.sendObject (obj, roomId);
Or, you can use sendObjectToGroup
The following example shows how to send a simple object with primitive data to two users.
(The 2 numbers in array represent the id numbers of your target users)
var move:Object = new Object()
move.x = 150
move.y = 250
move.speed = 8
smartFox.sendObjectToGroup(move, [11, 12])