!IsPlayerInRangeOfPoint - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: !IsPlayerInRangeOfPoint (
/showthread.php?tid=446340)
!IsPlayerInRangeOfPoint -
Josh_Main - 25.06.2013
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;
}
Re: !IsPlayerInRangeOfPoint -
introzen - 25.06.2013
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;
}
Re: !IsPlayerInRangeOfPoint -
Josh_Main - 25.06.2013
Thanks so much!
Re: !IsPlayerInRangeOfPoint -
introzen - 25.06.2013
Quote:
Originally Posted by Josh_Main
Thanks so much!
|
No problem. Rep if it worked