Wanted level
#1

Hello, I've recently been scripting a bank robbery system. My only problem is...When I try to /robbank, it keeps saying "You cannot rob the bank whilst wanted!" even when my player is not wanted.

Here is my script so far, please help me out. I'd appreciate it a lot!

pawn Код:
#include <a_samp>
#include <zcmd>

#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_PURPLE 0xC2A2DAAA
#define DIALOGITEMS 1
#define DIALOGITEMS2 2


forward robtimer(playerid);
forward waittimer();

new robpossible;

public OnFilterScriptInit()
{
   
    robpossible = 1;
    return 1;
}


CMD:robbank(playerid, params[])
{
        if(robpossible == 0) //If the bank can be robbed we continue below
        {
            SendClientMessage(playerid, COLOR_WHITE, "You can't rob the bank right now!");
            return 1;
        }
   
            if(!IsPlayerInRangeOfPoint(playerid, 3, 2144.2012,1640.6323,993.5761))
            {
                SendClientMessage(playerid, COLOR_WHITE, "You are not in range of the bank!");
                return 1;
            }
                if(GetPlayerWantedLevel(playerid) <1 || 2 || 3 || 4 || 5 || 6 )
                {
                    SendClientMessage(playerid, COLOR_WHITE, "You cannot rob the bank whilst wanted!");
                    return 1;
                }


                        robpossible = 0;
                        //SetTimer("waittimer",  5000, false); //for testing
           
                        //SetTimer("robtimer", 5000, false); //Test Mode 6 seconds
                        SetTimer("waittimer", 5500000, false);
                        SetTimer("robtimer", 300000, false);
           
                        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+4);
                        TogglePlayerControllable(playerid, 0);
                        SendClientMessage(playerid, COLOR_WHITE, "You are now robbing the bank, the police have been notified!");
                        SendClientMessage(playerid, COLOR_WHITE, "You must stay in the bank for 5 minutes in order to rob it!");
                        SendClientMessageToAll(COLOR_PURPLE, "*** . . : : You may hear alarms and sirens screaming outside the bank in Mulholland: : . .  ***");
                        new string[18];
                        format(string, sizeof(string), "Robbing the bank");
                        GameTextForPlayer(playerid, string, 299995, 5);
                        //GameTextForPlayer(playerid, string, 6000, 5); //for testing
                        return 1;
                    }

/*test cmds
CMD:wanted(playerid, params[])
{
    SetPlayerWantedLevel(playerid, 6);
    return 1;
}

CMD:unwanted(playerid, params[])
{
    SetPlayerWantedLevel(playerid, 0);
    return 1;
}*/


CMD:buyitems(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 7, 2561.2803,1403.9896,7699.5845))
    {
        ShowPlayerDialog(playerid, DIALOGITEMS, DIALOG_STYLE_LIST, "Items menu - New items soon!","Bank robbery timer reset (150k)","Buy","Cancel");
    }
    return 1;
}
 /*
CMD:bank(playerid, params[])
{
    SetPlayerPos(playerid, 2144.2012,1640.6323,993.5761);
    SetPlayerInterior(playerid, 1);
    return 1;
}

CMD:vip(playerid, params[])
{
    SetPlayerPos(playerid, 2561.2803,1403.9896,7699.5845);
    GivePlayerMoney(playerid, 200000);
    TogglePlayerControllable(playerid, 0);
    return 1;
}

CMD:unfreeze(playerid, params[])
{
    TogglePlayerControllable(playerid, 1);
    return 1;
}

CMD:setmoney(playerid, params[])
{
    GivePlayerMoney(playerid, 0);
    return 1;
}

CMD:sethp(playerid, params[])
{
    SetPlayerHealth(playerid, 10);
    return 1;
}
CMD:sethpp(playerid, params[])
{
    SetPlayerHealth(playerid, 25);
    return 1;
}*/


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOGITEMS)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
            {
                ShowPlayerDialog(playerid, DIALOGITEMS2, DIALOG_STYLE_MSGBOX, "Are you sure you want to buy this item?","Buying this item will reset the bank timer so you're\nable to rob the bank again without waiting 30 minutes.\nRemember: There is no point in buying this timer if the bank has\nnot been robbed in the past 30 minutes.","Buy item","Cancel");
            }
       
            }
        }
    }

    if(dialogid == DIALOGITEMS2)
    {
        if(response)
        {
            if(GetPlayerMoney(playerid) <150000) return SendClientMessage(playerid, COLOR_WHITE, "You do not have enough money to purchase this item!");
            SendClientMessage(playerid, COLOR_WHITE, "You have purchased a bank robbery timer reset!");
            SendClientMessage(playerid, COLOR_WHITE, "The bank timer has been reset!");
            GivePlayerMoney(playerid, -150000);
            robpossible = 1;
        }
    }
    return 1;
}


public robtimer(playerid)
{
    new string2[128];
    new cash = random(200000);
    GivePlayerMoney(playerid, cash);
    TogglePlayerControllable(playerid, 1);

    format(string2, sizeof(string2), "You have successfully robbed $%d from the bank!", cash);
    SendClientMessage(playerid, COLOR_WHITE, string2);
    new string3[18];
    format(string3, sizeof(string3), "Sucessful!");
    GameTextForPlayer(playerid, string3, 2000, 5);
}

public waittimer()
{
    robpossible = 1;
}
Reply
#2

try this

then its if you got the wanted level more than 1 so message ..

Код:
if(GetPlayerWantedLevel(playerid) > 1)
{
        SendClientMessage(playerid, COLOR_WHITE, "You cannot rob the bank whilst wanted!");
        return 1;
}
Reply
#3

Legend! It worked! Quick question, was the reason it kept saying I was wanted when I wasn't because I had "<" instead of ">"?
Reply
#4

yes of course its the if < smaller or if > higher
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)