Mode Changes Automatically in Sequence
#8

Код:
random( sizeof (ModeInfo) );
You can't use "random" if you want it to run in sequence.

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;
}
Reply


Messages In This Thread
Mode Changes Automatically in Sequence - by SpikY_ - 04.08.2015, 11:46
Re: Mode Changes Automatically in Sequence - by SpikY_ - 04.08.2015, 12:30
Re: Mode Changes Automatically in Sequence - by Krokett - 04.08.2015, 12:43
Re: Mode Changes Automatically in Sequence - by SpikY_ - 04.08.2015, 12:46
Re: Mode Changes Automatically in Sequence - by Crayder - 04.08.2015, 12:49
Re: Mode Changes Automatically in Sequence - by SpikY_ - 04.08.2015, 13:01
Re: Mode Changes Automatically in Sequence - by SpikY_ - 04.08.2015, 15:27
Re: Mode Changes Automatically in Sequence - by goldspy98 - 04.08.2015, 17:25
Re: Mode Changes Automatically in Sequence - by Inn0cent - 04.08.2015, 17:36
Re: Mode Changes Automatically in Sequence - by SpikY_ - 04.08.2015, 17:52

Forum Jump:


Users browsing this thread: 1 Guest(s)