GetClosestPlayerWhosWanted.
#1

Hey,

I have this stock function in my script and was wondering how I would make it so that a police officer can use it to arrest the player:

pawn Код:
stock GetClosestWantedPlayer(playerid,Float:limit)
{
    new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
    GetPlayerPos(playerid,x1,y1,z1);
    new Float:Range = 999.9;
    new id = -1;
    foreach(Player,i)
    {
        if(gTeam[i] == TEAM_CIVIL && GetPlayerWantedLevel(i))
        {
            if(playerid != i)
            {
                GetPlayerPos(i,x2,y2,z2);
                new Float:Dist = GetDistanceBetweenPoints(x1,y1,z1,x2,y2,z2);
                if(floatcmp(Range,Dist) == 1 && floatcmp(limit,Range) == 1)
                {
                    Range = Dist;
                    id = i;
                }
            }
        }
    }
    return id;
}
how would I make a command /arrest for the police officer to arrest if there is a suspect near by?

Thanks,

-Dark
Reply
#2

Use IsPlayerInRangeOfPoint.
Reply
#3

how?
Reply
#4

was thinking more like this:

pawn Код:
CMD:arrest(playerid,params[])
{
    new giveplayerid;
    if(gTeam[playerid] == TEAM_COP || PlayerInfo[playerid][pAdmin] >= 1)
    {
            if(GetPlayerWantedLevel(GetClosestWantedPlayer(playerid,2)) == 4)
            {
                SendPlayerToJail(giveplayerid,1,1);
            }
            if(GetPlayerWantedLevel(GetClosestWantedPlayer(playerid,2)) == 5)
            {
                SendPlayerToJail(giveplayerid,3,1);
            }
            if(GetPlayerWantedLevel(GetClosestWantedPlayer(playerid,2)) >= 6)
            {
                SendPlayerToJail(giveplayerid,5,1);
            }
    }
    return 1;
}
It's just a matter of getting the ID
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)