Round Timer and ticket system help
#1

Hello people of the samp forums, i am creating a Battlefield 3 server in samp but i need some help with timers.

I need a timer that starts from 15 mins and counts down to 0, the moment it reaches 0 i want that the winning team shows up in a textdraw and that the round restarts.

i use the teams USA and SOVIET, the winning team should have more tickets then the loosing team (if u play bf3 u should understand). i got a textdraw box set up already and if you guys could help me with this that would be great.

if u guys can also help me make a ticket system for the 2 teams so they start with 100 tickets and they loose 1 if a team member gets killed and 5 if the enemy captures a base.

I already tried googling allot with the timers etc but no luck,

thanks!
Reply
#2

please? somoene? im dying for this
Reply
#3

This is a little hard for us because we don't know what variables you're using, so we can't guess variable names to help you out.
Also, we don't know what callback is called when a base is captured.
The ticket system and the timer is nonsense, just tell us which function you use for base captures, player deaths and so on.
Reply
#4

Okay, here they are:

pawn Код:
#define TEAM_SOVIET 2
#define TEAM_USA 3
#define TEAM_NONE 5
pawn Код:
new UnderAttack[30] = 0;
new Captured[MAX_PLAYERS][30];
new IsPlayerCapturing[MAX_PLAYERS][30];
pawn Код:
if(Captured[playerid][SNAKE] == 0 && IsPlayerCapturing[playerid][SNAKE] == 1)
    {
        LeavingSnakeFarm(playerid);
    }
    if(Captured[playerid][BAY] == 0 && IsPlayerCapturing[playerid][BAY] == 1)
    {
        LeavingBay(playerid);
    }
    if(Captured[playerid][BIG] == 0 && IsPlayerCapturing[playerid][BIG] == 1)
    {
        LeavingEar(playerid);
    }
    if(Captured[playerid][ARMY] == 0 && IsPlayerCapturing[playerid][ARMY] == 1)
    {
        LeavingArmy(playerid);
    }
    if(Captured[playerid][PETROL] == 0 && IsPlayerCapturing[playerid][PETROL] == 1)
    {
        LeavingPetrol(playerid);
    }
    if(Captured[playerid][OIL] == 0 && IsPlayerCapturing[playerid][OIL] == 1)
    {
        LeavingOil(playerid);
    }
    if(Captured[playerid][DESERT] == 0 && IsPlayerCapturing[playerid][DESERT] == 1)
    {
        LeavingDesert(playerid);
    }
    if(Captured[playerid][QUARRY] == 0 && IsPlayerCapturing[playerid][QUARRY] == 1)
    {
        LeavingQuarry(playerid);
    }
    if(Captured[playerid][GUEST] == 0 && IsPlayerCapturing[playerid][GUEST] == 1)
    {
        LeavingGuest(playerid);
    }
    if(Captured[playerid][EAR] == 0 && IsPlayerCapturing[playerid][EAR] == 1)
    {
        LeavingEar(playerid);
    }
pawn Код:
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");
not sure if this is all you need.
Reply
#5

A couple more things:
-Do you store the basenames in enums? (SNAKE, EAR...)
-What variable do you use to store a player's team?

Once you give me this info, I should be able to script it up for you in minutes.
Reply
#6

No i do not store them in enums.

these are my team commands, i think u can find them there, because i did not really know what you meanth, i only have my teams defined and cant find a variable that stores it but this:
pawn Код:
CMD:teams(playerid, params[])
{
   new team2count = GetTeamCount(TEAM_USA);
   new team4count = GetTeamCount(TEAM_SOVIET);
   new str[500];
   SendClientMessage(playerid, orange,"|_____| Teams |_____| ");
   format(str, sizeof(str),"USA: %d Players", team2count);
   SendClientMessage(playerid, lightblue, str);
   format(str, sizeof(str),"Russia: %d Players", team4count);
   SendClientMessage(playerid, lightblue, str);
   return 1;
}
CMD:getteam(playerid, params[])
{
   if(PlayerInfo[playerid][Level] >= 4)
   {
       new team[100], Float:x, Float:y, Float:z, interior = GetPlayerInterior(playerid), world = GetPlayerVirtualWorld(playerid);
       if(sscanf(params,"s[100]",team)) return SendClientMessage(playerid, RED,"USAGE: /getteam [teamname USA/EUROPE/Arabia/Soviet/Australia]");
       GetPlayerPos(playerid, x, y, z);
       //---------USA------------------------
       if(strfind(params,"USA",true) != -1) //Returns 4 (Thanks to wiki for helping in strfind).
       {
           for(new i = 0; i < MAX_PLAYERS; i++)
           {
               if(gTeam[i] == TEAM_USA)
               {
                   SetPlayerInterior(i, interior);
                   SetPlayerVirtualWorld(i, world);
                   SetPlayerPos(i, x+3, y, z);
               }
           }
           new string[100];
           format(string,sizeof(string),"Administrator %s has teleported team %s",PlayerName2(playerid),params);
           SendClientMessageToAll(blue, string);
       }
       //----------Soviet-------
       if(strfind(params,"Soviet",true) != -1 || strfind(params,"Russia",true) != -1) //Returns 4 (Thanks to wiki for helping in strfind).
       {
           for(new i = 0; i < MAX_PLAYERS; i++)
           {
               if(gTeam[i] == TEAM_SOVIET)
               {
                   SetPlayerPos(i, x+3, y, z);
                   SetPlayerInterior(i, interior);
                   SetPlayerVirtualWorld(i, world);
               }
           }
           new string[100];
           format(string,sizeof(string),"Administrator %s has teleported team %s",PlayerName2(playerid),params);
           SendClientMessageToAll(blue, string);
       }
    }
    else return SendClientMessage(playerid, RED,"[ERROR]: You are not high enough level to use this command!");
    return 1;
}
Reply
#7

soo ehm, can u do it? or anyone else?
Reply
#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
#9

Thanks to much for taking the time out of your day to help me out! repped
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)