Hallo
kann mir einer schnall was machen sowie GetNearestPlayer
GetNearestPlayer(playerid,max_dist)
{
new Float:x1,Float:y1,Float:z1;
if (!IsPlayerConnected(playerid))
{
return -1;
}
GetPlayerPos(playerid,x1,y1,z1);
new closest = -1;
new closest_dist = -1;
new Float:dis,string[256];
new Float:x2,Float:y2,Float:z2;
for (new i; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i) && i != playerid)
{
GetPlayerPos(i,x2,y2,z2);
dis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
format(string, sizeof(string), "%f", dis);
if (strval(string) < closest_dist || closest_dist == -1)
{
if (strval(string) <= max_dist)
{
closest = i;
closest_dist = strval(string);
}
}
}
}
return closest;
}
Nur das halt mit Vehicle
MFG
Deathrunner