09.09.2011, 01:39
What can I put on my function "GPSUpdate"?
I must check position between 2 players, but in "GPSUpdate" i must use only 1 var "i" (cuz is from my loop).
for example:
thx a lot!
I must check position between 2 players, but in "GPSUpdate" i must use only 1 var "i" (cuz is from my loop).
for example:
Код:
public GPSUpdate()
{
new string[128];
for(new i = 0; i < MAX_PLAYERS; ++i)
{
if(PlayerInfo[i][pGPS] != INVALID_PLAYER_ID)
{
if(IsPlayerConnected(PlayerInfo[i][pGPS]))
{
new Distance;
new Float:X, Float:Y, Float:Z;
new Float:X2, Float:Y2, Float:Z2;
GetPlayerPos(i, X, Y, Z);
GetPlayerPos(PlayerInfo[i][pGPS], X2, Y2, Z2);
Distance = floatround(floatsqroot(floatadd(floatadd(floatpower(floatabs(floatsub(X,X2)),2),floatpower(floatabs(floatsub(Y,Y2)),2)),floatpower(floatabs(floatsub(Z,Z2)),2))));
format(string, sizeof(string), "- %s -~n~city:~w~ %s ~l~- ~p~Distance: ~w~%dm", PlayerName(i), GetPlayerCity(i), Distance);
TextDrawSetString(GPS[i], string);
}
else
{
SendClientMessage(i, COLOR_LIGHTRED, "error, gps must be turned off");
PlayerInfo[i][pGPS] = INVALID_PLAYER_ID;
}
}
}
return 1;
}


