Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <mapmark>
- new Float:GPSx[MAX_PLAYERS];
- new Float:GPSy[MAX_PLAYERS];
- new bool:GPSon[MAX_PLAYERS];
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/map", cmdtext, true) == 0)
- {
- SendClientMessage(playerid,0x00FF00FF,"Mark a position on the map to transmit it to the server!");
- SetPlayerMarkingMap(playerid,1);
- return 1;
- }
- if (strcmp("/gps", cmdtext, true) == 0)
- {
- SendClientMessage(playerid,0x00FF00FF,"Mark a position on the map to transmit it to the server!");
- SetPlayerMarkingMap(playerid,2);
- return 1;
- }
- return 0;
- }
- public OnPlayerMarkMap(playerid, MarkID, Float:X, Float:Y, Float:Z)
- {
- if(MarkID == 1)
- {
- SendClientMessage(playerid,0xFF0000FF,"MapIcon successfully set.");
- SetPlayerMapIcon(playerid,1,X,Y,Z,32,0,MAPICON_GLOBAL);
- }
- if(MarkID == 2)
- {
- GPSx[playerid] = X;
- GPSy[playerid] = Y;
- GPSon[playerid] = true;
- SetTimerEx("GPSTimer",3000,0,"d",playerid);
- }
- }
- forward GPSTimer(playerid);
- public GPSTimer(playerid)
- {
- if(!GPSon[playerid]) return 0;
- new Float: Distance;
- new Float:X, Float:Y, Float:Z;
- GetPlayerPos(playerid,X,Y,Z);
- if(IsPlayerInAnyVehicle(playerid)) GetVehiclePos(GetPlayerVehicleID(playerid),X,Y,Z);
- Distance = GDBP(X,Y,Z,GPSx[playerid],GPSy[playerid],Z);
- if(Distance > 10.0)
- {
- new str[128];
- format(str,sizeof(str),"~r~-GPS-~n~~g~Distance: %.2f",Distance);
- GameTextForPlayer(playerid,str,1000,4);
- SetTimerEx("GPSTimer",500,0,"d",playerid);
- }
- else
- {
- GameTextForPlayer(playerid,"~r~-GPS-~n~~g~Destination reached.",4000,4);
- GPSon[playerid] = false;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement