error 017: undefined symbol "pos1X" and another warning -
NoahF - 28.06.2015
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;
}
Re: error 017: undefined symbol "pos1X" and another warning -
Alex Magaсa - 28.06.2015
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.!
Re: error 017: undefined symbol "pos1X" and another warning -
Banana_Ghost - 29.06.2015
PHP код:
Float:GetDistanceBetweenPoints(Float:pos1X, Float:pos1Y, Float:pos1Z, Float:pos2X, Float:pos2Y, Float:pos2Z)
{
return floatadd(floatadd(floatsqroot(floatpower(floatsub(pos1X, pos2X), 2)), floatsqroot(floatpower(floatsub(pos1Y, pos2Y), 2))), floatsqroot(floatpower(floatsub(pos1Z, pos2Z), 2)));
}
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(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) == 1 && floatcmp(limit,Range) == 1)
{
Range = Dist;
id = i;
}
}
}
return id;
}
CMD:getclosestplayer(playerid, params[]){
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(id, pname, sizeof(pname));
format(str, sizeof(str), "%s is the closest player to you.", pname);
SendClientMessage(playerid, -1, str);
}
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.