A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: any experienced smartfox server user?

  1. #1
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389

    any experienced smartfox server user?

    Hello,

    I am a programming fan and I am trying to start a two team four player card game with smartfox server using its extensions to have it run from the server, but I have a very hard time finding the right information on the net and a lot harder finding any flash related books in the public libraries around here. If any, they are very outdated and will cover the very basics of Flash. I wonder if anyone can lend me a hand to get it started. I'm using one of the examples that come with the server and for now, all I want to do is set up the room for the first four players.

    So I have the connection, the association of the extension with the main file running but it behaves really awkwardly. The room will not be seen until the third try.

    I don't know obviously, but it doesn't seem like there is much to it. The main file communicates with the extension and it passes it the max amount of players to be in the room for the extension to take care of the internal events it receives every time a user joins that room. All I want to understand for the moment is setting up the room for the 4 players.

    I think this is where the extension sorts the incoming information and starts the game:


    Code:
    function handleInternalEvent(evt)
    {
    	evtName = evt.name;
    
    	if (evtName == "userJoin")
    	{
    		if (currentRoomId == undefined)
    		{
    			currentRoomId = evt["room"].getId();
    		}
    
    		u = evt["user"];
    
    		users[u.getUserId()] = u;
    
    		if (u.getPlayerIndex() != -1)
    		{
    			numPlayers++;
    			
    			trace("numPlayers = "+numPlayers);
    
    			if (u.getPlayerIndex() == 1)
    			{
    				p1id = u.getUserId();
    				trace("u.getPlayerIndex() = "+u.getPlayerIndex());
    				trace("p1.id = "+p1id);
    			} 
    			
    			else if(u.getPlayerIndex() == 2)
    			{
    				p2id = u.getUserId();
    				trace("u.getPlayerIndex() = "+u.getPlayerIndex());
    				trace("p2.id = "+p2id);
    			}
    			
    			else if(u.getPlayerIndex() == 3)
    			{
    				p4id = u.getUserId();
    			}
    			else
    			{
    				p4id = u.getUserId();
    			}
    
    			if (numPlayers == 4 && !gameStarted)
    			{
    				startGame();
    			}
    		}
    		else
    		{
    			updateSpectator(u);
    
    			if (endGameResponse != null)
    			{
    				_server.sendResponse(endGameResponse,currentRoomId,null,[u]);
    			}
    		}
    	}
    	else if (evtName == "userExit" || evtName == "userLost")
    	{
    		var uId = evt["userId"];
    
    		var oldPid = evt["oldPlayerIndex"];
    
    		var u = users[uId];
    
    		delete users[uId];
    
    		if (oldPid > 0)
    		{
    			numPlayers--;
    
    			gameStarted = false;
    
    			if (numPlayers > 0)
    			{
    				var res = {};
    				res._cmd = "stop";
    				res.n = u.getName();
    				_server.sendResponse(res, currentRoomId, null, users);
    			}
    		}
    	}
    I'm attaching both the main file and the extension associated to it in case anyone uses or tries smartfox as well. I have also posted at smartfox forums but I couldn't get my fla attached there so I thought I would try here. Thanks in advance for any replies. Will appreciate any advice even if it's a negative one to make me give up on trying.

  2. #2
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389
    Hi again, reattaching my files...

  3. #3
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389
    temporarilly resolved

  4. #4
    Member
    Join Date
    Apr 2014
    Posts
    51
    How was it? Is it up now? Got any links to share and see if the two team four player card game you created is running good on Smartfox Server user?

  5. #5
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389
    Terrible. Still stuck. Parked it aside for a while.

  6. #6
    Member
    Join Date
    Apr 2014
    Posts
    51
    Dude, have you tried posting your question to the Smartfox Server forum? They should give you the answer to your problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center