IsPlayerInRangeOfPoint Question -
jakejohnsonusa - 22.11.2012
How do I detect if a player is in range of IsACop (cops in my GM). I would like to make a police radar detector, I just need to know how I would set it up...
Thanks:
jakejohnsonusa
AW: IsPlayerInRangeOfPoint Question -
Skimmer - 22.11.2012
Like this?
pawn Код:
if (strcmp("/radar", cmdtext, true, 10) == 0)
{
if(!IsACop(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You aren't a cop.");
new counter = 0, string[268], player[268];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z) && i != playerid && IsPlayerConnected(i))
{
counter++;
}
}
if(counter == 0) return SendClientMessage(playerid, 0xFF0000FF, "No one is in your range.");
strdel(string, 0, strlen(string));
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z) && i != playerid && IsPlayerConnected(i))
{
format(player, sizeof(player), "%s (%d)\n", Nick(i), i);
strins(string, player, strlen(string), sizeof(string));
}
}
ShowPlayerDialog(playerid, DIALOG_RADAR, DIALOG_STYLE_MSGBOX, "Radar", string, "Okay", "");
strdel(string, 0, strlen(string));
return 1;
}
Re: IsPlayerInRangeOfPoint Question -
jakejohnsonusa - 22.11.2012
It will detect if a Police is near the player that uses /detector
AW: IsPlayerInRangeOfPoint Question -
Skimmer - 22.11.2012
Here
pawn Код:
if (strcmp("/radar", cmdtext, true, 10) == 0)
{
new counter = 0, string[268], player[268];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z) && i != playerid && IsPlayerConnected(i) && IsACop(i))
{
counter++;
}
}
if(counter == 0) return SendClientMessage(playerid, 0xFF0000FF, "No one is in your range.");
strdel(string, 0, strlen(string));
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z) && i != playerid && IsPlayerConnected(i) && IsACop(i))
{
format(player, sizeof(player), "%s (%d)\n", Nick(i), i);
strins(string, player, strlen(string), sizeof(string));
}
}
ShowPlayerDialog(playerid, DIALOG_RADAR, DIALOG_STYLE_MSGBOX, "Radar", string, "Okay", "");
strdel(string, 0, strlen(string));
return 1;
}
Re: IsPlayerInRangeOfPoint Question -
jakejohnsonusa - 22.11.2012
This will alert the player that a Police Officer is nearby? I would like it to constantly check for officers (so while they are driving if an officer starts to drive in the area around them they will get a message "Law Enforcment Detected"
How would I do that with the script you gave me... Also +1 Rep.
Thanks: jakejohnsonusa
AW: IsPlayerInRangeOfPoint Question -
Skimmer - 22.11.2012
Yes, and it will show the name of the cops.
I forgot to post the stock function for getting players name. Copy this anywhere in your script.
pawn Код:
stock Nick(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
Re: IsPlayerInRangeOfPoint Question -
jakejohnsonusa - 22.11.2012
Would you mind //the part that does that, tells the cops name... Please and thanks
AW: IsPlayerInRangeOfPoint Question -
Skimmer - 22.11.2012
It works now or? If yes no problem
Re: IsPlayerInRangeOfPoint Question -
jakejohnsonusa - 22.11.2012
I get these errors with the script:
Код:
C:\Users\Michael Fagel\Desktop\larp.pwn(38418) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Michael\Desktop\larp.pwn(38419) : warning 217: loose indentation
C:\Users\Michael\Desktop\larp.pwn(38421) : error 017: undefined symbol "x"
C:\Users\Michael\Desktop\larp.pwn(38430) : error 017: undefined symbol "x"
C:\Users\Michael\Desktop\larp.pwn(38436) : error 017: undefined symbol "DIALOG_RADAR"
AW: IsPlayerInRangeOfPoint Question -
Skimmer - 22.11.2012
Try this
pawn Код:
if (strcmp("/radar", cmdtext, true, 10) == 0)
{
new counter = 0, player[268];
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z) && i != playerid && IsPlayerConnected(i) && IsACop(i))
{
counter++;
}
}
if(counter == 0) return SendClientMessage(playerid, 0xFF0000FF, "No one is in your range.");
strdel(string, 0, strlen(string));
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z) && i != playerid && IsPlayerConnected(i) && IsACop(i))
{
format(player, sizeof(player), "%s (%d)\n", Nick(i), i);
strins(string, player, strlen(string), sizeof(string));
}
}
ShowPlayerDialog(playerid, 1592, DIALOG_STYLE_MSGBOX, "Radar", string, "Okay", "");
strdel(string, 0, strlen(string));
return 1;
}