View Full Version : Rob a player if no cops are near?

16/07/2013, 04:26 AM
Hey guys,

How do I make it so that I can rob a player if no cops are near? TEAM_COPS being the team of the cops (gteam). I've been trying for a while but it never works fine.

I know how to do the rob thing, but I don't know how to make it so that if there are cops in the distance of 100 it wont work.

16/07/2013, 06:31 AM
stock IsPlayerCloseToCops(playerid)
new bool:IsClose = false, Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
foreach(Player, i)
if(IsPlayerInRangeOfPoint(i, 60.0, Pos[0], Pos[1], Pos[2]))
if(gTeam[i] == TEAM_COPS)
IsClose = true;

return IsClose;

And you can use :
if(IsPlayerCloseToCops(playerid)) return SendClientMessage(playerid,-1,"Attention,There are cops near you.");

If you won't use foreach you can use this loop : for(new i=0; i < MAX_PLAYERS; i++)