[Help] Rob Bank Timer
#1

Ok, so I'm trying to do a Rob Bank system, and I want it to be robbed only once every 30 minutes, here is the code, can you tell me why can they rob unlimited times, what did I do wrong? Thanks in advance, cheers.

pawn Код:
new BankTimer[MAX_PLAYERS];//  The timer to only let someone rob the bank once in 30 minutes.
new RobTimer[MAX_PLAYERS];// The timer to pay to the person who robbed it.

CMD:rob(playerid, params[])
{
    if(!IsPlayerInRangeOfPoint(playerid, 20.0, 2311.5740,-8.9346,26.7422))// To check if the player is at the bank.
    {
        SendClientMessageEx(playerid, COLOR_GREY, "You are not at the bank!");
        return 1;
    }
    new string[70+MAX_PLAYER_NAME];
                    ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_Out", 4.0, 0, 0, 0, 0, 0, 1);
                    SendClientMessageEx(playerid, COLOR_RED, "You're now trying to rob the bank, don't leave the bank!");
                    format(string, sizeof(string), " The bank silent alarm was triggered, respond immediatly!"); // Sends a message to cops.
                    SendRadioMessage(1, RADIO, string);
                    SendRadioMessage(2, RADIO, string);
                    SendRadioMessage(3, RADIO, string);
                    SendRadioMessage(7, RADIO, string);
                    if(BankTimer[playerid] == 1) // This will check if the bank has already been robbed.
                    return SendClientMessageEx(playerid, COLOR_GREY, "The bank has already been robbed in the past 30 minutes!");
                    RobPlayTimer[playerid]= SetTimerEx("Rob", 30000, false, "d", playerid); //So he gets the money in 30 seconds.
                    BankTimer[playerid]= SetTimerEx("Bank", 1800000, false, "d", playerid); //Will set the timer so if the player use it again he will fail.
                    BankTimer[playerid] = 1; //This makes the Variable a 1 So that means he has to wait 5 minutes.
                   
                    return 1;
        }

forward Rob(playerid);
public Rob(playerid)
{
    GivePlayerCash(playerid, 100000);
    SendClientMessageEx(playerid, COLOR_RED, "You've robbed the bank and received 100k, watch your way out for cops!");
    return 1;
}

forward Bank(playerid);
public Bank(playerid)
{
    BankTimer[playerid] = 0;
    return 1;
}
Reply
#2

problem is this line...
if(BankTimer[playerid] == 1)

try if(BankTimer[playerid] != 0)
Reply
#3

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
problem is this line...
if(BankTimer[playerid] == 1)

try if(BankTimer[playerid] != 0)
I'll try it now, thanks, anyways.

Edit: Thanks, mate. That worked perfectly! Now I just need to figure out a way to stop the robbing if the player leaves the area, any ideas?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)