Page 1 of 1

[HELP]dont display the gameroom name if the game is started

Posted: 07 Jan 2011, 22:02
by kaloy12
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

Posted: 09 Jan 2011, 07:50
by kaloy12
hmmm ... so it seem no ones gonna help me

Posted: 11 Jan 2011, 03:52
by kaloy12
pls help me...!!!!!!

Posted: 12 Jan 2011, 14:45
by kaloy12
many views but no one answers,, even bigfish or lapo didnt,

is this a server side code?,,

how can i notify the other client when the room.getVariable("startgame")==ok?

pls help me

Posted: 12 Jan 2011, 14:52
by Rutter
Have you tried a trace statement to ensure that your variable contains what you think it should? I have often found that what I think is there isn't. :(

Posted: 12 Jan 2011, 21:39
by kaloy12
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?,,,

Posted: 13 Jan 2011, 00:28
by Carl Lydon
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:

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);
		}

Posted: 13 Jan 2011, 04:59
by kaloy12
but i want to send the object to the chatroom not to a game room..

i thougth when i send an object,, it only receive ti the players which are currently on the same room with the sender,,,

is it possible to send the object to a certain room?

Posted: 13 Jan 2011, 16:12
by Carl Lydon
Yea. I think you can be joined to two rooms at once, so maybe if you just populate the uselist with people from the 2nd room, that would work.

The way I would do it though, is to send a message to your zone extension, which can then send it along to any other room you want.

Posted: 14 Jan 2011, 03:33
by kaloy12
but particular code i should use?

Posted: 14 Jan 2011, 17:27
by Carl Lydon
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])