How to return to Gamemode 0, after it goes through all the modes?
#3

One minor thing you could do to optimize your code is use a switch statement.

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


Messages In This Thread
How to return to Gamemode 0, after it goes through all the modes? - by rangerxxll - 22.06.2012, 04:29
Re: How to return to Gamemode 0, after it goes through all the modes? - by [MM]RoXoR[FS] - 22.06.2012, 04:53
Re: How to return to Gamemode 0, after it goes through all the modes? - by ReneG - 22.06.2012, 05:06
Re: How to return to Gamemode 0, after it goes through all the modes? - by rangerxxll - 22.06.2012, 05:30

Forum Jump:


Users browsing this thread: 1 Guest(s)