SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Help Archive (https://forum.sa-mp.com/forumdisplay.php?f=89)
-   -   Nearest player (https://forum.sa-mp.com/showthread.php?t=272102)

budelis 27/07/2011 07:04 AM

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

[HiC]TheKiller 27/07/2011 07:08 AM

Re: Nearest player
 
Read this thread

http://forum.sa-mp.com/showthread.php?t=202122

Then use OnPlayerKeyStateChange.

MyLife 27/07/2011 07:11 AM

Re: Nearest player
 
pawn Code:
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) ; ..........
}
}

^_^


All times are GMT. The time now is 09:35 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.