Difference between revisions of "Dedicated autostart.gm"
From King Arthur's Gold Wiki
Splittingred (Talk | contribs) (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 (changed syntax highlight since GML != .gm) |
||
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=" | + | <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=" | + | <syntaxhighlight lang="cpp" enclose="div"> |
global autostartswitch = 1; | global autostartswitch = 1; | ||
newWorld( "" ); | newWorld( "" ); |
Revision as of 10:36, 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`);
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`);
}
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.