Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dini>
- #include <sscanf2>
- #include <zcmd>
- #define MAX_LOCATIONS 50//cate locatii vrei
- #define DIALOG_GPS 90
- enum GPSDATA
- {
- ID,
- Name[50],
- Float:Posx,
- Float:Posy,
- Float:Posz,
- }
- new GPSInfo[MAX_LOCATIONS][GPSDATA];
- public OnFilterScriptInit()
- {
- LoadGPS();
- print("\n--------------------------------------");
- print(" GPS Dynamic System by Gireada");
- print("--------------------------------------\n");
- //SetTimer("SaveGPS", 2000, 1);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- main()
- {
- print("\n----------------------------------");
- print(" GPS Dynamic System by Gireada");
- print("----------------------------------\n");
- }
- CMD:addlocations(playerid, params[])
- {
- new name[50],file[256];
- if(!(IsPlayerAdmin(playerid))) return SendClientMessage(playerid, 0xFFFFFFFF, "You need to be RCON Admim to use this command.");
- if(unformat(params, "s[50]", name)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /addlocations <name>");
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid, x,y,z);
- for(new i=0;i<MAX_LOCATIONS;i++)
- {
- format(file,sizeof(file), "GPS/%i.ini",i);
- if(!(dini_Exists(file)))
- {
- dini_Create(file);
- CreateGPSLocation(i,name, x,y,z);break;
- }
- }
- return 1;
- }
- forward ShowPlayerLocation(playerid);
- public ShowPlayerLocation(playerid)
- {
- new string[1024],string2[256],file[256];
- for(new i=0;i<MAX_LOCATIONS;i++)
- {
- format(file,sizeof(file), "GPS/%i.ini",i);
- if(dini_Exists(file))
- {
- if(i==0)
- {
- format(string2, sizeof(string2), "ID:%d | Location: %s",i,GPSInfo[i][Name]);
- strcat(string, string2);
- }
- else
- {
- format(string2, sizeof(string2), "\nID:%d | Location: %s",i,GPSInfo[i][Name]);
- strcat(string, string2);
- }
- }
- else break;
- }
- ShowPlayerDialog(playerid, DIALOG_GPS, DIALOG_STYLE_LIST, "GPS LOCATION", string, "Accept", "Cancel");
- return 1;
- }
- CMD:gps(playerid, params[])
- {
- SetPlayerVirtualWorld(playerid, 0);
- ShowPlayerLocation(playerid);
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- for(new i=0;i<MAX_LOCATIONS;i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 2.0, GPSInfo[i][Posx], GPSInfo[i][Posy], GPSInfo[i][Posz]))
- {
- SendClientMessage(playerid, 0xFFFFFFFF,"Here is your locations");
- DisablePlayerCheckpoint(playerid);
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new string[256];
- if(response)
- {
- switch(dialogid)
- {
- case DIALOG_GPS:
- {
- SetPlayerCheckpoint(playerid, GPSInfo[listitem][Posx], GPSInfo[listitem][Posy], GPSInfo[listitem][Posz], 3.0);
- format(string, sizeof(string), "Checkpoint set to %s",GPSInfo[listitem][Name]);
- SendClientMessage(playerid, 0xFFFFFFFF,string);
- }
- }
- }
- return 0;
- }
- forward CreateGPSLocation(i,const Nume[], Float:x,Float:y,Float:z);
- public CreateGPSLocation(i,const Nume[], Float:x,Float:y,Float:z)
- {
- GPSInfo[i][ID] = i; format(GPSInfo[i][Name], 50, Nume);
- GPSInfo[i][Posx] = x; GPSInfo[i][Posy] = y; GPSInfo[i][Posz] = z;
- return 1;
- }
- forward LoadGPS();
- public LoadGPS()
- {
- new file[256];
- for(new i=0;i<=MAX_LOCATIONS;i++)
- {
- format(file,sizeof(file), "GPS/%i.ini",i);
- if(dini_Exists(file))
- {
- GPSInfo[i][ID] = dini_Int(file,"ID");
- format(GPSInfo[i][Name], 50, dini_Get(file,"Name"));
- GPSInfo[i][Posx] = dini_Float(file,"Posx");
- GPSInfo[i][Posy] = dini_Float(file,"Posy");
- GPSInfo[i][Posz] = dini_Float(file,"Posz");
- }
- }
- return 1;
- }
- forward SaveGPS();
- public SaveGPS()
- {
- new file[256];
- for(new i=0;i<=MAX_LOCATIONS;i++)
- {
- format(file,sizeof(file), "GPS/%i.ini",i);
- if(dini_Exists(file))
- {
- dini_IntSet(file,"ID",GPSInfo[i][ID]);
- dini_Set(file,"Name", GPSInfo[i][Name]);
- dini_FloatSet(file,"Posx",GPSInfo[i][Posx]);
- dini_FloatSet(file,"Posy",GPSInfo[i][Posy]);
- dini_FloatSet(file,"Posz",GPSInfo[i][Posz]);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement