Round Timer and ticket system help
#8

pawn Код:
new UnderAttack[30] = 0;
new Captured[MAX_PLAYERS][30];
new IsPlayerCapturing[MAX_PLAYERS][30];
new teamLastOwned[30] = -1; // The last team that owned a certain base.
new teamTickets[2] = 100; //Replace 100 with the starting amount of tickets.
new winnerState = 0; //0 = tie, 1 = TEAM SOVIET win, 2 = TEAM USA win
new timerWin;
stock SnakeFarmCaptured(playerid)
{
    Captured[playerid][SNAKE] = 1; //(SNAKE is just one of the bases this is captues, above here you can see all the names like EAR and QUARRY)
    UnderAttack[SNAKE] = 0;
    KillTimer(timer[playerid][SNAKE]);
    TextDrawHideForPlayer(playerid, CountText[playerid]);
    CountVar[playerid][SNAKE] = 25;
    GivePlayerScore(playerid, 3);
    GivePlayerMoney(playerid, 5000);
    SendClientMessage(playerid, green,"Congratulations! You have captured \"Snake Farm\" you received +3 scores and +$5000 cash!");
    PlayAudioStreamForPlayer(playerid, "http://files.mboxdrive.com/100000435279790/Captured%20success.MP3");
    CheckTeamBase(playerid, SNAKE);
    ///rest of your code

CheckTeamBase(playerid, base)
{
    if( (gTeam[playerid] != teamLastOwned[base]) && (teamLastOwned[base] != -1))
    {
        teamTickets[ ((gTeam[playerid] == TEAM_SOVIET) ? TEAM_USA : TEAM_SOVIET) + 2 ] -= 5;
        if(teamTickets[ ((gTeam[playerid] == TEAM_SOVIET) ? TEAM_USA : TEAM_SOVIET) + 2 ] <= 0)
        {
            winnerState = (gTeam[playerid] == TEAM_SOVIET) ? 2 : 1);
            KillTimer(timerWin);
            //Show textdraws, etc, etc.
        }
    }
    return teamLastOwned[base] = gTeam[playerid];
}
Add this to your other bases, just change SNAKE with other names like EAR or whatever you have there.
As for the kill ticket reduction:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != playerid && playerid != INVALID_PLAYER_ID)
    {
        teamTickets[(gTeam[playerid] == TEAM_SOVIET) ? TEAM_USA : TEAM_SOVIET) - 2] -= 1;
        for(new i = 0; i < 30; i++)
        {
            CheckTeamBase(playerid, i);
        }
     }
     return 1;
}
As for the timer:
pawn Код:
public OnGameModeInit()
{
    timerWin = SetTimer("FinishGame", 15 * 60 * 1000, false);
    return 1;
}

forward FinishGame();
public FinishGame()
{
   if(teamTickets[0] > teamTickets[1])
   {
       winnerState = 1;
   }
   else if(teamTickets[0] < teamTickets[1])
   {
      winnerState = 2;
   }
   else winnerState = 0;
   new winning_Team = (( (winningState == 2) &&(winningState != 0)) ? 3 : 2);
   for(new i = 0; i < MAX_PLAYERS; i++)
   {
       if(IsPlayerConnected(i))
       {
           if(winnerState) {
           //Show a textdraw that winning_Team has won!
           }
           else {
           //Show a textdraw that it's a tie
           }
       }
    }  
}
Reply


Messages In This Thread
Round Timer and ticket system help - by Proph3t - 10.04.2013, 10:05
Re: Round Timer and ticket system help - by Proph3t - 10.04.2013, 13:26
Re: Round Timer and ticket system help - by [XST]O_x - 10.04.2013, 13:42
Re: Round Timer and ticket system help - by Proph3t - 10.04.2013, 14:06
Re: Round Timer and ticket system help - by [XST]O_x - 10.04.2013, 14:20
Re: Round Timer and ticket system help - by Proph3t - 10.04.2013, 15:32
Re: Round Timer and ticket system help - by Proph3t - 10.04.2013, 16:46
Re: Round Timer and ticket system help - by [XST]O_x - 10.04.2013, 16:50
Re: Round Timer and ticket system help - by Proph3t - 10.04.2013, 17:21

Forum Jump:


Users browsing this thread: 3 Guest(s)