Cops counter doesnt work
#1

I am astonished to see this not working...
It's happened with my house system too actually, but what's happened is that this: "if(cops < 1) return SendClientMessage(playerid, COLOR_GREY, "There has to be atleast one Police officer on duty to rob a store.");"
Gets told the whole time, even if there's cops online and onduty, its very weird, because it worked before.

But what's even more weird is, it works with bank robberies? That uses the same line?!
if(cops < 2) return SendClientMessage(playerid, COLOR_GREY, "There has to be atleast 2 Police officers on duty to rob the bank.");

This is the robbery command (not the bank) underneath:

pawn Код:
CMD:robbiz(playerid, params[])
{
    #pragma unused params
    new idx = GetPlayerVirtualWorld(playerid)-100, cops;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
    if(idx > 0 && idx < MAX_BIZ && BizInfo[idx][bType] != 1 && BizInfo[idx][bType] != 2 && BizInfo[idx][bType] != 3 && BizInfo[idx][bType] != 4 && BizInfo[idx][bType] != 6 && BizInfo[idx][bType] != 7 || idx < 1 || idx > MAX_BIZ) return SendClientMessage(playerid, COLOR_GREY, "You are not inside a business.");
    if(cops < 1) return SendClientMessage(playerid, COLOR_GREY, "There has to be atleast one Police officer on duty to rob a store.");
    if(BizInfo[idx][bMoney] < 500) return SendClientMessage(playerid, COLOR_GREY, "This business vault do not have enough money to rob");
    if(IsACop(playerid) || IsAFBI(playerid) || IsASWAT(playerid) || IsARCSD(playerid) || IsARCSD(playerid) || IsASATF(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Law enforcement cannot rob a business.");
    if(g_remainingBizTicks[idx])
    {
        new strRobbedInfo[128];
        new playerName[36];
        GetPlayerName(g_bizRobber[idx], playerName, 36);
        format(strRobbedInfo, sizeof(strRobbedInfo), "This business was robbed under 2 hours ago.");
        return SendClientMessage(playerid, COLOR_GREY, strRobbedInfo);
    }
    if(g_bizRobber[idx] == playerid) return SendClientMessage(playerid, COLOR_GREY, "You're already robbing a business.");
    g_bizRobber[idx] = playerid;
    g_bIsRobbiz[playerid] = 1;
    g_remainingRobTicks[playerid] = 70;
    g_remainingBizTicks[idx] = 120*60;
    g_apprehendedCash[playerid] = (BizInfo[idx][bMoney] * 10) / 100;

    SendClientMessage(playerid, COLOR_RED, "You've begun robbing this business");
    new warningMessage[64];
    format(warningMessage, sizeof(warningMessage), "* %s threatens the store clerk to give him the money.", NORPN(playerid));
    SendNearbyMessage(playerid, 15.0, warningMessage, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    for(new i=0;i<MAX_PLAYERS;i++){

// Bla bla functions here
Reply
#2

So you create a variable 'cops'...
pawn Код:
new idx = GetPlayerVirtualWorld(playerid)-100, cops;
You give it no value, therefore cops = 0 by default.
Then you check if the variable that you gave no value to is less than 1...
pawn Код:
if(cops < 1)
What are you doing differently in your bank robberies? Do you give 'cops' an actual value?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)