Altitude Game: Forums  

Go Back   Altitude Game: Forums > Altitude Support > Dedicated Server
FAQ Community Calendar

Dedicated Server Discuss technical issues related to hosting your own servers.

Reply
 
Thread Tools Display Modes
  #1  
Old 11-07-2010, 12:16 PM
Bockit Bockit is offline
Junior Member
 
Join Date: Sep 2010
Posts: 15
Default Spectator slots

Just a quick question about server configuration and spectators. Is there a way to configure the server so that it can be x slots (say, 20) and but of those only 10 are playable slots?

I did some searching on the forum and didn't have much luck, best I could find was a mention that someone can /assign someone to spectator? Is this handleable from just the server side?
Reply With Quote
  #2  
Old 11-07-2010, 03:34 PM
Pieface Pieface is offline
Super Moderator
 
Join Date: Aug 2009
Posts: 1,265
Default

There aren't specified spectator as opposed to player slots at the moment, but admins can /assignTeam a player to make them spectate and /startTournament to stop players from being able to join a team unless they were already on it.
Reply With Quote
  #3  
Old 11-08-2010, 09:59 PM
phong phong is offline
Senior Member
 
Join Date: Jul 2009
Location: Chicago
Posts: 372
Default

This can be handled server side with a parser such as PALP or similar. Basically a simple function on teamchange (so within the current function in PALP), to check the current amount of players in game and spectate someone if it is over a certain value.

Basically just query the database for how many users current connected to the server port, and take that value - number of people connected with the spectator team value (-1 or 2, can't remember).

It's easier to do it backwards like that since the team/color value can change depending on map/type.

You'd also probably want to add a global variable to enable/disable the limit to certain servers.

Last edited by phong; 11-08-2010 at 10:13 PM.
Reply With Quote
  #4  
Old 11-09-2010, 12:56 AM
Bockit Bockit is offline
Junior Member
 
Join Date: Sep 2010
Posts: 15
Default

Thanks very much for the help both of you, I think I'll be going with Phong's suggestion.
Reply With Quote
  #5  
Old 11-09-2010, 02:22 AM
phong phong is offline
Senior Member
 
Join Date: Jul 2009
Location: Chicago
Posts: 372
Default

I started to build this idea into palp this afternoon, should be done tomorrow. Not sure why I didn't do it before
Reply With Quote
  #6  
Old 11-09-2010, 03:53 AM
Bockit Bockit is offline
Junior Member
 
Join Date: Sep 2010
Posts: 15
Default

Many, many thanks for that
Reply With Quote
  #7  
Old 11-09-2010, 04:06 AM
phong phong is offline
Senior Member
 
Join Date: Jul 2009
Location: Chicago
Posts: 372
Default

I tested out some junk code and it worked ok, but there is alot of team change flooding since people are spamming to get in (and getting put back in spec).

Also, I noticed when there was 5-6 people trying to get in at once it flaked out and sql didn't update the team changes correctly (spectator is a team), but I'll put the code up later so you have something to start with.
Reply With Quote
  #8  
Old 11-09-2010, 01:58 PM
phong phong is offline
Senior Member
 
Join Date: Jul 2009
Location: Chicago
Posts: 372
Default

This is what I came up with. Here is the updated teamchange function in palp, you can just replace the entire function between the //Start teamchange and //End teamchange.

I still think the bug that happens when several people are spamming teamchanges when the server is full is due to buffering of the altitude log or the way I'm parsing the log. For the most part this works but needs to be tested more.

Also, if the server_players table gets out of wack for some reason, say palp was stopped while a server was active, the table needs to be flushed or the server restarted while palp is running otherwise the server will think there are active players when there are not.

Code:
#  palp.php teamchange function
// Start teamchange function
function parse_teamchange($obj) {
	
	# Check server_players to see if player exists
     $sql = "
	SELECT
		*
	FROM
		server_players
	WHERE
		p_port='" .$obj->port. "'
	AND
		p_id='" .$obj->player. "'
	LIMIT 1
	";

	$query = mysql_query($sql);
     $num_rows = mysql_num_rows($query);

     if ($num_rows) {
		
          # Player exists, process teamchange
          if ($GLOBALS['debug']) { echo "PALP: Parsing " .$obj->port. " player " .$obj->player. " teamchange to " .$obj->team. " \n"; }

          $sql = "
          UPDATE
               server_players
          SET
               p_team='" .$obj->team. "'
          WHERE
               p_port='" .$obj->port. "'
          AND
               p_id='" .$obj->player. "'
          ";
		
          $result = mysql_query($sql);
    
          # Reset server check
          $check_maxplayers = false;
		
          # Process maxplayers array from palp.ini and see if this server has maxplayers configured
		foreach ($GLOBALS['maxplayers'] as $m1) {
               if ("$obj->port"=="$m1[0]") { 
                    $check_maxplayers = true;  
                    $max_players = "$m1[1]";
               }
          }
		
		# If server does have maxplayers enabled, check each teamchange to ensure server is not full
          if ($check_maxplayers) {
		
               if ($GLOBALS['debug']) { echo "PALP: Checking " .$obj->port. " if player " .$obj->player. " should be spectated for max users. \n"; }

               # SQL statement for total players current on
               $t_players_sql = "
               SELECT
                    *
               FROM
                    server_players
               WHERE
                    p_port='" .$obj->port. "'
               ";
                
               # SQL statement for total spectators on
               $s_players_sql = "
               SELECT
                    *
               FROM
                    server_players
               WHERE
                    p_port='" .$obj->port. "'
               AND
                    p_team='2'
               ";     
              
               # Calculate active players in game based on total number of players - total number of spectators
               $active_players = mysql_num_rows(mysql_query($t_players_sql)) - mysql_num_rows(mysql_query($s_players_sql));
              
               # Debug statement for testing
               if ($GLOBALS['debug']) { echo "PALP: Server " .$obj->port. " is (" .$active_players. " of " .$max_players. "). \n"; }
              
               # Get player and server information
               while ($row = mysql_fetch_assoc($query)) {
                
                    #  If active players is over maxplayers limit spectate them and send a message
                    if ("$active_players" > "$max_players") {
                         
                         # Debug message
                         if ($GLOBALS['debug']) { echo "PALP: Server " .$obj->port. " is at maximum players (" .$active_players. " of " .$max_players. ").  Spectating player " .$obj->player. ". \n"; }

                         #Send server full message
                         send_command("$obj->port,console,serverWhisper \"" . addslashes($row['p_nickname']) . "\" You've been spectated as the server is currently full (" .$active_players. " of " .$max_players. ").");
                         
                         # Put player on spectate team and update team in database
                         send_command("$obj->port,console,assignTeam \"" . addslashes($row['p_nickname']) . "\" -1");	
                  
                         # Update player team
                         $spec_sql = "
                         UPDATE
                              server_players
                         SET
                              p_team='2'
                         WHERE
                              p_port='" .$obj->port. "'
                         AND
                              p_id='" .$obj->player. "'
                         ";
		
                         $result = mysql_query($spec_sql);
                               
                    }  
               }
          }
     }
}
// End teamchange function
And the array I added to the bottom of palp.inc to set the maxplayers per server (enable or disable)

Code:
# palp.inc

// Max players (allows for spectator slots)
// Example to limit 10 active players on server port 50006: $maxplayers = array(array('50006','10'));

$maxplayers = array(

  array('50011','10')
  
);
global $maxplayers;

Last edited by phong; 11-09-2010 at 02:01 PM.
Reply With Quote
  #9  
Old 11-09-2010, 02:04 PM
phong phong is offline
Senior Member
 
Join Date: Jul 2009
Location: Chicago
Posts: 372
Default

btw this is running on "Ohjeah! 5v5 with Spectators" if you want to get 10 people to test it
Reply With Quote
  #10  
Old 11-09-2010, 02:27 PM
phong phong is offline
Senior Member
 
Join Date: Jul 2009
Location: Chicago
Posts: 372
Default

Also, I'm really not sure why this can't be added quickly on the server side :/

The server obviously knows how many people are connected and I'm sure it could track the number of spectators. If it was added server side then it would clean up the team change spamming etc. This has been a long requested feature though so probably not anytime soon.
Reply With Quote
  #11  
Old 11-09-2010, 09:49 PM
Bockit Bockit is offline
Junior Member
 
Join Date: Sep 2010
Posts: 15
Default

Thanks so much for doing this. I'll try it out if not tonight, but definitely tomorrow. You just made the league I'm trying to set up for Australasian players that much more awesome.

EDIT: I agree it should be handleable from the server config, but since it's not and you've managed to do it anyway, I'm happy to use this solution.
Reply With Quote
  #12  
Old 11-10-2010, 03:24 AM
phong phong is offline
Senior Member
 
Join Date: Jul 2009
Location: Chicago
Posts: 372
Default

Still needs alot of testing and tweaks..
Reply With Quote
  #13  
Old 11-14-2010, 05:39 AM
|HF|Binarian |HF|Binarian is offline
Senior Member
 
Join Date: Oct 2010
Location: RIT
Posts: 122
Default

Ill also implement this in JALP. Quite a good idea.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:02 AM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
2008 Nimbly Games LLC