!IsPlayerInRangeOfPoint
#1

Hello, I'm editing a basic bank filterscript. What/where can I add to my script so that if the player leaves the point(the bank), it does not give him the money and returns a message saying "You left the bank!"?

Any help would be greatly appreciated! Thanks!

Heres the code:

pawn Code:
#include <a_samp>
#include <zcmd>

#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_PURPLE 0xC2A2DAAA


forward robtimer(playerid);
forward waittimer();

new robpossible;

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


CMD:robbank(playerid, params[])
{
    if(robpossible == 1)
    {
        if(IsPlayerInRangeOfPoint(playerid, 50, 2144.2012,1640.6323,993.5761))
        {
            robpossible = 0;
            SetTimer("waittimer", 30000, false);
                     
            SetTimer("robtimer", 5000, false);       

            SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+4);
            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: : . .  ***");
         }
    } else {
        SendClientMessage(playerid, COLOR_WHITE, "You can't rob the bank right now!");
    }
    return 1;
}

//quick bank teleport for testing
CMD:bank(playerid, params[])
{
    SetPlayerPos(playerid, 2144.2012,1640.6323,993.5761);
    SetPlayerInterior(playerid, 1);
    return 1;
}


public robtimer(playerid)
{
    new string[128];
    new cash = random(85000);
    GivePlayerMoney(playerid, cash);
   
    format(string, sizeof(string), "You have successfully robbed $%d from the bank!", cash);
    SendClientMessage(playerid, COLOR_WHITE, string);
}

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

EDIT: Changed the whole code for you. Just Copy and paste.

pawn Code:
#include <a_samp>
#include <zcmd>

#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_PURPLE 0xC2A2DAAA


forward robtimer(playerid);
forward waittimer();
forward rangetimer();

new robpossible;

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


CMD:robbank(playerid, params[])
{
    if(robpossible == 1)
    {
        if(IsPlayerInRangeOfPoint(playerid, 50, 2144.2012,1640.6323,993.5761))
        {
            robpossible = 0;
            new waittime = SetTimer("waittimer", 30000, false);
            new robtime = SetTimer("robtimer", 5000, false);
            new rangetime = SetTimer("rangetimer",1000,true);        

            SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+4);
            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: : . .  ***");
         }
    } else {
        SendClientMessage(playerid, COLOR_WHITE, "You can't rob the bank right now!");
    }
    return 1;
}

//quick bank teleport for testing
CMD:bank(playerid, params[])
{
    SetPlayerPos(playerid, 2144.2012,1640.6323,993.5761);
    SetPlayerInterior(playerid, 1);
    return 1;
}

public rangetimer();
{
      if(IsPlayerInRangeOfPoint(playerid, 50, 2144.2012,1640.6323,993.5761)) return 1;
      SendClientMessage(playerid,COLOR_WHITE,"You've left the bank. Robbery cancelled.");
      KillTimer(waittime);
      KillTimer(robtime);
      return 1;
}

public robtimer(playerid)
{
    new string[128];
    new cash = random(85000);
    GivePlayerMoney(playerid, cash);
   
    format(string, sizeof(string), "You have successfully robbed $%d from the bank!", cash);
    SendClientMessage(playerid, COLOR_WHITE, string);
    KillTimer(rangetime);
}

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

Thanks so much!
Reply
#4

Quote:
Originally Posted by Josh_Main
View Post
Thanks so much!
No problem. Rep if it worked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)