GetClosestPlayerWhosWanted. - 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: GetClosestPlayerWhosWanted. (
/showthread.php?tid=309097)
GetClosestPlayerWhosWanted. -
DarkKillerWithPride<3 - 06.01.2012
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
Re: GetClosestPlayerWhosWanted. -
FuTuяe - 06.01.2012
Use IsPlayerInRangeOfPoint.
Re: GetClosestPlayerWhosWanted. -
DarkKillerWithPride<3 - 06.01.2012
how?
Re: GetClosestPlayerWhosWanted. -
DarkKillerWithPride<3 - 06.01.2012
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