20.07.2012, 01:26
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;
}