Game Development Community

The -name command line operator for dedicated servers.

by Christopher Gardner · 06/28/2009 (4:46 am) · 2 comments

So, today I though, I've asked so many questions since I got here, it's time to give something back. This isn't a big humongus thing, but it works.

So this requires the editing of 3 script files:
scriptsAndAssests/main.cs
scriptsAndAssets/server/init.cs

Ok, so main.cs first
Add this to the end of the switch in the parse args function.
case "-name": //Case for the switch
            $argUsed[%i]++; //....
            if (%hasNextArg) { //If it has a next arg...
               $NameIsDone = 1; //New global variable
               $Pref::Server::Name = %nextArg; //Get the name of the server from the next argument
               $argUsed[%i+1]++; //.....
               %i++; //.....
            }
            else //Otherwise....
               error("Error: Missing Command Line argument. Usage: -name <name_of_Server>"); //ACKKKK!!! ERROR MESSAGE!
Now simply put the code below somewhere in the initDedicated() function
parseArgs();

Now simply launch a dedicated server like so:
YourGame.exe -dedicated -mission yourmission -name Your Server Name Here!

Goodbye

#1
06/28/2009 (6:09 am)
Tested in TGEA 1.8.1

If you did this earlier and modifided your game, you can remove the parts in default.cs, they are not needed anymore.
#2
07/24/2009 (5:07 pm)
also don't forget to add the lines in the help argument in the main.cs file
After this:
function displayHelp() {
   Parent::displayHelp();
   error(

Add this:
"  -name <name of server> For naming specific Server name\n"

Don't forget the put a @ after the last line of the previous help line also.