SA-MP Forums Archive
[Help] Please, GPS System. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help] Please, GPS System. (/showthread.php?tid=282007)



[Help] Please, GPS System. - Avalanche! - 09.09.2011

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!


Re: [Help] Please, GPS System. - Wesley221 - 09.09.2011

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


Re: [Help] Please, GPS System. - Lorenc_ - 09.09.2011

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?


Re: [Help] Please, GPS System. - Avalanche! - 09.09.2011

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