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

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
kaloy12
Posts: 26
Joined: 20 Nov 2010, 23:39
Location: PH

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

Post 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
kaloy12
Posts: 26
Joined: 20 Nov 2010, 23:39
Location: PH

Post by kaloy12 »

hmmm ... so it seem no ones gonna help me
kaloy12
Posts: 26
Joined: 20 Nov 2010, 23:39
Location: PH

Post by kaloy12 »

pls help me...!!!!!!
kaloy12
Posts: 26
Joined: 20 Nov 2010, 23:39
Location: PH

Post 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
Rutter
Posts: 99
Joined: 12 Dec 2007, 16:21
Location: Canada
Contact:

Post 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. :(
kaloy12
Posts: 26
Joined: 20 Nov 2010, 23:39
Location: PH

Post 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?,,,
User avatar
Carl Lydon
Posts: 298
Joined: 12 Nov 2007, 16:15
Location: NYC

Post 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);
		}
kaloy12
Posts: 26
Joined: 20 Nov 2010, 23:39
Location: PH

Post 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?
User avatar
Carl Lydon
Posts: 298
Joined: 12 Nov 2007, 16:15
Location: NYC

Post 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.
kaloy12
Posts: 26
Joined: 20 Nov 2010, 23:39
Location: PH

Post by kaloy12 »

but particular code i should use?
User avatar
Carl Lydon
Posts: 298
Joined: 12 Nov 2007, 16:15
Location: NYC

Post 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])
Post Reply