SA-MP Forums Archive
Nearest player - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Nearest player (/showthread.php?tid=272102)



Nearest player - budelis - 27.07.2011

Hi all.I need some help to do that,when any player press alt key and for nearest player,nearest player get freeze.


Re: Nearest player - [HiC]TheKiller - 27.07.2011

Read this thread

https://sampforum.blast.hk/showthread.php?tid=202122

Then use OnPlayerKeyStateChange.


Re: Nearest player - MyLife - 27.07.2011

pawn Код:
stock GetClosestPlayer(p1)
{
    new x,Float:dis,Float:dis2,player;
    player = -1;
    dis = 99999.99;
    for (x=0;x<MAX_PLAYERS;x++)
    {
        if(IsPlayerConnected(x))
        {
            if(x != p1)
            {
                dis2 = GetDistanceBetweenPlayers(x,p1);
                if(dis2 < dis && dis2 != -1.00)
                {
                    dis = dis2;
                    player = x;
                }
            }
        }
    }
    return player;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new vm = GetClosestPlayer(playerid);
new Float:xyz[3];
GetPlayerPos(vm,xyz[0],xyz[1],xyz[2]);
if(IsPlayerInRangeOfPoint(playerid,2.0,xyz[0],xyz[1],xyz[2]))
{
...... TogglePlayerControllable(vm,0) ; ..........
}
}
^_^