Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.83 KB | None | 0 0
  1. /*- Scripted by Vasic -*//*
  2. [!] Mozete odmah uzeti fs i staviti u fs folder. Radice svakako.
  3. [!] U folderu 'scriptfiles' morate imati kreiran fajl GPS.
  4. [!] Radjeno za Balkan SAMP i za Pocetnike skriptanja.
  5.  
  6. - Sistem koristi y_ini proces cuvanja, a zcmd proces komandi.
  7. - Verzija 1.1 ce se odraditi u MySQL bazi za servere koji koriste istu.
  8. - Credits to Y_Less & Zeex */
  9.  
  10. #include < a_samp >
  11. #include < zcmd >
  12. #include < YSI\y_ini >
  13. #include < sscanf2 >
  14.  
  15. #if defined FILTERSCRIPT
  16.  
  17. public OnFilterScriptInit()
  18. {
  19. print( "[!] Dynamic GPS System - by Vasic [v1.0 | Y_INI] [!]" );
  20. //
  21. for( new id = 1; id < MAX_GPSLOKACIJA; id++ ) //ukoliko ubacujete sistem u vas mod, ovo stavljate pod OnGameModeInit
  22. {
  23. new filename[ 32 ];
  24. format( filename, sizeof( filename ), GPS_FAJL, id );
  25. if(fexist(filename))
  26. {
  27. INI_ParseFile( filename, "ucitajga", .bExtra = true, .extra = id );
  28. }
  29. }
  30. return 1;
  31. }
  32. public OnFilterScriptExit()
  33. {
  34. return 1;
  35. }
  36.  
  37. #else
  38.  
  39. main()
  40. {
  41. // print("GPS Sistem uspesno ucitan...");
  42. }
  43.  
  44. #endif
  45.  
  46. new PokazivacGPS[MAX_PLAYERS];
  47.  
  48. #pragma tabsize 0 //ovo sam dodao jer me je mrzelo da poravnam linije -.-
  49.  
  50. #define gray "{C0C0C0}"//cisto da bude lepse, mozete ukloniti i prilagoditi
  51. #define blue "{0084E3}"//cisto da bude lepse, mozete ukloniti i prilagoditi
  52.  
  53. enum
  54. {
  55. DINAMICNI_GPS // ja sam ovo odradio u ENUMu, vi mozete definisati dialog default. (npr. #define DINAMICNI_GPS 1)
  56. }
  57.  
  58. #define GPS_FAJL "GPS/vasicgps_%i.ini"
  59. #define MAX_GPSLOKACIJA 30 //prilagoditi modu
  60.  
  61. new dialogstring[256];
  62.  
  63. enum GPSSyss
  64. {
  65. Float:pozicija[ 3 ],
  66. imelokacije[ 50 ]
  67. };
  68. new GPSPodaci[MAX_GPSLOKACIJA][GPSSyss];
  69. new gpsonoff[MAX_PLAYERS]; //dodajte kod ostalih definicija
  70.  
  71. stock SledeciGPS( const len )
  72. {
  73. new id = ( -1 );
  74. for( new loop = (0), provera = (-1), Data_[64] = "\0"; loop != len; ++ loop ) {
  75. provera = (loop+1);
  76. format( Data_, ( sizeof Data_ ), GPS_FAJL, provera );
  77. if( !fexist ( Data_ )) {
  78. id = ( provera );
  79. break; }
  80. }
  81. return id;
  82. }
  83.  
  84. forward SacuvajGPS(id);
  85. public SacuvajGPS(id) {
  86. new iFile[60];
  87. format(iFile, sizeof(iFile), GPS_FAJL, id);
  88. new INI:File = INI_Open(iFile);
  89. INI_WriteString( File, "ImeLokacije", GPSPodaci[ id ] [ imelokacije ]);
  90. INI_WriteFloat( File, "PosX", GPSPodaci[ id ][ pozicija ][ 0 ]);
  91. INI_WriteFloat( File, "PosY", GPSPodaci[ id ][ pozicija ][ 1 ]);
  92. INI_WriteFloat( File, "PosZ", GPSPodaci[ id ][ pozicija ][ 2 ]);
  93. INI_Close( File );
  94. return 1;
  95. }
  96.  
  97. forward ucitajga(id, name[], value[]);
  98. public ucitajga(id, name[], value[]) {
  99.  
  100. INI_String( "ImeLokacije", GPSPodaci[ id ] [imelokacije], 50);
  101. INI_Float( "PozicijaX", GPSPodaci[ id ] [pozicija][ 0 ]);
  102. INI_Float( "PozicijaY", GPSPodaci[ id ] [pozicija][ 1 ]);
  103. INI_Float( "PozicijaZ", GPSPodaci[ id ] [pozicija][ 2 ]);
  104. return 1;
  105. }
  106.  
  107. public OnGameModeInit()
  108. {
  109. // Don't use these lines if it's a filterscript
  110. SetGameModeText("Blank Script");
  111. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  112. return 1;
  113. }
  114.  
  115. public OnGameModeExit()
  116. {
  117. return 1;
  118. }
  119. public OnPlayerRequestClass(playerid, classid)
  120. {
  121. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  122. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  123. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  124. return 1;
  125. }
  126.  
  127. public OnPlayerConnect(playerid)
  128. {
  129. gpsonoff[playerid] = 0; //resetuje
  130. return 1;
  131. }
  132.  
  133. public OnPlayerDisconnect(playerid, reason)
  134. {
  135. return 1;
  136. }
  137.  
  138. public OnPlayerSpawn(playerid)
  139. {
  140. SendClientMessage(playerid, -1, ""blue"(( INFO )) - "gray"Komande sistema su /kreirajgps || /izbrisigps || /gpsoff || /gps");
  141. SendClientMessage(playerid, -1, ""blue"(( INFO )) - "gray"Sistem napravio - "blue"Vasic");
  142. return 1;
  143. }
  144.  
  145. public OnPlayerDeath(playerid, killerid, reason)
  146. {
  147. DisablePlayerCheckpoint(playerid);
  148. DestroyObject(PokazivacGPS[playerid]);
  149. gpsonoff[playerid] = 0;
  150. return 1;
  151. }
  152.  
  153. public OnVehicleSpawn(vehicleid)
  154. {
  155. return 1;
  156. }
  157.  
  158. public OnVehicleDeath(vehicleid, killerid)
  159. {
  160. return 1;
  161. }
  162.  
  163. public OnPlayerText(playerid, text[])
  164. {
  165. return 1;
  166. }
  167.  
  168. CMD:kreirajgps( playerid, params[ ] )
  169. {
  170. if(!IsPlayerAdmin(playerid)) return SendClientMessage( playerid, -1, ""blue"(( INFO )) - "gray"Niste Ovlasceni!" ); {
  171. new id = SledeciGPS( MAX_GPSLOKACIJA ), Float:PozX, Float:PozY, Float:PozZ, filename[ 60 ], namegps[ 50 ];
  172. format( filename, sizeof ( filename ), GPS_FAJL, id );
  173. if(fexist( filename ) ) return SendClientMessage(playerid,-1, ""blue"(( INFO )) - "gray"ID te gps lokacije vec postoji!");
  174. if(sscanf( params, "s[50]", namegps)) return SendClientMessage( playerid,-1 ,""blue"(( INFO )) - "gray"/kreirajgps [Ime Lokacije]" );
  175. if(strlen( namegps ) < 3 || strlen( namegps ) > 25 ) return SendClientMessage( playerid,-1, ""blue"(( INFO )) - "gray"Ne moze da postakooji vise od 25 znakova u tekstu." );
  176. GetPlayerPos( playerid, PozX, PozY, PozZ );
  177. GPSPodaci[ id ][ pozicija ] [ 0 ] = PozX;
  178. GPSPodaci[ id ][ pozicija ] [ 1 ] = PozY;
  179. GPSPodaci[ id ][ pozicija ] [ 2 ] = PozZ;
  180. strmid( GPSPodaci[ id ][ imelokacije ], namegps, 0, strlen( namegps ), 50 ); SacuvajGPS( id ); SendClientMessage(playerid,-1,""blue"(( INFO )) - "gray"Uspesno ste kreirali GPS lokaciju!"); }
  181. return 1;
  182. }
  183. CMD:gps( playerid, params[ ] )
  184. {
  185. if( gpsonoff[ playerid ] == 1 ) return SendClientMessage( playerid, -1, ""blue"(( INFO )) - "gray"Imate aktiviranu lokaciju, ugasite komandom - /gpsoff" );
  186. {
  187. strdel( dialogstring, 0, sizeof( dialogstring ));
  188. for(new i = 1; i < MAX_GPSLOKACIJA; i++)
  189. {
  190. new filename[ 32 ];
  191. format( filename, sizeof( filename ), GPS_FAJL, i );
  192. if(fexist(filename))
  193. if( fexist ( filename ) )
  194. {
  195. format( dialogstring, sizeof ( dialogstring ), "%s%s\n", dialogstring, GPSPodaci[ i ][ imelokacije ] );
  196. }
  197. }
  198. ShowPlayerDialog( playerid, DINAMICNI_GPS, DIALOG_STYLE_LIST, "GPS Sistem", dialogstring, "Odaberi", "Odustani" );
  199. }
  200. return 1;
  201. }
  202. CMD:gpsoff(playerid, params[])
  203. {
  204. if( gpsonoff [ playerid ] == 0) return SendClientMessage(playerid, -1, ""blue"(( INFO )) - "gray"Nemate aktiviranu nijednu lokaciju.");
  205. {
  206. DisablePlayerCheckpoint(playerid);
  207. DestroyObject(PokazivacGPS[playerid]);
  208. gpsonoff[playerid] = 0;
  209. GameTextForPlayer(playerid, "~y~gps ugasen...", 5000, 3);
  210. }
  211. return 1;
  212. }
  213. CMD:izbrisigps( playerid, params[ ] )
  214. {
  215. if(!IsPlayerAdmin(playerid)) return SendClientMessage( playerid, -1, ""blue"(( INFO )) - "gray"Niste Ovlasceni!" );
  216. {
  217. new targetid;
  218. new kFile[64];
  219. if(sscanf(params,"i",targetid)) return SendClientMessage(playerid,-1,""blue"(( INFO )) - "gray"/izbrisigps [ID]");
  220. format(kFile, sizeof(kFile), GPS_FAJL, targetid);
  221. if(fexist(kFile))
  222. {
  223. fremove(kFile); SendClientMessage(playerid,-1,""blue"(( INFO )) - "gray"Obrisali ste GPS Lokaciju!");
  224. }
  225. else
  226. {
  227. SendClientMessage(playerid,-1,""blue"(( INFO )) - "gray"Pogresan ID");
  228. }
  229. }
  230. return 1;
  231. }
  232. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  233. {
  234. return 1;
  235. }
  236.  
  237. public OnPlayerExitVehicle(playerid, vehicleid)
  238. {
  239. DestroyObject(PokazivacGPS[playerid]);
  240. return 1;
  241. }
  242.  
  243. public OnPlayerStateChange(playerid, newstate, oldstate)
  244. {
  245. return 1;
  246. }
  247.  
  248. public OnPlayerEnterCheckpoint(playerid)
  249. {
  250. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  251. if( gpsonoff[ playerid ] == 1 )
  252. {
  253. DisablePlayerCheckpoint( playerid );
  254. gpsonoff[ playerid ] = 0; GameTextForPlayer( playerid, "~y~stigli ste na lokaciju", 5000, 3 );
  255. DestroyObject(PokazivacGPS[playerid]);
  256. }
  257. return 1;
  258. }
  259.  
  260. public OnPlayerLeaveCheckpoint(playerid)
  261. {
  262. return 1;
  263. }
  264.  
  265. public OnPlayerEnterRaceCheckpoint(playerid)
  266. {
  267. return 1;
  268. }
  269.  
  270. public OnPlayerLeaveRaceCheckpoint(playerid)
  271. {
  272. return 1;
  273. }
  274.  
  275. public OnRconCommand(cmd[])
  276. {
  277. return 1;
  278. }
  279.  
  280. public OnPlayerRequestSpawn(playerid)
  281. {
  282. return 1;
  283. }
  284.  
  285. public OnObjectMoved(objectid)
  286. {
  287. return 1;
  288. }
  289.  
  290. public OnPlayerObjectMoved(playerid, objectid)
  291. {
  292. return 1;
  293. }
  294.  
  295. public OnPlayerPickUpPickup(playerid, pickupid)
  296. {
  297. return 1;
  298. }
  299.  
  300. public OnVehicleMod(playerid, vehicleid, componentid)
  301. {
  302. return 1;
  303. }
  304.  
  305. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  306. {
  307. return 1;
  308. }
  309.  
  310. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  311. {
  312. return 1;
  313. }
  314.  
  315. public OnPlayerSelectedMenuRow(playerid, row)
  316. {
  317. return 1;
  318. }
  319.  
  320. public OnPlayerExitedMenu(playerid)
  321. {
  322. return 1;
  323. }
  324.  
  325. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  326. {
  327. return 1;
  328. }
  329.  
  330. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  331. {
  332. return 1;
  333. }
  334.  
  335. public OnRconLoginAttempt(ip[], password[], success)
  336. {
  337. return 1;
  338. }
  339. stock Float:KreirajStrelicu(playerid, Float:xa, Float:ya, Float:xb, Float:yb)
  340. {
  341. new Float:carangle;
  342. new Float:xc, Float:yc;
  343. new Float:angle;
  344. xc = floatabs(floatsub(xa,xb));
  345. yc = floatabs(floatsub(ya,yb));
  346. if (yc == 0.0 || xc == 0.0)
  347. {
  348. if(yc == 0 && xc > 0) angle = 0.0;
  349. else if(yc == 0 && xc < 0) angle = 180.0;
  350. else if(yc > 0 && xc == 0) angle = 90.0;
  351. else if(yc < 0 && xc == 0) angle = 270.0;
  352. else if(yc == 0 && xc == 0) angle = 0.0;
  353. }
  354. else
  355. {
  356. angle = atan(xc/yc);
  357. if(xb > xa && yb <= ya) angle += 90.0;
  358. else if(xb <= xa && yb < ya) angle = floatsub(90.0, angle);
  359. else if(xb < xa && yb >= ya) angle -= 90.0;
  360. else if(xb >= xa && yb > ya) angle = floatsub(270.0, angle);
  361. }
  362. GetVehicleZAngle(GetPlayerVehicleID(playerid), carangle);
  363. return floatadd(angle, -carangle);
  364. }
  365.  
  366. public OnPlayerUpdate(playerid)
  367. {
  368. if(gpsonoff[playerid] == 1)
  369. {
  370. new Float:Rotacija, Float:strelica;
  371. Rotacija = KreirajStrelicu(playerid, strelica,GPSPodaci[ playerid ][ pozicija ][ 0 ],GPSPodaci[ playerid ][ pozicija ][ 1 ],GPSPodaci[ playerid ][ pozicija ][ 2 ]);
  372. AttachObjectToVehicle(PokazivacGPS[playerid], GetPlayerVehicleID(playerid), 0.0, 0.0, 1.5, 0.0, 90.0, Rotacija);
  373. }
  374. return 1;
  375. }
  376.  
  377. public OnPlayerStreamIn(playerid, forplayerid)
  378. {
  379. return 1;
  380. }
  381.  
  382. public OnPlayerStreamOut(playerid, forplayerid)
  383. {
  384. return 1;
  385. }
  386.  
  387. public OnVehicleStreamIn(vehicleid, forplayerid)
  388. {
  389. return 1;
  390. }
  391.  
  392. public OnVehicleStreamOut(vehicleid, forplayerid)
  393. {
  394. return 1;
  395. }
  396.  
  397. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  398. {
  399. if( dialogid == DINAMICNI_GPS )
  400. {
  401. if( !response ) return true;
  402. if( response )
  403. {
  404. listitem++;
  405. gpsonoff[ playerid ] = 1;
  406. SetPlayerCheckpoint( playerid, GPSPodaci[ listitem ][ pozicija ][ 0 ], GPSPodaci[ listitem ] [ pozicija ][ 1 ], GPSPodaci[ listitem ][ pozicija ][ 2 ], 3);
  407. PokazivacGPS[playerid] = CreateObject(1318, 0, 0, 0, 0.0, 0.0, 0);
  408. }
  409. }
  410. return 1;
  411. }
  412. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  413. {
  414. return 1;
  415. }
  416. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement