Rob a player if no cops are near?
#1

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.
Reply
#2

pawn Код:
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 :
pawn Код:
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++)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)