error 017: undefined symbol "pos1X" and another warning
#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


Messages In This Thread
error 017: undefined symbol "pos1X" and another warning - by NoahF - 28.06.2015, 21:08
Re: error 017: undefined symbol "pos1X" and another warning - by Alex Magaсa - 28.06.2015, 21:29
Re: error 017: undefined symbol "pos1X" and another warning - by Banana_Ghost - 29.06.2015, 09:23

Forum Jump:


Users browsing this thread: 1 Guest(s)