04.08.2015, 17:25
Код:
random( sizeof (ModeInfo) );
Make sure you run this as a Filterscripts otherwise it will not work as expected. (Check the comments in the code for more info)
Код:
#include <a_samp>
new changemodetimer, currentmode = 0;
enum smode
{
Mode[50],
Time
}
stock const ModeInfo[][smode] =
{
{"Gamemode 1", 300000}, //Make sure this ("Gamemode 1") is the first one in your server otherwise the sequence will be mixed
{"Gamemode 2", 300000},
{"Gamemode 3", 300000},
{"Gamemode 4", 300000}
};
public OnGameModeInit()
{
changemodetimer = SetTimer("switchmode", ModeInfo[currentmode][Time], false); //This timer will be started everytime a new Gamemode is loaded
return 1;
}
public OnGameModeExit()
{
KillTimer(changemodetimer); //This will prevent errors if you manually change the Gamemode
return 1;
}
forward switchmode();
public switchmode()
{
new modestring[50];
//This works like a loop, so when it reach the last Gamemode it will change to the first again
if(currentmode < sizeof(ModeInfo))
++currentmode;
else
currentmode = 0;
format(modestring, sizeof(modestring), "The Next mode will be %s!", ModeInfo[currentmode][Mode]);
SendClientMessageToAll(0x32CD32FF, modestring);
format(modestring,sizeof(modestring), "changemode %s", ModeInfo[currentmode][Mode]);
SendRconCommand(modestring);
return 1;
}

