SA-MP Forums Archive
ROBBERY COUNTDOWN TIMER? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: ROBBERY COUNTDOWN TIMER? (/showthread.php?tid=520023)



ROBBERY COUNTDOWN TIMER? - [Cali]ChrOnic_T - 17.06.2014

How to make it so it says

- " 10 seconds left"
- " 9 seconds left"
- " 8 seconds left"
- and on and on.


Cause i made a robbery script (help from a tutorial on samp forums) and i need it cause it seems wierd when you /robstore and you stand there for 15 seconds with no gametext informing you how many seconds you have to wait to finish robbing it.

Dont mind the comments cause it was a tutorial xD, but heres the script:

pawn Код:
CMD:robstore(playerid, params[])
{
    if(robpossible == 1) //If the bank can be robbed we continue below
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 374.8841,-118.8026,1001.4995))
       
        {//Next thing we do is, we check if we are at the bank interior ^^
            robpossible = 0; //Then we set the bank so it cannot be robbed
            SetTimer("waittimer", 900000, false); //Normal Mode 5 minutes
            /*We run the timer(5 minutes) for the function that is going to make the
            bank available for robbing again
            */

            //SetTimer("waittimer", 65000, false); //Test Mode 65 seconds
            SetTimer("robtimer", 15000, false);
            /* We also run another timer(1 minute) for the function that is
            actually going to give us the money and a user friendly message.
            */

            /*
            Add a function that would notify the police.
            */

            SendClientMessage(playerid, COLOR_WHITE, "{FF0000}You are now Robbing {EAEA15}Well Stacked Pizza.");
            GameTextForPlayer(playerid,"~Y~ROBBERY STARTED",3000,3);
            SendClientMessage(playerid, COLOR_WHITE, "{1A94E6}You gotta stay here for 15 seconds.");
         }
    } else {
        SendClientMessage(playerid, COLOR_WHITE, "You can't rob the bank right now!");
    }
    return 1;
}
and the timer:

pawn Код:
public robtimer(playerid)
{
    new string[256];//We are defining a new string for the formatted message that we are displaying later on.
    new cash = random(90000);
    GivePlayerMoney(playerid, cash);
    /*
    With the fuction above 'new cash = random(200000);
    GivePlayerMoney(playerid, cash);' we give the player
    a random amount of money from $0 - $200,000
    */

    //Here below we use the string we defined above to format the message itself and display it to the player.
    format(string, sizeof(string), "{FF3300}You have successfully robbed {09F720}$%d {FF3300}from Well Stacked Pizza!", cash);
    SendClientMessage(playerid, COLOR_WHITE, string);
    new pname[126];
    GetPlayerName(playerid,pname,sizeof(pname));
    format(string, 256, "{33CCBD}%s has robbed $%d from Well Stacked Pizza in Idlewood.",pname,cash);
    SendClientMessageToAll( 0x48ACB7C8, string );
}
I would really appreciate if you helped.


Re: ROBBERY COUNTDOWN TIMER? - RenovanZ - 17.06.2014

Try this.

pawn Код:
new RobCount[MAX_PLAYERS];
CMD:robstore(playerid, params[])
{
    if(robpossible == 1) //If the bank can be robbed we continue below
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 374.8841,-118.8026,1001.4995))
       
        {//Next thing we do is, we check if we are at the bank interior ^^
            robpossible = 0; //Then we set the bank so it cannot be robbed
            SetTimer("waittimer", 900000, false); //Normal Mode 5 minutes
            /*We run the timer(5 minutes) for the function that is going to make the
            bank available for robbing again
            */

            //SetTimer("waittimer", 65000, false); //Test Mode 65 seconds
            SetTimer("robtimer", 15000, false);
            SetTimerEx("robcount", 1000, false, "i", playerid);
            RobCount[playerid] = 15;
            SendClientMessage(playerid, -1, "INFO: 15 seconds remaining.");
            /* We also run another timer(1 minute) for the function that is
            actually going to give us the money and a user friendly message.
            */

            /*
            Add a function that would notify the police.
            */

            SendClientMessage(playerid, COLOR_WHITE, "{FF0000}You are now Robbing {EAEA15}Well Stacked Pizza.");
            GameTextForPlayer(playerid,"~Y~ROBBERY STARTED",3000,3);
            SendClientMessage(playerid, COLOR_WHITE, "{1A94E6}You gotta stay here for 15 seconds.");
         }
    } else {
        SendClientMessage(playerid, COLOR_WHITE, "You can't rob the bank right now!");
    }
    return 1;
}

forward robcount(playerid);
public robcount(playerid)
{
    if(RobCount[playerid] != 0)
    {
        RobCount[playerid]--;
        SetTimerEx("robcount", 1000, false, "i", playerid);
        format(string, sizeof(string), "INFO: %d seconds remaining.", RobCount[playerid]);
        SendClientMessage(playerid, -1, string);
    }
    // Send message that timer end or whatever.
    return 1;
}