[Help] Please, GPS System.
#1

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:
Код:
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;
}
thx a lot!
Reply
#2

I dont really get what you mean, but you might want to use "SetTimerEx();".
https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#3

Quote:
Originally Posted by Wesley221
Посмотреть сообщение
I dont really get what you mean, but you might want to use "SetTimerEx();".
https://sampwiki.blast.hk/wiki/SetTimerEx
His doing it fine, I mean I would perfer one timer than a server with heaps of players running a single timer at a time.

Does 'distance' work or what's the problem?
Reply
#4

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
His doing it fine, I mean I would perfer one timer than a server with heaps of players running a single timer at a time.

Does 'distance' work or what's the problem?
Yes, 'distance' works fine, but i must create a second "playerid" because I need to compare the distance.

Код:
/gps [id]

I must create a variable to set who i'm locating, for example:
PlayerInfo[playerid][pGps] = giveid;
After this, I create a loop to compare with this function "GetDistanceBetweenPlayers(i, PlayerInfo[i][pGps]);
I dont know if it's right, and sorry 4 my bad english.

thx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)