Problem with robbery script
#1

Hello guys. I have a robbery script on my server. You can say like its working to 90%. The problem is, after I've robbed the bank once I need to restart the server to be able to rob the bank again. Here is my code.

pawn Код:
/*
    This script/application is created by UnlimitedDeveloper from SAMP forums
    and it's supposed to be shared only at SAMP forums, nowhere else!
    If any copy of this script is found on another forum, it will be taken down.
    */

    #include <a_samp>
    #include <zcmd>

    #define COLOR_WHITE 0xFFFFFFAA
    #define COLOR_RED 0xAA3333AA
    //Function forwarding
    /*
    Firstly we have to forward the functions that we are going
    to use later in our sript.
    */

    forward robtimer(playerid);
    forward waittimer();

    //Variables
    /*
    We are adding a NEW Variable so we can determine wether the bank
    can or cannot be robber at a certain time.
    */

    new robpossible;

    public OnFilterScriptInit()
    {
            /*
            When the filterscript executes itself it's setting the 'robpossible'
            variable to 1 which means that we can rob the bank right after we login.
            */

            robpossible = 1;
            return 1;
    }

    //Command(s)
    CMD:robbank(playerid, params[])
    {
            if(robpossible == 1) //If the bank can be robbed we continue below
            {
                    if(IsPlayerInRangeOfPoint(playerid, 3.0, 2315.952880,-1.618174,26.742187))
                    {//Next thing we do is, we check if we are at the bank interior ^^
                        robpossible = 0; //Then we set the bank so it cannot be robbed
                        SetTimer("waittimer", 300000, false); //Normal Mode 5 minutes
                        /*We run the timer(5 minutes) for the function that is going to make the
                        bank available for robbing again
                        */

                        //SetTimer("waittimer", 65000, false); //Test Mode 65 seconds
                        SetTimer("robtimer", 60000, false);
                        /* We also run another timer(1 minute) for the function that is
                        actually going to give us the money and a user friendly message.
                        */

                        /*
                        Add a function that would notify the police.
                        */

                        SendClientMessage(playerid, COLOR_WHITE, "You are robbing the bank, the police has been notified!");
                SendClientMessage(playerid, COLOR_WHITE, "You gotta stay 30 seconds in the bank in order to rob it!");
                SendClientMessageToAll(COLOR_RED, "Los Santos bank is being robbed!");
                     }
            } else {
                SendClientMessage(playerid, COLOR_WHITE, "The bank has already been robbed!");
            }
            return 1;
    }

    //Functions
    public robtimer(playerid)
    {
            new string[128];//We are defining a new string for the formatted message that we are displaying later on.
        new cash = random(200000);
            GivePlayerMoney(playerid, cash);
            /*
        With the fuction above 'new cash = random(200000);
            GivePlayerMoney(playerid, cash);' we give the player
        a random amount of money from $0 - $200,000
        */

        //Here below we use the string we defined above to format the message itself and display it to the player.
            format(string, sizeof(string), "You have successfully robbed $%d from the bank!", cash);
            SendClientMessage(playerid, COLOR_WHITE, string);
    }

    public waittimer()
    {
            robpossible = 1; //With this we make the bank available for robbery again, and we display a friendly message to all players.
            SendClientMessageToAll(COLOR_WHITE, "The bank is now available for robbery!");
    }
Please help me fix this!!
Reply


Messages In This Thread
Problem with robbery script - by AustinWeerdGuy - 14.03.2014, 10:55
Re: Problem with robbery script - by Matess - 14.03.2014, 10:58
Re: Problem with robbery script - by shahryar2 - 14.03.2014, 11:02
Re: Problem with robbery script - by AustinWeerdGuy - 14.03.2014, 11:10
Re: Problem with robbery script - by AustinWeerdGuy - 14.03.2014, 11:12
Re: Problem with robbery script - by Ceathor - 14.03.2014, 11:15
Re: Problem with robbery script - by AustinWeerdGuy - 14.03.2014, 11:17
Re: Problem with robbery script - by Ceathor - 14.03.2014, 11:18
Re: Problem with robbery script - by Ceathor - 14.03.2014, 11:22
Re: Problem with robbery script - by AustinWeerdGuy - 14.03.2014, 11:54

Forum Jump:


Users browsing this thread: 1 Guest(s)