Robbery time not correct
#1

The first one or two times you rob the casino it works. But sometimes it will say "time remaining 0" but you wont get the money until a little later. I think its because its not setting the time to 0 correct but saying it is. Look over this code and tell me if you see anything wrong. And it will just get stuck saying The casino is currently being robbed! Which means the time is not setting to 0

pawn Код:
CMD:robcasino(playerid, params[])
{
    if(Info[playerid][Team] == BP) return SendClientMessage(playerid, COLOR_RED, "Border Patrol cannot rob casinos!");
    if(GetPlayerWantedLevel(playerid) >= 5) return SendClientMessage(playerid, COLOR_RED, "You cannot rob the casino with 5 or more stars!");
    if(BeingRobbed == 1) return SendClientMessage(playerid, COLOR_RED, "The casino is currently being robbed!");
   
    if(IsInCasino[playerid] == 1 && BeingRobbed == 0)
    {
        Casino = SetTimerEx("CasinoRob", 1000, true, "i", playerid);
        time = randomEx(30,50); //setting the time between 30 and 50
        BeingRobbed = 1;
    }
    else return SendClientMessage(playerid, COLOR_RED, "You are not in a casino robbery checkpoint!");
    return 1;
}
pawn Код:
public CasinoRob(playerid)
{
    new string[148];
    if(time > 0)
    {
        time--;
        format(string,sizeof(string), "~w~Do not leave the checkpoint! ~g~~n~%i remaining",time);
        GameTextForPlayer(playerid,string,1000,3);
    }
    else if(time == 0 && IsPlayerInRangeOfPoint(playerid, 10, 1945.7587, 1017.7634, 992.4688))
    {
        new cash = randomEx(2500,20000);
        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+4);
        if(GetPlayerWantedLevel(playerid) > 6) return SetPlayerWantedLevel(playerid, 6);
        GivePlayerCash(playerid, cash);
        format(string, sizeof(string), "%s has robbed $%d from 4 Dragons Casino!", Name(playerid), cash);
        SendClientMessageToAll(COLOR_GREEN, string);
        KillTimer(Casino);
        BeingRobbed = 0;
        time = 0;
    }
    else if(time == 0 && IsPlayerInRangeOfPoint(playerid, 10, 2144.1394,1637.5559,993.5761))
    {
        new cash = randomEx(2500,20000);
        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+4);
        if(GetPlayerWantedLevel(playerid) > 6) return SetPlayerWantedLevel(playerid, 6);
        GivePlayerCash(playerid, cash);
        format(string, sizeof(string), "%s has robbed $%d from Cali Casino!", Name(playerid), cash);
        SendClientMessageToAll(COLOR_GREEN, string);
        KillTimer(Casino);
        BeingRobbed = 0;
        time = 0;
    }
    else if(time == 0 && IsPlayerInRangeOfPoint(playerid, 10, 1142.3894,-0.2019,1000.6797))
    {
        new cash = randomEx(2500,20000);
        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+4);
        if(GetPlayerWantedLevel(playerid) > 6) return SetPlayerWantedLevel(playerid, 6);
        GivePlayerCash(playerid, cash);
        format(string, sizeof(string), "%s has robbed $%d from the LV Casino!", Name(playerid), cash);
        SendClientMessageToAll(COLOR_GREEN, string);
        KillTimer(Casino);
        BeingRobbed = 0;
        time = 0;
    }
    SetWantedLevelColor(playerid);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)