error 017: undefined symbol "pos1X" and another warning
#1

here's the undefined symbol line:
Код:
new Float:Dist = GetDistanceBetweenPoints(pos1X,pos1Y,pos1Z,pos2X,pos2Y,pos2Z);
Here's the warning:
Код:
(2985) : warning 202: number of arguments does not match definition
and heres line 2985:
Код:
id = GetClosestPlayer(playerid)
here's getclosestplayer:
Код:
stock GetClosestPlayer(playerid,Float:limit)
{
	new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
	GetPlayerPos(playerid,x1,y1,z1);
	new Float:Range = 3.0;
	new id = -1;
	foreach(Player,i)
	{
		if(playerid != i)
		{
			GetPlayerPos(i,x2,y2,z2);
			new Float:Dist = GetDistanceBetweenPoints(pos1X,pos1Y,pos1Z,pos2X,pos2Y,pos2Z);
			if(floatcmp(Range,Dist) == 1 && floatcmp(limit,Range) == 1)
			{
				Range = Dist;
				id = i;
			}
		}
	}
	return id;
}
Reply
#2

About PosX1 i will think about it so i wont make a mistake.!
https://sampwiki.blast.hk/wiki/Useful_F...tClosestPlayer This tutorial will help you.!
Reply
#3

PHP код:
Float:GetDistanceBetweenPoints(Float:pos1XFloat:pos1YFloat:pos1ZFloat:pos2XFloat:pos2YFloat:pos2Z)
{
    return 
floatadd(floatadd(floatsqroot(floatpower(floatsub(pos1Xpos2X), 2)), floatsqroot(floatpower(floatsub(pos1Ypos2Y), 2))), floatsqroot(floatpower(floatsub(pos1Zpos2Z), 2)));
}
stock GetClosestPlayer(playerid,Float:limit)
{
    new 
Float:x1Float:y1Float:z1Float:x2Float:y2Float:z2;
    
GetPlayerPos(playerid,x1,y1,z1);
    new 
Float:Range 3.0;
    new 
id = -1;
    foreach(
Player,i)
    {
        if(
playerid != i)
        {
            
GetPlayerPos(i,x2,y2,z2);
            new 
Float:Dist GetDistanceBetweenPoints(x1,y1,z1,x2,y2,z2); //Those variables weren't defined as what you had, so they were replaced with the original ones.
            
if(floatcmp(Range,Dist) == && floatcmp(limit,Range) == 1)
            {
                
Range Dist;
                
id i;
            }
        }
    }
    return 
id;
}
CMD:getclosestplayer(playeridparams[]){
    new
        
id GetClosestPlayer(playerid,15.0);//You were missing the radius parameter.
        
    
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,-1,"That player isn't connected.");
    else{
    
        new
            
str[64],pname[MAX_PLAYER_NAME];
            
        
GetPlayerName(idpnamesizeof(pname));
        
format(strsizeof(str), "%s is the closest player to you."pname);
        
SendClientMessage(playerid, -1str);
    }
    return 
1;

The variables in the GetClosestPlayer function were incorrect as well as you didn't specify a radius for the function to use during calculation.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)