22.06.2012, 05:06
One minor thing you could do to optimize your code is use a switch statement.
Example with your code.
Much more powerful than the if structure, and easier to read. I recommend you to look at that link. It tells you every thing about switch statements.
Example with your code.
pawn Код:
switch(CurrentGamemode)
{
// If Current Gamemode is equal to the value after "case" then it runs that code
// So on and so forth.
case 0:
{
ServerMinutes = 0;
ServerSeconds = 10;
CurrentGamemode++; // adds one for the next time you call ChangeMode or w/e
}
case 1:
{
ServerMinutes = 0;
ServerSeconds = 10;
CurrentGamemode++;
}
case 2:
{
ServerMinutes = 0;
ServerSeconds = 10;
CurrentGamemode++;
}
case 3:
{
ServerMinutes = 0;
ServerSeconds = 10;
CurrentGamemode++;
}
case 4:
{
ServerMinutes = 0;
ServerSeconds = 10;
CurrentGamemode++;
}
case 5:
{
ServerMinutes = 0;
ServerSeconds = 10;
// if we've reached the final mode
// we reset it to zero.
CurrentGamemode = 0;
}
}