Establish Match/Turn/Round system in gamemode
#1

Ahoy friends.
Currently im trying to improve my gamemode https://sampforum.blast.hk/showthread.php?tid=629023.
Currently there are at least 3 teams and i want to get a round system to start and finish a round.
There have to be at least 2 players, 1 player in one of the three teams.
After reaching the minimum player count, a countdown of 60 seconds should start.
If a player leaves during this countdown and there is no sufficient amount of players the countdown should be reset.

If the game is running already a player who joined late will be part of the TEAM_SPECTATOR and may not spawn until the round has ended.
If there is only one team left FinishedGame() will be called and the round is over.

I just dont know when its useful to call the StartGame() function. Maybe using a timer periodically?

Currently any player can join any time and start playing, but thats not useful.

Код:
stock StartGame()
{
    if(GetActiveTeamCount() > 1)
    {
        CountDownVar--; 
        new str[128];
        if(CountDownVar == 0)
        {
            KillTimer(CountDownTimer2);
            CountDownVar = 59; 
            GameHasStarted =1;
            GameTextForAll("Start!",1000,1);
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(gPlayerHasTeamSelected(i))
                {
                    TeleportPlayerToBase(i);
                    TogglePlayerControllable(i,1);
                    ResetPlayerData(i);
                }
            }    
        }
        else
        {
            format(str, sizeof(str), "Count Down: %d", CountDownTimer2);
            GameTextForAll(str, 1000, 1);
        }
        return 1;
    }
    else 
    {
        CountDownVar = 59;
    }    
}
Also my function to check if there is only one team remaining.
Is there any problem to use recursive functions at this point? At least it works.

Код:
stock TeamsAlive(bool:value)
{
    new i=0,count=0;
    while(i<TEAMSIZE)
    {
        if(GetTeamPlayerCount(i) > 0)
        {
            count++;
        }
        i++;    
    }
    if(bool:value == false)
    switch(count)
    {
    case 1:
        {
            switch(TeamsAlive(true))
            {
            case FIRST_TEAM:
                {
                    for(new d;d<MAX_PLAYERS;d++)
                    {
                        SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIRST_TEAM_COLOR_TAG);
                    }    
                }
            case SECOND_TEAM:
                {
                    for(new d;d<MAX_PLAYERS;d++)
                    {
                        SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SECOND_TEAM_COLOR_TAG);
                    }    
                }
                #if defined TEAMSIZE
                #if TEAMSIZE >= 3
            case THIRD_TEAM:
                {
                    for(new d;d<MAX_PLAYERS;d++)
                    {
                        SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",THIRD_TEAM_COLOR_TAG);
                    }    
                }
                #endif
                #endif
                #if defined TEAMSIZE
                #if TEAMSIZE >= 4
            case FOURTH_TEAM:
                {
                    for(new d;d<MAX_PLAYERS;d++)
                    {
                        SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FOURTH_TEAM_COLOR_TAG);
                    }    
                }
                #endif
                #endif
                #if defined TEAMSIZE
                #if TEAMSIZE >= 5
            case FIFTH_TEAM:
                {
                    for(new d;d<MAX_PLAYERS;d++)
                    {
                        SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",FIFTH_TEAM_COLOR_TAG);
                    }    
                }
                #endif
                #endif
                #if defined TEAMSIZE
                #if TEAMSIZE == 6
            case SIXTH_TEAM:
                {
                    for(new d;d<MAX_PLAYERS;d++)
                    {
                        SendClientMessageEx(d,COLOR_WHITE,"SERVER: All remaining teams have been wiped. Team %s {FFFFFF}has won the game!",SIXTH_TEAM_COLOR_TAG);
                    }    
                }
                #endif
                #endif
            }
            for(new o;o<MAX_PLAYERS;o++)
            {
                ResetPlayerData(o);
            }
            FinishedGame();
        }
    }
    if(bool:value == true && count == 1)//Returns the ID of the remaining team
    return i;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)