Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*- Scripted by Vasic -*//*
- [!] Mozete odmah uzeti fs i staviti u fs folder. Radice svakako.
- [!] U folderu 'scriptfiles' morate imati kreiran fajl GPS.
- [!] Radjeno za Balkan SAMP i za Pocetnike skriptanja.
- - Sistem koristi y_ini proces cuvanja, a zcmd proces komandi.
- - Verzija 1.1 ce se odraditi u MySQL bazi za servere koji koriste istu.
- - Credits to Y_Less & Zeex */
- #include < a_samp >
- #include < zcmd >
- #include < YSI\y_ini >
- #include < sscanf2 >
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print( "[!] Dynamic GPS System - by Vasic [v1.0 | Y_INI] [!]" );
- //
- for( new id = 1; id < MAX_GPSLOKACIJA; id++ ) //ukoliko ubacujete sistem u vas mod, ovo stavljate pod OnGameModeInit
- {
- new filename[ 32 ];
- format( filename, sizeof( filename ), GPS_FAJL, id );
- if(fexist(filename))
- {
- INI_ParseFile( filename, "ucitajga", .bExtra = true, .extra = id );
- }
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- // print("GPS Sistem uspesno ucitan...");
- }
- #endif
- new PokazivacGPS[MAX_PLAYERS];
- #pragma tabsize 0 //ovo sam dodao jer me je mrzelo da poravnam linije -.-
- #define gray "{C0C0C0}"//cisto da bude lepse, mozete ukloniti i prilagoditi
- #define blue "{0084E3}"//cisto da bude lepse, mozete ukloniti i prilagoditi
- enum
- {
- DINAMICNI_GPS // ja sam ovo odradio u ENUMu, vi mozete definisati dialog default. (npr. #define DINAMICNI_GPS 1)
- }
- #define GPS_FAJL "GPS/vasicgps_%i.ini"
- #define MAX_GPSLOKACIJA 30 //prilagoditi modu
- new dialogstring[256];
- enum GPSSyss
- {
- Float:pozicija[ 3 ],
- imelokacije[ 50 ]
- };
- new GPSPodaci[MAX_GPSLOKACIJA][GPSSyss];
- new gpsonoff[MAX_PLAYERS]; //dodajte kod ostalih definicija
- stock SledeciGPS( const len )
- {
- new id = ( -1 );
- for( new loop = (0), provera = (-1), Data_[64] = "\0"; loop != len; ++ loop ) {
- provera = (loop+1);
- format( Data_, ( sizeof Data_ ), GPS_FAJL, provera );
- if( !fexist ( Data_ )) {
- id = ( provera );
- break; }
- }
- return id;
- }
- forward SacuvajGPS(id);
- public SacuvajGPS(id) {
- new iFile[60];
- format(iFile, sizeof(iFile), GPS_FAJL, id);
- new INI:File = INI_Open(iFile);
- INI_WriteString( File, "ImeLokacije", GPSPodaci[ id ] [ imelokacije ]);
- INI_WriteFloat( File, "PosX", GPSPodaci[ id ][ pozicija ][ 0 ]);
- INI_WriteFloat( File, "PosY", GPSPodaci[ id ][ pozicija ][ 1 ]);
- INI_WriteFloat( File, "PosZ", GPSPodaci[ id ][ pozicija ][ 2 ]);
- INI_Close( File );
- return 1;
- }
- forward ucitajga(id, name[], value[]);
- public ucitajga(id, name[], value[]) {
- INI_String( "ImeLokacije", GPSPodaci[ id ] [imelokacije], 50);
- INI_Float( "PozicijaX", GPSPodaci[ id ] [pozicija][ 0 ]);
- INI_Float( "PozicijaY", GPSPodaci[ id ] [pozicija][ 1 ]);
- INI_Float( "PozicijaZ", GPSPodaci[ id ] [pozicija][ 2 ]);
- return 1;
- }
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- gpsonoff[playerid] = 0; //resetuje
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SendClientMessage(playerid, -1, ""blue"(( INFO )) - "gray"Komande sistema su /kreirajgps || /izbrisigps || /gpsoff || /gps");
- SendClientMessage(playerid, -1, ""blue"(( INFO )) - "gray"Sistem napravio - "blue"Vasic");
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- DisablePlayerCheckpoint(playerid);
- DestroyObject(PokazivacGPS[playerid]);
- gpsonoff[playerid] = 0;
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- CMD:kreirajgps( playerid, params[ ] )
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage( playerid, -1, ""blue"(( INFO )) - "gray"Niste Ovlasceni!" ); {
- new id = SledeciGPS( MAX_GPSLOKACIJA ), Float:PozX, Float:PozY, Float:PozZ, filename[ 60 ], namegps[ 50 ];
- format( filename, sizeof ( filename ), GPS_FAJL, id );
- if(fexist( filename ) ) return SendClientMessage(playerid,-1, ""blue"(( INFO )) - "gray"ID te gps lokacije vec postoji!");
- if(sscanf( params, "s[50]", namegps)) return SendClientMessage( playerid,-1 ,""blue"(( INFO )) - "gray"/kreirajgps [Ime Lokacije]" );
- if(strlen( namegps ) < 3 || strlen( namegps ) > 25 ) return SendClientMessage( playerid,-1, ""blue"(( INFO )) - "gray"Ne moze da postakooji vise od 25 znakova u tekstu." );
- GetPlayerPos( playerid, PozX, PozY, PozZ );
- GPSPodaci[ id ][ pozicija ] [ 0 ] = PozX;
- GPSPodaci[ id ][ pozicija ] [ 1 ] = PozY;
- GPSPodaci[ id ][ pozicija ] [ 2 ] = PozZ;
- strmid( GPSPodaci[ id ][ imelokacije ], namegps, 0, strlen( namegps ), 50 ); SacuvajGPS( id ); SendClientMessage(playerid,-1,""blue"(( INFO )) - "gray"Uspesno ste kreirali GPS lokaciju!"); }
- return 1;
- }
- CMD:gps( playerid, params[ ] )
- {
- if( gpsonoff[ playerid ] == 1 ) return SendClientMessage( playerid, -1, ""blue"(( INFO )) - "gray"Imate aktiviranu lokaciju, ugasite komandom - /gpsoff" );
- {
- strdel( dialogstring, 0, sizeof( dialogstring ));
- for(new i = 1; i < MAX_GPSLOKACIJA; i++)
- {
- new filename[ 32 ];
- format( filename, sizeof( filename ), GPS_FAJL, i );
- if(fexist(filename))
- if( fexist ( filename ) )
- {
- format( dialogstring, sizeof ( dialogstring ), "%s%s\n", dialogstring, GPSPodaci[ i ][ imelokacije ] );
- }
- }
- ShowPlayerDialog( playerid, DINAMICNI_GPS, DIALOG_STYLE_LIST, "GPS Sistem", dialogstring, "Odaberi", "Odustani" );
- }
- return 1;
- }
- CMD:gpsoff(playerid, params[])
- {
- if( gpsonoff [ playerid ] == 0) return SendClientMessage(playerid, -1, ""blue"(( INFO )) - "gray"Nemate aktiviranu nijednu lokaciju.");
- {
- DisablePlayerCheckpoint(playerid);
- DestroyObject(PokazivacGPS[playerid]);
- gpsonoff[playerid] = 0;
- GameTextForPlayer(playerid, "~y~gps ugasen...", 5000, 3);
- }
- return 1;
- }
- CMD:izbrisigps( playerid, params[ ] )
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage( playerid, -1, ""blue"(( INFO )) - "gray"Niste Ovlasceni!" );
- {
- new targetid;
- new kFile[64];
- if(sscanf(params,"i",targetid)) return SendClientMessage(playerid,-1,""blue"(( INFO )) - "gray"/izbrisigps [ID]");
- format(kFile, sizeof(kFile), GPS_FAJL, targetid);
- if(fexist(kFile))
- {
- fremove(kFile); SendClientMessage(playerid,-1,""blue"(( INFO )) - "gray"Obrisali ste GPS Lokaciju!");
- }
- else
- {
- SendClientMessage(playerid,-1,""blue"(( INFO )) - "gray"Pogresan ID");
- }
- }
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- DestroyObject(PokazivacGPS[playerid]);
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- if( gpsonoff[ playerid ] == 1 )
- {
- DisablePlayerCheckpoint( playerid );
- gpsonoff[ playerid ] = 0; GameTextForPlayer( playerid, "~y~stigli ste na lokaciju", 5000, 3 );
- DestroyObject(PokazivacGPS[playerid]);
- }
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- stock Float:KreirajStrelicu(playerid, Float:xa, Float:ya, Float:xb, Float:yb)
- {
- new Float:carangle;
- new Float:xc, Float:yc;
- new Float:angle;
- xc = floatabs(floatsub(xa,xb));
- yc = floatabs(floatsub(ya,yb));
- if (yc == 0.0 || xc == 0.0)
- {
- if(yc == 0 && xc > 0) angle = 0.0;
- else if(yc == 0 && xc < 0) angle = 180.0;
- else if(yc > 0 && xc == 0) angle = 90.0;
- else if(yc < 0 && xc == 0) angle = 270.0;
- else if(yc == 0 && xc == 0) angle = 0.0;
- }
- else
- {
- angle = atan(xc/yc);
- if(xb > xa && yb <= ya) angle += 90.0;
- else if(xb <= xa && yb < ya) angle = floatsub(90.0, angle);
- else if(xb < xa && yb >= ya) angle -= 90.0;
- else if(xb >= xa && yb > ya) angle = floatsub(270.0, angle);
- }
- GetVehicleZAngle(GetPlayerVehicleID(playerid), carangle);
- return floatadd(angle, -carangle);
- }
- public OnPlayerUpdate(playerid)
- {
- if(gpsonoff[playerid] == 1)
- {
- new Float:Rotacija, Float:strelica;
- Rotacija = KreirajStrelicu(playerid, strelica,GPSPodaci[ playerid ][ pozicija ][ 0 ],GPSPodaci[ playerid ][ pozicija ][ 1 ],GPSPodaci[ playerid ][ pozicija ][ 2 ]);
- AttachObjectToVehicle(PokazivacGPS[playerid], GetPlayerVehicleID(playerid), 0.0, 0.0, 1.5, 0.0, 90.0, Rotacija);
- }
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if( dialogid == DINAMICNI_GPS )
- {
- if( !response ) return true;
- if( response )
- {
- listitem++;
- gpsonoff[ playerid ] = 1;
- SetPlayerCheckpoint( playerid, GPSPodaci[ listitem ][ pozicija ][ 0 ], GPSPodaci[ listitem ] [ pozicija ][ 1 ], GPSPodaci[ listitem ][ pozicija ][ 2 ], 3);
- PokazivacGPS[playerid] = CreateObject(1318, 0, 0, 0, 0.0, 0.0, 0);
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement