Difference between revisions of "Dedicated autostart.gm"

From King Arthur's Gold Wiki
Jump to: navigation, search
Line 45: Line 45:
 
* [[Server]]
 
* [[Server]]
 
* [[gamemode.cfg]]
 
* [[gamemode.cfg]]
* [[mapcycle.cfg]]
+
* [[MapCycle.cfg]]
  
 
[[Category:Modding]][[Category:Server]]
 
[[Category:Modding]][[Category:Server]]

Revision as of 15:31, 8 January 2013

Located in Base/Scripts/, this is the file KAG uses to "initialize" the server. It is usually modified to enable different gamemodes based upon a global.

A simple dedicated_autostart.gm file would look like this:

newWorld( "" );
switchGameState(0);
startServer();

LoadRules("Rules/TDM/gamemode.cfg");
LoadMapCycle( "Scripts/mapcycle.cfg" );
LoadMap( "" );
print(`Loaded TDM default config`);

This loads a new world for the server, switches the game state to 0 (it is unknown what the flag is, but changing it does nothing), loads the Map Cycle, and then loads the Map. Print simply echoes out to the log file/console.

Some people use a global var and the if/else switch to easily switch between gamemodes:

global autostartswitch = 1;
newWorld( "" );
switchGameState(0);
startServer(); 
if (autostartswitch == 0) //ctf
{
        LoadRules("Rules/CTF/gamemode.cfg");
        LoadMapCycle( "Scripts/mapcycle.cfg" );
        LoadMap( "" );
        print(`Loaded CTF default config`);
}
else if (autostartswitch == 1) //tdm
{
        LoadRules("Rules/TDM/gamemode.cfg");
        LoadMapCycle( "Scripts/mapcycle.cfg" );
        LoadMap( "" );
        print(`Loaded TDM default config`);
}

Note the global setting the variable to 1, and then the if/elseif that tells KAG to load the TDM gamemode, since "autostartswitch" is set to 1.

See also