Difference between revisions of "Dedicated autostart.gm"

From King Arthur's Gold Wiki
Jump to: navigation, search
(Created page with "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_auto...")
 
m
 
(3 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
A simple dedicated_autostart.gm file would look like this:
 
A simple dedicated_autostart.gm file would look like this:
  
<syntaxhighlight lang="gml">
+
<syntaxhighlight lang="cpp" enclose="div">
 
newWorld( "" );
 
newWorld( "" );
 
switchGameState(0);
 
switchGameState(0);
Line 14: Line 14:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
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.
+
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 [[MapCycle.cfg|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:
 
Some people use a global var and the if/else switch to easily switch between gamemodes:
  
<syntaxhighlight lang="gml">
+
<syntaxhighlight lang="cpp" enclose="div">
 
global autostartswitch = 1;
 
global autostartswitch = 1;
 
newWorld( "" );
 
newWorld( "" );
Line 40: Line 40:
  
 
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.
 
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 =
 +
* [[Modding]]
 +
* [[Server]]
 +
* [[Dedicated autoconfig.gm]]
 +
* [[gamemode.cfg]]
 +
* [[MapCycle.cfg]]
 +
 +
[[Category:Modding]][[Category:Server]]

Latest revision as of 18:03, 5 August 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