SA-MP Forums Archive
Timer not being called - 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: Timer not being called (/showthread.php?tid=367780)



Timer not being called - Abreezy - 11.08.2012

Alright, im working on some random commands, and for some damn reason this command won't run the timers set in it.

Here's the code, I get 0 response from the timers, hopefully you guys show me the issue.

pawn Код:
CMD:robshop(playerid, params[])
{
    new string[128];
    if(Shop1[playerid] == 1)
    {
        if(Shop1robbed == 0)
        {
            format(string, sizeof(string), "%s has begun robbing a 24/7 shop on The Strip.", pName(playerid));
            SendClientMessageToAll(COLOR_GREEN, string);
            RobbingShop1[playerid] = 1;
            GameTextForPlayer(playerid, "ROBBING WILL FINISH IN 30 SECONDS", 4999, 4);
            SetTimerEx("Robshop1", 1000, false, "d", playerid);
            SetTimerEx("CountDown", 1000, false, "d", playerid);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "This shop has been robbed recently.");
        }
       
    }
    else if(Shop2[playerid] == 1)
    {
        if(Shop2robbed == 0)
        {
            format(string, sizeof(string), "%s has begun robbing a 24/7 shop on insertlocation.", pName(playerid));
            SendClientMessageToAll(COLOR_GREEN, string);
            RobbingShop2[playerid] = 1;

           
            SetTimerEx("Robshop2", 1000, false, "d", playerid);
            GameTextForPlayer(playerid, "ROBBING WILL FINISH IN 30 SECONDS", 4999, 4);
            SetTimerEx("CountDown", 1000, false, "d", playerid);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "This shop has been robbed recently.");
        }
    }
    else if(Shop3[playerid] == 1)
    {
        if(Shop3robbed == 0)
        {
            format(string, sizeof(string), "%s has begun robbing a 24/7 shop on insertlocation.", pName(playerid));
            SendClientMessageToAll(COLOR_GREEN, string);
            RobbingShop3[playerid] = 1;

           
            SetTimerEx("Robshop3", 1000, false, "d", playerid);
            GameTextForPlayer(playerid, "ROBBING WILL FINISH IN 30 SECONDS", 4999, 4);
            SetTimerEx("CountDown", 1000, false, "d", playerid);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "This shop has been robbed recently.");
        }
    }
    else if(Shop4[playerid] == 1)
    {
        if(Shop4robbed == 0)
        {
            format(string, sizeof(string), "%s has begun robbing a 24/7 shop on insertlocation.", pName(playerid));
            SendClientMessageToAll(COLOR_GREEN, string);
            RobbingShop4[playerid] = 1;

           
            SetTimerEx("Robshop4", 1000, false, "d", playerid);
            GameTextForPlayer(playerid, "ROBBING WILL FINISH IN 30 SECONDS", 4999, 4);
            SetTimerEx("CountDown", 1000, false, "d", playerid);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "This shop has been robbed recently.");
        }
    }
    else if(Shop5[playerid] == 1)
    {
        if(Shop5robbed == 0)
        {
            format(string, sizeof(string), "%s has begun robbing a 24/7 shop on insertlocation.", pName(playerid));
            SendClientMessageToAll(COLOR_GREEN, string);
            RobbingShop5[playerid] = 1;

       
            SetTimerEx("Robshop5", 1000, false, "d", playerid);
            GameTextForPlayer(playerid, "ROBBING WILL FINISH IN 30 SECONDS", 4999, 4);
            SetTimerEx("CountDown", 1000, false, "d", playerid);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "This shop has been robbed recently.");
        }
    }
    else if(Shop6[playerid] == 1)
    {
        if(Shop6robbed == 0)
        {
            format(string, sizeof(string), "%s has begun robbing a 24/7 shop on insertlocation.", pName(playerid));
            SendClientMessageToAll(COLOR_GREEN, string);
            RobbingShop6[playerid] = 1;

           
            SetTimerEx("Robshop6", 1000, false, "d", playerid);
            GameTextForPlayer(playerid, "ROBBING WILL FINISH IN 30 SECONDS", 4999, 4);
            SetTimerEx("CountDown", 1000, false, "d", playerid);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "This shop has been robbed recently.");
        }
    }
    else if(Shop7[playerid] == 1)
    {
        if(Shop7robbed == 0)
        {
            format(string, sizeof(string), "%s has begun robbing a 24/7 shop on insertlocation.", pName(playerid));
            SendClientMessageToAll(COLOR_GREEN, string);
            RobbingShop7[playerid] = 1;
           
           
            SetTimerEx("Robshop7", 1000, false, "d", playerid);
            GameTextForPlayer(playerid, "ROBBING WILL FINISH IN 30 SECONDS", 4999, 4);
            SetTimerEx("CountDown", 1000, false, "d", playerid);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "This shop has been robbed recently.");
        }
    }
    else if(Shop8[playerid] == 1)
    {
        if(Shop8robbed == 0)
        {
            format(string, sizeof(string), "%s has begun robbing a 24/7 shop on insertlocation.", pName(playerid));
            SendClientMessageToAll(COLOR_GREEN, string);
            RobbingShop8[playerid] = 1;

           
            SetTimerEx("Robshop8", 1000, false, "d", playerid);
            GameTextForPlayer(playerid, "ROBBING WILL FINISH IN 30 SECONDS", 4999, 4);
            SetTimerEx("CountDown", 1000, false, "d", playerid);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "This shop has been robbed recently.");
        }
    }
   
    return 1;
}
The Shop1-8 are set as you enter the place, which works because the robbing countdown works, just not the robshop1-8. Here's an example of robshop1

pawn Код:
public RobShop1(playerid)
{
    print("Called");
    Shop1robbed = 1;
    SetTimer("Shop1cooldown", 1000*120, false);
    new rand = random(150000);
    GivePlayerMoney(playerid, rand);
    IncreaseWantedLevel(playerid, 2);
    WantedLevelColor(playerid);
    SendClientMessage(playerid, COLOR_LBLUE, "Done.");
    return 1;
}
I get absolutely no response from the RobShop1 timer, please help, thank you in advance!


Re: Timer not being called - [KHK]Khalid - 11.08.2012

You're calling a public with the name Robshop1 which doesn't probably exist actually it's RobShop1, so your SetTimer call should be:

pawn Код:
SetTimerEx("RobShop1", 1000, false, "d", playerid);
instead of
pawn Код:
SetTimerEx("Robshop1", 1000, false, "d", playerid);