GTAOnline.net

San Andreas Multiplayer (sa:mp) => Problèmes et bugs => Discussion démarrée par: yhaabb le 02 Août 2012, 02:45:47

Titre: GetDistance
Posté par: yhaabb le 02 Août 2012, 02:45:47
Salut.

J'ai trouvé ce code sur Internet afin de mettre des distances pour le chat...

public OnPlayerText(playerid,text[])
{
new Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:z2 ,Float:dist,string[128],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string),"%s dit: %s",name,text);
GetPlayerPos(playerid,x,y,z);
for(new i=0;i<MAX_PLAYERS;i++)
{
if (!IsPlayerConnected(i)) continue;
GetPlayerPos(i,x2,y2,z2);
dist = GetDistance(x,y,z,x2,y2,z2);
if (dist<1.0) SendClientMessage(i,0xFFFFFFAA,string);
else if (dist<2.0) SendClientMessage(i,0xFFFFFFAA,string);
else if (dist<4.0) SendClientMessage(i,0xFFFFFFAA,string);
else if (dist<6.0) SendClientMessage(i,0xFFFFFFAA,string);
else if (dist<8.0) SendClientMessage(i,0xFFFFFFAA,string);
}
return 0;
}

Sauf que quand je compile j'obtiens "undefined symbol "GetDistance""

Donc, si on pouvait m'aidé sur sa plz. :)

Merci.
Titre: Re : GetDistance
Posté par: Ssk le 02 Août 2012, 04:50:32
Peut être que la fonction n'existe pas dans ton script, sans parler du fait que la distance est inutile dans ton script vu que tu fais la même pour toute les distances lol
Titre: Re : GetDistance
Posté par: Alexandre_Leborgn le 03 Août 2012, 05:02:45
la fonction :

Citer
stock GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 )
{
    return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) ) );
}