team wins
#5

No need to declare a timer you can use the callbacks OnPlayerDeath (Called when a player dies) and OnPlayerDisconnect (Called when a player disconnects), example (Read the comments):

pawn Code:
#include <a_samp>

// Let's make a stock to check for a winner team so we can use it anywhere we want
stock CheckForWinnerTeam()
{
    if(bluecount < 1) // if the blue team count equals to anything below 1 (0, -1, -2 ... etc)
    {
        // The red team won. Do something!
        return 1;
    }
    if(redcount < 1) // if the red team count equals to anything below 1 (0, -1, -2 ... etc)
    {
        // The blue team won. Do something!
        return 1;
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    switch(gTeam[playerid])
    {
        case TEAM_BLUE: // if player in the blue team
        {
            bluecount --; // decrease the blue team count
            break;
        }
        case TEAM_RED: // if player in the red team
        {
            redcount --; // decrease the red team count
            break;
        }
        default:
            break;
    }
    CheckForWinnerTeam(); // Here comes the stock we made ABOVE
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    switch(gTeam[playerid])
    {
        case TEAM_BLUE: // if player in the blue team
        {
            bluecount --; // decrease the blue team count
            break;
        }
        case TEAM_RED: // if player in the red team
        {
            redcount --; // decrease the red team count
            break;
        }
        default:
            break;
    }
    CheckForWinnerTeam(); // Here comes the stock we made ABOVE
    return 1;
}
Reply


Messages In This Thread
team wins - by (_AcE_) - 19.07.2012, 23:24
Re: team wins - by (_AcE_) - 19.07.2012, 23:44
Re: team wins - by nepstep - 19.07.2012, 23:47
Re: team wins - by (_AcE_) - 20.07.2012, 01:21
Re: team wins - by [KHK]Khalid - 20.07.2012, 01:26
Re: team wins - by leonardo1434 - 20.07.2012, 01:55
Re: team wins - by [KHK]Khalid - 20.07.2012, 02:15
Re: team wins - by nepstep - 20.07.2012, 05:04
Re: team wins - by cessil - 21.07.2012, 09:19

Forum Jump:


Users browsing this thread: 2 Guest(s)