SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 27/07/2011, 07:04 AM   #1
budelis
Huge Clucker
 
Join Date: Jun 2011
Posts: 453
Reputation: 7
Default 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.
budelis is offline  
Old 27/07/2011, 07:08 AM   #2
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 2,630
Reputation: 410
Default Re: Nearest player

Read this thread

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

Then use OnPlayerKeyStateChange.
__________________
[HiC]TheKiller is offline  
Old 27/07/2011, 07:11 AM   #3
MyLife
Big Clucker
 
Join Date: Mar 2010
Posts: 79
Reputation: 2
Default 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) ; ..........
}
}

^_^
MyLife is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get nearest player austin070 Help Archive 2 04/03/2011 12:07 AM
get nearest point... Owenlishious Help Archive 0 23/01/2011 05:10 PM
[HELP]Get nearest to farthest WThieves Help Archive 2 15/06/2010 08:13 PM
SetPlayerAngle to nearest player.. wiilweer Help Archive 1 09/01/2010 12:19 PM
How can I get the vehicle which is the nearest to a player =? KIDUL Help Archive 1 04/11/2009 03:29 PM


All times are GMT. The time now is 03:37 PM.


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