Guest User

Untitled

a guest
Mar 23rd, 2011
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.26 KB | None | 0 0
  1. /*
  2. ================================================================================
  3. Phanto's Script
  4. ________________________________________________________________________________
  5. •Script: PRaceSystem •Scripter: Phanto90
  6. •Type: FS •File size: 46 Kb(.pwn) / 57 Kb(.amx)
  7. •Lines: 1013 •Version: 1.2v
  8. ________________________________________________________________________________
  9. * Description *
  10.  
  11. Tired of your server modes? No problem! Here it is a nice FS that allows you to
  12. play races on your server! Added also a in-game race editor!
  13. In the version 1.2 it has been added the new race type "Chase"
  14.  
  15. System:
  16. •3 types of races: Circuit, Sprint & Chase.
  17. •You can build your own race in few minutes thanks to the powerful editor.
  18. •Different players can race different tracks at the same time.
  19. •Functional & nice system
  20.  
  21. Fixed bug & add-on:
  22. -Version 1.1
  23. •Fixed a bug /quitrace when race isn't started yet.
  24. •Added a nice ingame race editor
  25. -Version 1.2
  26. •Added new race type "Chase"
  27. •Modified the Race Edior to build also Chase Races.
  28.  
  29. Note: Old race.txt are no longer compatible. Change the races in scriptfiles
  30. with the new one instead.
  31.  
  32.  
  33. Thanks for choosing Pawnoscripter!
  34. http://pawnoscripter.forumfree.it
  35.  
  36. Phanto90
  37. ________________________________________________________________________________
  38.  
  39. Do not remove credits.
  40. ================================================================================
  41. */
  42. #include <a_samp>
  43. //===============MODIFICABILI
  44. #define TELETRASPORTO_INIZIAGARA // Comment to disable teleport to the starting checkpoint
  45. #define MAX_GARE 20
  46. #define MAX_CHECKPOINT 700
  47. //===============COLORI
  48. #define ROSSO 0xFF3233FF
  49. #define BIANCO 0xFFFFFFFF
  50. #define VERDE 0x00FF00FF
  51. #define TURCHESE 0x3C93FFFF
  52. //================DIALOG
  53. #define DIALOGGARE 10016
  54. #define DIALOGINFO 10017
  55. #define DIALOGINFOCOSTRUTTORE 10018
  56. #define DIALOGNOMEGARA 10019
  57. #define DIALOGGIRIGARA 10020
  58. #define DIALOGCOSTOGARA 10021
  59. #define DIALOGINFOGARA2 10022
  60. #define DIALOGINSEGUIMENTO 10023
  61. //=========================FORWARD
  62. forward Tre(playerid);
  63. forward Due(playerid);
  64. forward Uno(playerid);
  65. forward Via(playerid);
  66. forward Secondo(playerid);
  67. forward Cronometro(playerid);
  68. //=========================VARIABILIGIOCATORE
  69. enum InfoGiocatore{IdGara,Tempo,Giro,Checkpoint,Pronto,Costruttore,GaraEditorId,AttivaCheck,Inseguitore,Punti};
  70. new Giocatore[MAX_PLAYERS][InfoGiocatore];
  71. new Float:XPosizione,Float:YPosizione,Float:ZPosizione;
  72. new nome[25];
  73. //==============VARIABILIGARE
  74. enum InfoGara{Nome[50],Giri,NumeroCheckpoint,Inseguimento,Costo,Partecipanti,PartecipantiPronti,Avviata,Record,GiocatoreRecord[25],Produttore[25],Podio};
  75. new Gara[MAX_GARE][InfoGara];
  76. enum CheckInfo{Float:CXPos,Float:CYPos,Float:CZPos};
  77. new CheckpointGara[MAX_GARE][MAX_CHECKPOINT][CheckInfo];
  78. new TimerPlayers[MAX_PLAYERS];
  79. new GareCaricate,GareEditor;
  80. //=============VARIABILI
  81. new stringa[1000],stringa2[1000];
  82. new InfoSplit[7][250];
  83. new InfoCheck1[MAX_CHECKPOINT][256];
  84. new InfoCheck2[3][256];
  85. //============TEXTDRAW
  86. new Text:sfondo,Text:sfondorosso,Text:sfondogiallo,Text:sfondoverde,Text:rossoacceso,Text:gialloacceso,Text:verdeacceso; //Textdraw semaforo
  87. new Text:TimerSfondo,Text:TimerText[MAX_PLAYERS]; //Timer textdraw
  88. new Text:TextGiriSfondo,Text:TextGiriContatore[MAX_PLAYERS]; //Textdraw laps
  89. new Text:TextSfondoInseguimento,Text:SfondoInseguimentoRosso,Text:SfondoInseguimentoGiallo,Text:SfondoInseguimentoVerde,Text:SfondoInseguimentoAzzurro,Text:TextInseguimento,Text:TextPessimo,Text:TextMediocre,Text:TextBuono,Text:TextOttimo,Text:TextPunti[MAX_PLAYERS];
  90. //====================================================================CARICAGARE
  91. stock CaricaGare()
  92. {
  93. new stringagara[1000];
  94. for(new i=0;i<MAX_GARE;i++)
  95. {
  96. //==============CARICAMENTOINFOGARA
  97. format(stringa,sizeof(stringa),"Races/Race%d.txt",i);
  98. format(stringa2,sizeof(stringa2),"Race %d not found. Failed to load this race.",i);
  99. if(!fexist(stringa)) return printf(stringa2);
  100. new File:nomegara=fopen(stringa, io_read);
  101. fread(nomegara,stringagara);
  102. fclose(nomegara);
  103. split(stringagara,InfoSplit,',');
  104. format(Gara[i][Nome],50,InfoSplit[0]); //Nome,Giri,Costo,Record,GiocatoreRecord,Produttore,Inseguimento
  105. Gara[i][Giri]=strval(InfoSplit[1]);
  106. Gara[i][Costo]=strval(InfoSplit[2]);
  107. Gara[i][Record]=strval(InfoSplit[3]);
  108. format(Gara[i][GiocatoreRecord],25,InfoSplit[4]);
  109. format(Gara[i][Produttore],300,InfoSplit[5]);
  110. Gara[i][Inseguimento]=strval(InfoSplit[6]);
  111. Gara[i][NumeroCheckpoint]=-1;
  112. format(stringa,sizeof(stringa),"%s,%d,%d$,%s,%s",Gara[i][Nome],Gara[i][Giri],Gara[i][Costo],Gara[i][GiocatoreRecord],Gara[i][Produttore]);
  113. printf(stringa);
  114. //================CARICAMENTOCHECKPOINT
  115. format(stringagara,sizeof(stringagara),"");
  116. format(stringa,sizeof(stringa),"Races/Check%d.txt",i);
  117. format(stringa2,sizeof(stringa2),"Checkpoint list for Race %d not found. Failed to load this race.",i);
  118. if(!fexist(stringa)) return printf(stringa2);
  119. nomegara=fopen(stringa, io_read);
  120. fread(nomegara,stringagara);
  121. fclose(nomegara);
  122. split(stringagara,InfoCheck1,'|');
  123. print("____________________________________");
  124. for(new j=0;j<MAX_CHECKPOINT;j++)
  125. {
  126. split(InfoCheck1[j],InfoCheck2,',');
  127. if(floatstr(InfoCheck2[0])==0) {printf("%d checkpoints loaded for Race %d.",Gara[i][NumeroCheckpoint]+1,i);break;}
  128. CheckpointGara[i][j][CXPos]=floatstr(InfoCheck2[0]);
  129. CheckpointGara[i][j][CYPos]=floatstr(InfoCheck2[1]);
  130. CheckpointGara[i][j][CZPos]=floatstr(InfoCheck2[2]);
  131. Gara[i][NumeroCheckpoint]++;
  132. }
  133. GareCaricate=i;
  134. GareEditor=i;
  135. print("____________________________________");
  136. }
  137. return 1;
  138. }
  139. //====================================================================SALVAGARE
  140. stock SalvaGare()
  141. {
  142. for(new i=0;i<GareCaricate;i++)
  143. {
  144. format(stringa,sizeof(stringa),"Races/Race%d.txt",i);
  145. format(stringa2,sizeof(stringa2),"Race %d not found. Failed to save this race.",i);
  146. if(!fexist(stringa)) return printf(stringa2);
  147. new File:nomegara=fopen(stringa, io_write);
  148. new stringagara[700];
  149. format(stringagara,sizeof(stringagara),"%s,%d,%d,%d,%s,%s,%d",Gara[i][Nome],Gara[i][Giri],Gara[i][Costo],Gara[i][Record],Gara[i][GiocatoreRecord],Gara[i][Produttore],Gara[i][Inseguimento]);
  150. fwrite(nomegara,stringagara);
  151. fclose(nomegara);
  152. }
  153. return 1;
  154. }
  155. //=====================================================================AVVIAGARA
  156. stock AvviaGara(idGara)
  157. {
  158. format(stringa,sizeof(stringa),"[RACE:] Race {446ED1}%s{FFFFFF} starts!",Gara[idGara][Nome]);
  159. SendClientMessageToAll(BIANCO,stringa);
  160. Gara[idGara][Avviata]=1;
  161. for(new i=0;i<MAX_PLAYERS;i++)
  162. {
  163. if(Giocatore[i][IdGara]==idGara)
  164. {
  165. TogglePlayerControllable(i,0);
  166. TextDrawShowForPlayer(i,sfondo);
  167. TextDrawShowForPlayer(i,sfondorosso);
  168. TextDrawShowForPlayer(i,sfondogiallo);
  169. TextDrawShowForPlayer(i,sfondoverde);
  170. TextDrawShowForPlayer(i,rossoacceso);
  171. if(Gara[Giocatore[i][IdGara]][Inseguimento])
  172. {
  173. TextDrawShowForPlayer(i,TextSfondoInseguimento);
  174. TextDrawShowForPlayer(i,SfondoInseguimentoRosso);
  175. TextDrawShowForPlayer(i,SfondoInseguimentoGiallo);
  176. TextDrawShowForPlayer(i,SfondoInseguimentoVerde);
  177. TextDrawShowForPlayer(i,SfondoInseguimentoAzzurro);
  178. TextDrawShowForPlayer(i,TextInseguimento);
  179. TextDrawShowForPlayer(i,TextPessimo);
  180. TextDrawShowForPlayer(i,TextMediocre);
  181. TextDrawShowForPlayer(i,TextBuono);
  182. TextDrawShowForPlayer(i,TextOttimo);
  183. TextDrawSetString(TextPunti[i],"Points: 0000");
  184. TextDrawShowForPlayer(i,TextPunti[i]);
  185. }
  186. SetTimerEx("Tre",1000,false,"idx",i);
  187. }
  188. }
  189. return 1;
  190. }
  191. //===========================================================================TRE
  192. public Tre(playerid)
  193. {
  194. GameTextForPlayer(playerid,"~r~3",1000,3);
  195. SuonoGiocatore(playerid,1056);
  196. Giocatore[playerid][Tempo]=0;
  197. Giocatore[playerid][Giro]=1;
  198. format(stringa,sizeof(stringa),"Laps: 1/%d",Gara[Giocatore[playerid][IdGara]][Giri]);
  199. TextDrawSetString(TextGiriContatore[playerid],stringa);
  200. TextDrawSetString(TimerText[playerid],"00:00");
  201. GetPlayerPos(playerid,XPosizione,YPosizione,ZPosizione);
  202. SetPlayerCameraPos(playerid,XPosizione+4,YPosizione+2,ZPosizione+3);
  203. SetPlayerCameraLookAt(playerid,XPosizione,YPosizione,ZPosizione);
  204. TextDrawShowForPlayer(playerid,TimerSfondo);
  205. TextDrawShowForPlayer(playerid,TimerText[playerid]);
  206. TextDrawShowForPlayer(playerid,TextGiriSfondo);
  207. TextDrawShowForPlayer(playerid,TextGiriContatore[playerid]);
  208. SetTimerEx("Due",1000,false,"idx",playerid);
  209. }
  210. //===========================================================================DUE
  211. public Due(playerid)
  212. {
  213. GameTextForPlayer(playerid,"~r~3~n~~y~2",1000,3);
  214. SuonoGiocatore(playerid,1056);
  215. GetPlayerPos(playerid,XPosizione,YPosizione,ZPosizione);
  216. SetPlayerCameraPos(playerid,XPosizione-4,YPosizione-2,ZPosizione+3);
  217. SetPlayerCameraLookAt(playerid,XPosizione,YPosizione,ZPosizione);
  218. SetTimerEx("Uno",1000,false,"idx",playerid);
  219. }
  220. //===========================================================================UNO
  221. public Uno(playerid)
  222. {
  223. GameTextForPlayer(playerid,"~r~3~n~~y~2~n~~g~~h~1",1000,3);
  224. SuonoGiocatore(playerid,1056);
  225. GetPlayerPos(playerid,XPosizione,YPosizione,ZPosizione);
  226. SetPlayerCameraPos(playerid,XPosizione+4,YPosizione-2,ZPosizione+3);
  227. SetPlayerCameraLookAt(playerid,XPosizione,YPosizione,ZPosizione);
  228. TextDrawShowForPlayer(playerid,gialloacceso);
  229. TextDrawHideForPlayer(playerid,rossoacceso);
  230. SetTimerEx("Via",1000,false,"idx",playerid);
  231. }
  232. //===========================================================================VIA
  233. public Via(playerid)
  234. {
  235. SetCameraBehindPlayer(playerid);
  236. GameTextForPlayer(playerid,"~w~Go!",3000,3);
  237. SuonoGiocatore(playerid,1057);
  238. TogglePlayerControllable(playerid,1);
  239. TextDrawShowForPlayer(playerid,verdeacceso);
  240. TextDrawHideForPlayer(playerid,gialloacceso);
  241. SetTimerEx("Secondo",1000,false,"idx",playerid);
  242. TimerPlayers[playerid]=SetTimerEx("Cronometro",1000,true,"idx",playerid);
  243. }
  244. //=======================================================================SECONDO
  245. public Secondo(playerid)
  246. {
  247. TextDrawHideForPlayer(playerid,sfondo);
  248. TextDrawHideForPlayer(playerid,sfondorosso);
  249. TextDrawHideForPlayer(playerid,sfondogiallo);
  250. TextDrawHideForPlayer(playerid,sfondoverde);
  251. TextDrawHideForPlayer(playerid,verdeacceso);
  252. return 1;
  253. }
  254. //===================================================================CONTROMETRO
  255. public Cronometro(playerid)
  256. {
  257.  
  258. Giocatore[playerid][Tempo]++;
  259. new Minuti=floatround(Giocatore[playerid][Tempo]/60);
  260. new Secondi=Giocatore[playerid][Tempo]-(Minuti*60);
  261. if(Minuti>20)
  262. {
  263. SendClientMessage(playerid,ROSSO,"[RACE:] {FFFFFF}You quit automatically the race for excessive time (20 minutes)");
  264. LasciaGara(playerid);
  265. return 1;
  266. }
  267. new stringatempo[10];
  268. format(stringatempo,sizeof(stringatempo),"%02d:%02d",Minuti,Secondi);
  269. TextDrawSetString(TimerText[playerid],stringatempo);
  270. if(Gara[Giocatore[playerid][IdGara]][Inseguimento]==1)
  271. {
  272. for(new i=0;i<MAX_PLAYERS;i++)
  273. {
  274. if(Giocatore[i][IdGara]==Giocatore[playerid][IdGara] && i!=playerid)
  275. {
  276. GetPlayerPos(i,XPosizione,YPosizione,ZPosizione);
  277. break;
  278. }
  279. }
  280. TextDrawHideForPlayer(playerid,SfondoInseguimentoRosso);
  281. TextDrawHideForPlayer(playerid,SfondoInseguimentoGiallo);
  282. TextDrawHideForPlayer(playerid,SfondoInseguimentoVerde);
  283. TextDrawHideForPlayer(playerid,SfondoInseguimentoAzzurro);
  284. if(!Giocatore[playerid][Inseguitore])
  285. {
  286. if(IsPlayerInRangeOfPoint(playerid,15,XPosizione,YPosizione,ZPosizione)){
  287. Giocatore[playerid][Punti]+=3; TextDrawShowForPlayer(playerid,SfondoInseguimentoRosso);}
  288. else if (IsPlayerInRangeOfPoint(playerid,30,XPosizione,YPosizione,ZPosizione)){
  289. Giocatore[playerid][Punti]+=5; TextDrawShowForPlayer(playerid,SfondoInseguimentoGiallo);}
  290. else if(IsPlayerInRangeOfPoint(playerid,40,XPosizione,YPosizione,ZPosizione)){
  291. Giocatore[playerid][Punti]+=7; TextDrawShowForPlayer(playerid,SfondoInseguimentoVerde);}
  292. else{
  293. Giocatore[playerid][Punti]+=8; TextDrawShowForPlayer(playerid,SfondoInseguimentoAzzurro);}
  294. }
  295. else
  296. {
  297. if(IsPlayerInRangeOfPoint(playerid,15,XPosizione,YPosizione,ZPosizione)){
  298. Giocatore[playerid][Punti]+=8; TextDrawShowForPlayer(playerid,SfondoInseguimentoAzzurro);}
  299. else if (IsPlayerInRangeOfPoint(playerid,30,XPosizione,YPosizione,ZPosizione)){
  300. Giocatore[playerid][Punti]+=7; TextDrawShowForPlayer(playerid,SfondoInseguimentoVerde);}
  301. else if(IsPlayerInRangeOfPoint(playerid,40,XPosizione,YPosizione,ZPosizione)){
  302. Giocatore[playerid][Punti]+=5; TextDrawShowForPlayer(playerid,SfondoInseguimentoGiallo);}
  303. else{
  304. Giocatore[playerid][Punti]+=3; TextDrawShowForPlayer(playerid,SfondoInseguimentoRosso);}
  305. }
  306. format(stringa,sizeof(stringa),"Points: %d",Giocatore[playerid][Punti]);
  307. TextDrawSetString(TextPunti[playerid],stringa);
  308. }
  309. return 1;
  310. }
  311. //====================================================================LASCIAGARA
  312. stock LasciaGara(playerid)
  313. {
  314. if(Giocatore[playerid][IdGara]==-1) return 1;
  315. if(Gara[Giocatore[playerid][IdGara]][Avviata]==0)
  316. {
  317. if(Giocatore[playerid][Pronto]==1)
  318. Gara[Giocatore[playerid][IdGara]][PartecipantiPronti]--;
  319. }
  320. KillTimer(TimerPlayers[playerid]);
  321. Giocatore[playerid][Tempo]=0;
  322. GetPlayerName(playerid,nome,sizeof(nome));
  323. format(stringa,sizeof(stringa),"[RACE:] {8CE46C}%s {FFFFFF}quit the race.", nome);
  324. MandaMessaggioPartecipanti(Giocatore[playerid][IdGara],stringa);
  325. //==========TEXTBASE
  326. TextDrawHideForPlayer(playerid,sfondo);
  327. TextDrawHideForPlayer(playerid,TimerText[playerid]);
  328. TextDrawHideForPlayer(playerid,TimerSfondo);
  329. TextDrawHideForPlayer(playerid,sfondorosso);
  330. TextDrawHideForPlayer(playerid,sfondogiallo);
  331. TextDrawHideForPlayer(playerid,sfondoverde);
  332. TextDrawHideForPlayer(playerid,rossoacceso);
  333. TextDrawHideForPlayer(playerid,gialloacceso);
  334. TextDrawHideForPlayer(playerid,verdeacceso);
  335. TextDrawHideForPlayer(playerid,TextGiriSfondo);
  336. //==========TEXTINSEGUIMENTO
  337. TextDrawHideForPlayer(playerid,TextSfondoInseguimento);
  338. TextDrawHideForPlayer(playerid,SfondoInseguimentoRosso);
  339. TextDrawHideForPlayer(playerid,SfondoInseguimentoGiallo);
  340. TextDrawHideForPlayer(playerid,SfondoInseguimentoVerde);
  341. TextDrawHideForPlayer(playerid,SfondoInseguimentoAzzurro);
  342. TextDrawHideForPlayer(playerid,TextInseguimento);
  343. TextDrawHideForPlayer(playerid,TextPessimo);
  344. TextDrawHideForPlayer(playerid,TextMediocre);
  345. TextDrawHideForPlayer(playerid,TextBuono);
  346. TextDrawHideForPlayer(playerid,TextOttimo);
  347. TextDrawHideForPlayer(playerid,TextPunti[playerid]);
  348.  
  349. TextDrawHideForPlayer(playerid,TextGiriContatore[playerid]);
  350. TextDrawSetString(TimerText[playerid],"00:00");
  351. Giocatore[playerid][Checkpoint]=0;
  352. Gara[Giocatore[playerid][IdGara]][Partecipanti]--;
  353. if(Gara[Giocatore[playerid][IdGara]][PartecipantiPronti]==Gara[Giocatore[playerid][IdGara]][Partecipanti] && Gara[Giocatore[playerid][IdGara]][Partecipanti]!=0 && Gara[Giocatore[playerid][IdGara]][Avviata]==0)
  354. AvviaGara(Giocatore[playerid][IdGara]);
  355. ChiudiGara(Giocatore[playerid][IdGara]);
  356. Giocatore[playerid][IdGara]=-1;
  357. Giocatore[playerid][Pronto]=0;
  358. Giocatore[playerid][Giro]=1;
  359. Giocatore[playerid][Inseguitore]=0;
  360. Giocatore[playerid][Punti]=0;
  361. DisablePlayerRaceCheckpoint(playerid);
  362. return 1;
  363. }
  364. //====================================================================CHIUDIGARA
  365. stock ChiudiGara(idGara)
  366. {
  367. if(Gara[idGara][Partecipanti]==0 && idGara!=-1)
  368. {
  369. format(stringa,sizeof(stringa),"[RACE:] {FFFFFF}Race {446ED1}%s{FFFFFF} finish.",Gara[idGara][Nome]);
  370. SendClientMessageToAll(BIANCO,stringa);
  371. Gara[idGara][Podio]=0;
  372. Gara[idGara][Avviata]=0;
  373. Gara[idGara][Partecipanti]=0;
  374. Gara[idGara][PartecipantiPronti]=0;
  375. }
  376. }
  377. //============================================================ONFILTERSCRIPTINIT
  378. public OnFilterScriptInit()
  379. {
  380. print("_______________________________________________");
  381. print(" PRaceSystem by Phanto90 loaded ");
  382. print("_______________________________________________");
  383. CaricaGare();
  384. TextGiriSfondo = TextDrawCreate(541.000000, 189.000000, "1");
  385. TextDrawBackgroundColor(TextGiriSfondo, 0);
  386. TextDrawFont(TextGiriSfondo, 1);
  387. TextDrawLetterSize(TextGiriSfondo, 0.579999, 1.700000);
  388. TextDrawColor(TextGiriSfondo, 0);
  389. TextDrawSetOutline(TextGiriSfondo, 0);
  390. TextDrawSetProportional(TextGiriSfondo, 1);
  391. TextDrawSetShadow(TextGiriSfondo, 1);
  392. TextDrawUseBox(TextGiriSfondo, 1);
  393. TextDrawBoxColor(TextGiriSfondo, 1010580600);
  394. TextDrawTextSize(TextGiriSfondo, 613.000000, 0.000000);
  395.  
  396. TimerSfondo = TextDrawCreate(620.000000, 160.000000, ".sfo");
  397. TextDrawBackgroundColor(TimerSfondo, 0);
  398. TextDrawFont(TimerSfondo, 1);
  399. TextDrawLetterSize(TimerSfondo, 0.500000, 2.499999);
  400. TextDrawColor(TimerSfondo, 0);
  401. TextDrawSetOutline(TimerSfondo, 0);
  402. TextDrawSetProportional(TimerSfondo, 1);
  403. TextDrawSetShadow(TimerSfondo, 1);
  404. TextDrawUseBox(TimerSfondo, 1);
  405. TextDrawBoxColor(TimerSfondo, 1010580580);
  406. TextDrawTextSize(TimerSfondo, 535.000000, 0.000000);
  407.  
  408. sfondo = TextDrawCreate(265.000000, 40.000000, "sfondo");
  409. TextDrawBackgroundColor(sfondo, 0);
  410. TextDrawFont(sfondo, 1);
  411. TextDrawLetterSize(sfondo, 0.500000, 3.500000);
  412. TextDrawColor(sfondo, 0);
  413. TextDrawSetOutline(sfondo, 0);
  414. TextDrawSetProportional(sfondo, 1);
  415. TextDrawSetShadow(sfondo, 1);
  416. TextDrawUseBox(sfondo, 1);
  417. TextDrawBoxColor(sfondo, 338826495);
  418. TextDrawTextSize(sfondo, 384.000000, 0.000000);
  419.  
  420. sfondorosso = TextDrawCreate(278.000000, 48.000000, "sfondorosso");
  421. TextDrawBackgroundColor(sfondorosso, 0);
  422. TextDrawFont(sfondorosso, 1);
  423. TextDrawLetterSize(sfondorosso, 0.500000, 1.800001);
  424. TextDrawColor(sfondorosso, 0);
  425. TextDrawSetOutline(sfondorosso, 0);
  426. TextDrawSetProportional(sfondorosso, 1);
  427. TextDrawSetShadow(sfondorosso, 1);
  428. TextDrawUseBox(sfondorosso, 1);
  429. TextDrawBoxColor(sfondorosso, 840176895);
  430. TextDrawTextSize(sfondorosso, 293.000000, 0.000000);
  431.  
  432. sfondogiallo = TextDrawCreate(320.000000, 48.000000, "sfondoarancione");
  433. TextDrawBackgroundColor(sfondogiallo, 0);
  434. TextDrawFont(sfondogiallo, 1);
  435. TextDrawLetterSize(sfondogiallo, 0.500000, 1.800001);
  436. TextDrawColor(sfondogiallo, 0);
  437. TextDrawSetOutline(sfondogiallo, 0);
  438. TextDrawSetProportional(sfondogiallo, 1);
  439. TextDrawSetShadow(sfondogiallo, 1);
  440. TextDrawUseBox(sfondogiallo, 1);
  441. TextDrawBoxColor(sfondogiallo, 842142975);
  442. TextDrawTextSize(sfondogiallo, 334.000000, 0.000000);
  443.  
  444. sfondoverde = TextDrawCreate(359.000000, 48.000000, "sfondoverde");
  445. TextDrawBackgroundColor(sfondoverde, 0);
  446. TextDrawFont(sfondoverde, 1);
  447. TextDrawLetterSize(sfondoverde, 0.500000, 1.800001);
  448. TextDrawColor(sfondoverde, 0);
  449. TextDrawSetOutline(sfondoverde, 0);
  450. TextDrawSetProportional(sfondoverde, 1);
  451. TextDrawSetShadow(sfondoverde, 1);
  452. TextDrawUseBox(sfondoverde, 1);
  453. TextDrawBoxColor(sfondoverde, 337515775);
  454. TextDrawTextSize(sfondoverde, 373.000000, 0.000000);
  455.  
  456. rossoacceso = TextDrawCreate(281.000000, 51.000000, "sfondorossoacceso");
  457. TextDrawBackgroundColor(rossoacceso, 0);
  458. TextDrawFont(rossoacceso, 1);
  459. TextDrawLetterSize(rossoacceso, 0.500000, 1.100001);
  460. TextDrawColor(rossoacceso, 0);
  461. TextDrawSetOutline(rossoacceso, 0);
  462. TextDrawSetProportional(rossoacceso, 1);
  463. TextDrawSetShadow(rossoacceso, 1);
  464. TextDrawUseBox(rossoacceso, 1);
  465. TextDrawBoxColor(rossoacceso, -938208001);
  466. TextDrawTextSize(rossoacceso, 291.000000, 0.000000);
  467.  
  468. gialloacceso = TextDrawCreate(322.000000, 51.000000, "sfondoarancioneacceso");
  469. TextDrawBackgroundColor(gialloacceso, 0);
  470. TextDrawFont(gialloacceso, 1);
  471. TextDrawLetterSize(gialloacceso, 0.500000, 1.100001);
  472. TextDrawColor(gialloacceso, 0);
  473. TextDrawSetOutline(gialloacceso, 0);
  474. TextDrawSetProportional(gialloacceso, 1);
  475. TextDrawSetShadow(gialloacceso, 1);
  476. TextDrawUseBox(gialloacceso, 1);
  477. TextDrawBoxColor(gialloacceso, -926411521);
  478. TextDrawTextSize(gialloacceso, 332.000000, 0.000000);
  479.  
  480. verdeacceso = TextDrawCreate(362.000000, 51.000000, "sfondoverdeacceso");
  481. TextDrawBackgroundColor(verdeacceso, 0);
  482. TextDrawFont(verdeacceso, 1);
  483. TextDrawLetterSize(verdeacceso, 0.500000, 1.100001);
  484. TextDrawColor(verdeacceso, 0);
  485. TextDrawSetOutline(verdeacceso, 0);
  486. TextDrawSetProportional(verdeacceso, 1);
  487. TextDrawSetShadow(verdeacceso, 1);
  488. TextDrawUseBox(verdeacceso, 1);
  489. TextDrawBoxColor(verdeacceso, 348656895);
  490. TextDrawTextSize(verdeacceso, 370.000000, 0.000000);
  491.  
  492. TextSfondoInseguimento = TextDrawCreate(170.000000, 362.000000, "box");
  493. TextDrawBackgroundColor(TextSfondoInseguimento, 0);
  494. TextDrawFont(TextSfondoInseguimento, 1);
  495. TextDrawLetterSize(TextSfondoInseguimento, 0.460000, 2.700011);
  496. TextDrawColor(TextSfondoInseguimento, 0);
  497. TextDrawSetOutline(TextSfondoInseguimento, 0);
  498. TextDrawSetProportional(TextSfondoInseguimento, 1);
  499. TextDrawSetShadow(TextSfondoInseguimento, 1);
  500. TextDrawUseBox(TextSfondoInseguimento, 1);
  501. TextDrawBoxColor(TextSfondoInseguimento, 505290340);
  502. TextDrawTextSize(TextSfondoInseguimento, 467.000000, 0.000000);
  503.  
  504. SfondoInseguimentoRosso = TextDrawCreate(174.000000, 366.000000, "boxrosso");
  505. TextDrawBackgroundColor(SfondoInseguimentoRosso, 0);
  506. TextDrawFont(SfondoInseguimentoRosso, 1);
  507. TextDrawLetterSize(SfondoInseguimentoRosso, 0.460000, 1.600010);
  508. TextDrawColor(SfondoInseguimentoRosso, 0);
  509. TextDrawSetOutline(SfondoInseguimentoRosso, 0);
  510. TextDrawSetProportional(SfondoInseguimentoRosso, 1);
  511. TextDrawSetShadow(SfondoInseguimentoRosso, 1);
  512. TextDrawUseBox(SfondoInseguimentoRosso, 1);
  513. TextDrawBoxColor(SfondoInseguimentoRosso, -1776410956);
  514. TextDrawTextSize(SfondoInseguimentoRosso, 243.000000, 0.000000);
  515.  
  516. SfondoInseguimentoGiallo = TextDrawCreate(249.000000, 366.000000, "boxgiallo");
  517. TextDrawBackgroundColor(SfondoInseguimentoGiallo, 0);
  518. TextDrawFont(SfondoInseguimentoGiallo, 1);
  519. TextDrawLetterSize(SfondoInseguimentoGiallo, 0.460000, 1.600010);
  520. TextDrawColor(SfondoInseguimentoGiallo, 0);
  521. TextDrawSetOutline(SfondoInseguimentoGiallo, 0);
  522. TextDrawSetProportional(SfondoInseguimentoGiallo, 1);
  523. TextDrawSetShadow(SfondoInseguimentoGiallo, 1);
  524. TextDrawUseBox(SfondoInseguimentoGiallo, 1);
  525. TextDrawBoxColor(SfondoInseguimentoGiallo, -1768546636);
  526. TextDrawTextSize(SfondoInseguimentoGiallo, 319.000000, 0.000000);
  527.  
  528. SfondoInseguimentoVerde = TextDrawCreate(325.000000, 366.000000, "boxverde");
  529. TextDrawBackgroundColor(SfondoInseguimentoVerde, 0);
  530. TextDrawFont(SfondoInseguimentoVerde, 1);
  531. TextDrawLetterSize(SfondoInseguimentoVerde, 0.460000, 1.600010);
  532. TextDrawColor(SfondoInseguimentoVerde, 0);
  533. TextDrawSetOutline(SfondoInseguimentoVerde, 0);
  534. TextDrawSetProportional(SfondoInseguimentoVerde, 1);
  535. TextDrawSetShadow(SfondoInseguimentoVerde, 1);
  536. TextDrawUseBox(SfondoInseguimentoVerde, 1);
  537. TextDrawBoxColor(SfondoInseguimentoVerde, 513154740);
  538. TextDrawTextSize(SfondoInseguimentoVerde, 394.000000, 0.000000);
  539.  
  540. SfondoInseguimentoAzzurro = TextDrawCreate(400.000000, 366.000000, "boxazzurro");
  541. TextDrawBackgroundColor(SfondoInseguimentoAzzurro, 0);
  542. TextDrawFont(SfondoInseguimentoAzzurro, 1);
  543. TextDrawLetterSize(SfondoInseguimentoAzzurro, 0.460000, 1.600010);
  544. TextDrawColor(SfondoInseguimentoAzzurro, 0);
  545. TextDrawSetOutline(SfondoInseguimentoAzzurro, 0);
  546. TextDrawSetProportional(SfondoInseguimentoAzzurro, 1);
  547. TextDrawSetShadow(SfondoInseguimentoAzzurro, 1);
  548. TextDrawUseBox(SfondoInseguimentoAzzurro, 1);
  549. TextDrawBoxColor(SfondoInseguimentoAzzurro, 513198260);
  550. TextDrawTextSize(SfondoInseguimentoAzzurro, 463.000000, 0.000000);
  551.  
  552. TextInseguimento = TextDrawCreate(274.000000, 339.000000, " Chase");
  553. TextDrawBackgroundColor(TextInseguimento, 255);
  554. TextDrawFont(TextInseguimento, 0);
  555. TextDrawLetterSize(TextInseguimento, 0.629999, 2.599999);
  556. TextDrawColor(TextInseguimento, -1);
  557. TextDrawSetOutline(TextInseguimento, 0);
  558. TextDrawSetProportional(TextInseguimento, 1);
  559. TextDrawSetShadow(TextInseguimento, 1);
  560.  
  561. TextPessimo = TextDrawCreate(188.000000, 363.000000, " Bad");
  562. TextDrawBackgroundColor(TextPessimo, 255);
  563. TextDrawFont(TextPessimo, 1);
  564. TextDrawLetterSize(TextPessimo, 0.339999, 2.000000);
  565. TextDrawColor(TextPessimo, -1);
  566. TextDrawSetOutline(TextPessimo, 0);
  567. TextDrawSetProportional(TextPessimo, 1);
  568. TextDrawSetShadow(TextPessimo, 1);
  569.  
  570. TextMediocre = TextDrawCreate(258.000000, 363.000000, "Average");
  571. TextDrawBackgroundColor(TextMediocre, 255);
  572. TextDrawFont(TextMediocre, 1);
  573. TextDrawLetterSize(TextMediocre, 0.339999, 2.000000);
  574. TextDrawColor(TextMediocre, -1);
  575. TextDrawSetOutline(TextMediocre, 0);
  576. TextDrawSetProportional(TextMediocre, 1);
  577. TextDrawSetShadow(TextMediocre, 1);
  578.  
  579. TextBuono = TextDrawCreate(344.000000, 363.000000, "Good");
  580. TextDrawBackgroundColor(TextBuono, 255);
  581. TextDrawFont(TextBuono, 1);
  582. TextDrawLetterSize(TextBuono, 0.339999, 2.000000);
  583. TextDrawColor(TextBuono, -1);
  584. TextDrawSetOutline(TextBuono, 0);
  585. TextDrawSetProportional(TextBuono, 1);
  586. TextDrawSetShadow(TextBuono, 1);
  587.  
  588. TextOttimo = TextDrawCreate(410.000000, 363.000000, "Excellent");
  589. TextDrawBackgroundColor(TextOttimo, 255);
  590. TextDrawFont(TextOttimo, 1);
  591. TextDrawLetterSize(TextOttimo, 0.339999, 2.000000);
  592. TextDrawColor(TextOttimo, -1);
  593. TextDrawSetOutline(TextOttimo, 0);
  594. TextDrawSetProportional(TextOttimo, 1);
  595. TextDrawSetShadow(TextOttimo, 1);
  596.  
  597. for(new i=0;i<MAX_PLAYERS;i++)
  598. {
  599. Giocatore[i][IdGara]=-1;
  600.  
  601. TextPunti[i] = TextDrawCreate(288.000000, 386.000000, "Points: 0000");
  602. TextDrawBackgroundColor(TextPunti[i], 255);
  603. TextDrawFont(TextPunti[i], 1);
  604. TextDrawLetterSize(TextPunti[i], 0.339999, 2.000000);
  605. TextDrawColor(TextPunti[i], -1);
  606. TextDrawSetOutline(TextPunti[i], 0);
  607. TextDrawSetProportional(TextPunti[i], 1);
  608. TextDrawSetShadow(TextPunti[i], 1);
  609.  
  610. TimerText[i] = TextDrawCreate(542.000000, 150.000000, "00:00");
  611. TextDrawBackgroundColor(TimerText[i], 255);
  612. TextDrawFont(TimerText[i], 2);
  613. TextDrawLetterSize(TimerText[i], 0.610000, 4.099999);
  614. TextDrawColor(TimerText[i], TURCHESE);
  615. TextDrawSetOutline(TimerText[i], 0);
  616. TextDrawSetProportional(TimerText[i], 1);
  617. TextDrawSetShadow(TimerText[i], 1);
  618.  
  619. TextGiriContatore[i] = TextDrawCreate(542.000000, 192.000000, "Laps: 1/3");
  620. TextDrawBackgroundColor(TextGiriContatore[i], 255);
  621. TextDrawFont(TextGiriContatore[i], 1);
  622. TextDrawLetterSize(TextGiriContatore[i], 0.460000, 1.000000);
  623. TextDrawColor(TextGiriContatore[i], -1);
  624. TextDrawSetOutline(TextGiriContatore[i], 0);
  625. TextDrawSetProportional(TextGiriContatore[i], 1);
  626. TextDrawSetShadow(TextGiriContatore[i], 1);
  627. }
  628. return 1;
  629. }
  630. //============================================================ONFILTERSCRIPTEXIT
  631. public OnFilterScriptExit()
  632. {
  633. SalvaGare();
  634. return 1;
  635. }
  636. //===============================================================ONPLAYERCONNECT
  637. public OnPlayerConnect(playerid)
  638. {
  639. return 1;
  640. }
  641. //============================================================ONPLAYERDISCONNECT
  642. public OnPlayerDisconnect(playerid, reason)
  643. {
  644. if(Gara[Giocatore[playerid][IdGara]][Inseguimento] && Gara[Giocatore[playerid][IdGara]][Avviata]==1)
  645. {
  646. for(new i=0;i<MAX_PLAYERS;i++)
  647. {
  648. if(Giocatore[i][IdGara]==Giocatore[playerid][IdGara] && i!=playerid)
  649. {
  650. GetPlayerName(i,nome,sizeof(nome));
  651. format(stringa,sizeof(stringa),"[RACE:] {8ECE46}%s{FFFFFF} wons the race because the opponent disconnected.",nome);
  652. SendClientMessageToAll(BIANCO,stringa);
  653. GivePlayerMoney(i,Gara[Giocatore[i][IdGara]][Costo]*2);
  654. LasciaGara(i);
  655. }
  656. }
  657. }
  658. LasciaGara(playerid);
  659. Giocatore[playerid][Costruttore]=0;
  660. return 1;
  661. }
  662. //===========================================================ONPLAYERCOMMANDTEXT
  663. public OnPlayerCommandText(playerid, cmdtext[])
  664. {
  665. //=====================================PROVVISORIO
  666. if(!strcmp(cmdtext,"/car",true))
  667. {
  668. GetPlayerPos(playerid,XPosizione,YPosizione,ZPosizione);
  669. CreateVehicle(400,XPosizione,YPosizione,ZPosizione,0,1,1,0);
  670. return 1;
  671. }
  672. //=====================================GARE
  673. if(!strcmp(cmdtext,"/race",true))
  674. {
  675. if(Giocatore[playerid][Costruttore]==1) return SendClientMessage(playerid,ROSSO,"[ERROR:] {FFFFFF}You are in builder mode.");
  676. format(stringa,sizeof(stringa),"");
  677. for(new i=0;i<=GareCaricate; i++)
  678. {
  679. if(Gara[i][Giri]>1 && Gara[i][Inseguimento]==0)
  680. format(stringa2,sizeof(stringa2),"{F58C5B}Circuit-{FFFFFF}%s (%d laps)",Gara[i][Nome],Gara[i][Giri]);
  681. if(Gara[i][Giri]==1 && Gara[i][Inseguimento]==0)
  682. format(stringa2,sizeof(stringa2),"{97EA68}Sprint-{FFFFFF}%s",Gara[i][Nome]);
  683. if(Gara[i][Giri]>1 && Gara[i][Inseguimento]==1)
  684. format(stringa2,sizeof(stringa2),"{446ED1}Chase-{FFFFFF}%s (%d laps)",Gara[i][Nome],Gara[i][Giri]);
  685. if(Gara[i][Giri]==1 && Gara[i][Inseguimento]==1)
  686. format(stringa2,sizeof(stringa2),"{446ED1}Chase-{FFFFFF}%s",Gara[i][Nome]);
  687. strins(stringa,stringa2,strlen(stringa),sizeof(stringa));
  688. if(i!=GareCaricate)
  689. strins(stringa,"\n",strlen(stringa),sizeof(stringa));
  690. }
  691. ShowPlayerDialog(playerid,DIALOGGARE,DIALOG_STYLE_LIST,"Avaible races",stringa,"Join","Exit");
  692. return 1;
  693. }
  694. //=====================================LASCIAGARA
  695. if(!strcmp(cmdtext,"/quitrace",true))
  696. {
  697. if(Giocatore[playerid][IdGara]==-1) return SendClientMessage(playerid,ROSSO,"[ERROR:] {FFFFFF}You did not join any race.");
  698. if(Gara[Giocatore[playerid][IdGara]][Inseguimento] && Gara[Giocatore[playerid][IdGara]][Avviata]==1)
  699. {
  700. for(new i=0;i<MAX_PLAYERS;i++)
  701. {
  702. if(Giocatore[i][IdGara]==Giocatore[playerid][IdGara] && i!=playerid)
  703. {
  704. GetPlayerName(i,nome,sizeof(nome));
  705. format(stringa,sizeof(stringa),"[RACE:] {8ECE46}%s{FFFFFF} wons the race because the opponent quitted.",nome);
  706. SendClientMessageToAll(BIANCO,stringa);
  707. GivePlayerMoney(i,Gara[Giocatore[i][IdGara]][Costo]*2);
  708. LasciaGara(i);
  709. }
  710. }
  711. }
  712. LasciaGara(playerid);
  713. return 1;
  714. }
  715. //=====================================PRONTO
  716. if(!strcmp(cmdtext,"/ready",true))
  717. {
  718. if(Giocatore[playerid][IdGara]==-1) return SendClientMessage(playerid,ROSSO,"[ERROR:] {FFFFFF}You did not join any race.");
  719. if(Giocatore[playerid][Pronto]==1) return SendClientMessage(playerid,ROSSO,"[ERROR:] {FFFFFF} You are yet ready, wait opponents to be.");
  720. SendClientMessage(playerid,BIANCO,"[PRONTO:] Now you are ready, wait other players to be.");
  721. Gara[Giocatore[playerid][IdGara]][PartecipantiPronti]++;
  722. Giocatore[playerid][Pronto]=1;
  723. if(Gara[Giocatore[playerid][IdGara]][Partecipanti]==Gara[Giocatore[playerid][IdGara]][PartecipantiPronti] && Gara[Giocatore[playerid][IdGara]][Inseguimento]==0)
  724. AvviaGara(Giocatore[playerid][IdGara]);
  725. if(Gara[Giocatore[playerid][IdGara]][PartecipantiPronti]==2 && Gara[Giocatore[playerid][IdGara]][Inseguimento]==1)
  726. AvviaGara(Giocatore[playerid][IdGara]);
  727. return 1;
  728. }
  729. //=====================================COSTRUISCIGARA
  730. if(!strcmp(cmdtext,"/builder",true))
  731. {
  732. if(!IsPlayerAdmin(playerid)) return 1;
  733. if(Giocatore[playerid][IdGara]!=-1) return SendClientMessage(playerid,ROSSO,"[ERROR:]{FFFFFF} You cannot build races while racing.");
  734. ShowPlayerDialog(playerid,DIALOGINFOCOSTRUTTORE,0,"Info Builder","{FFFFFF}Welcome in the builder mode of {C14124}PRaceSystem{FFFFFF}.\nNow you have to inserit some race informations:\n•Race's Name\n•Laps\n•Cost\n•Creation of a checkpoint list\n\nNote: During the builder mode you cannot join races.","Proceed","");
  735. GareEditor++;
  736. Giocatore[playerid][GaraEditorId]=GareEditor;
  737. Giocatore[playerid][Costruttore]=1;
  738. format(stringa,sizeof(stringa),"Races/Race%d.txt",GareEditor);
  739. new File:nomegara=fopen(stringa, io_write);
  740. fwrite(nomegara,"Name,1,50,1000,Nobody,0");
  741. fclose(nomegara);
  742. return 1;
  743. }
  744. //======================================CHECK
  745. if (!strcmp("/check", cmdtext, true))
  746. {
  747. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,ROSSO,"[ERROR:] {FFFFFF}You are not logged as RCON Admin");
  748. if(Giocatore[playerid][Costruttore]==0) return SendClientMessage(playerid,ROSSO,"[ERROR:]{FFFFFF} You are not in builder mode.");
  749. if(Giocatore[playerid][AttivaCheck]==0) return SendClientMessage(playerid,ROSSO,"[ERROR:]{FFFFFF} Finish to inserit race information before creating a checkpoint list.");
  750. SendClientMessage(playerid,VERDE,"[CHECKPOINT:] {FFFFFF}Checkpoint saved.");
  751. format(stringa,sizeof(stringa),"Races/Check%d.txt",Giocatore[playerid][GaraEditorId]);
  752. new File:nomegara=fopen(stringa, io_append);
  753. new stringagara[150];
  754. GetPlayerPos(playerid,XPosizione,YPosizione,ZPosizione);
  755. format(stringagara,sizeof(stringagara),"%f,%f,%f|",XPosizione,YPosizione,ZPosizione);
  756. SetPlayerCheckpoint(playerid,XPosizione,YPosizione,ZPosizione,9);
  757. fwrite(nomegara,stringagara);
  758. fclose(nomegara);
  759. return 1;
  760. }
  761. //====================================FINECHECK
  762. if(!strcmp("/endcheck", cmdtext, true))
  763. {
  764. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,ROSSO,"[ERROR:] {FFFFFF}You are not logged as RCON Admin");
  765. if(Giocatore[playerid][Costruttore]==0) return SendClientMessage(playerid,ROSSO,"[ERROR:]{FFFFFF} You are not in builder mode.");
  766. if(Giocatore[playerid][AttivaCheck]==0) return SendClientMessage(playerid,ROSSO,"[ERROR:]{FFFFFF} To finish, create first a checkpoint list with /check");
  767. Giocatore[playerid][Costruttore]=0;
  768. Giocatore[playerid][AttivaCheck]=0;
  769. SendClientMessage(playerid,BIANCO,"[EDITOR:] You completed the race.");
  770. DisablePlayerCheckpoint(playerid);
  771. SalvaGare();
  772. for(new i=0;i<MAX_PLAYERS;i++){
  773. LasciaGara(i);}
  774. SendClientMessageToAll(BIANCO,"[ANNOUNCE:] Administrator has build a new race. In order to load all the other races have been forced to finish.");
  775. CaricaGare();
  776. return 1;
  777. }
  778. return 0;
  779. }
  780. //===================================================ONPLAYERENTERRACECHECKPOINT
  781. public OnPlayerEnterRaceCheckpoint(playerid)
  782. {
  783. if(Giocatore[playerid][IdGara]==-1) return 1;
  784. new g=Giocatore[playerid][IdGara];
  785. new c=Giocatore[playerid][Checkpoint];
  786. if(Gara[Giocatore[playerid][IdGara]][Avviata]==0) return 1;
  787. SuonoGiocatore(playerid,1138);
  788. //==============SECHECKPOINT==ULTIMO
  789. if(Giocatore[playerid][Checkpoint]==Gara[Giocatore[playerid][IdGara]][NumeroCheckpoint])
  790. {
  791. //===========SEGIRO=ULTIMO
  792. if(Giocatore[playerid][Giro]==Gara[Giocatore[playerid][IdGara]][Giri])
  793. {
  794. GetPlayerName(playerid,nome,sizeof(nome));
  795. Gara[Giocatore[playerid][IdGara]][Podio]++;
  796. if(Giocatore[playerid][Tempo]<Gara[Giocatore[playerid][IdGara]][Record])
  797. {
  798. new Minuti=floatround(Giocatore[playerid][Tempo]/60);
  799. new Secondi=Giocatore[playerid][Tempo]-(Minuti*60);
  800. format(stringa,sizeof(stringa),"[RECORD:] Player:{8ECE46}%s{FFFFFF} Track: {446ED1}%s{FFFFFF} Record: {C14124}%02d:%02d",nome,Gara[Giocatore[playerid][IdGara]][Nome],Minuti,Secondi);
  801. SendClientMessageToAll(BIANCO,stringa);
  802. Gara[Giocatore[playerid][IdGara]][Record]=Giocatore[playerid][Tempo];
  803. format(Gara[Giocatore[playerid][IdGara]][GiocatoreRecord],25,nome);
  804. }
  805. if(!Gara[Giocatore[playerid][IdGara]][Inseguimento])
  806. {
  807. format(stringa,sizeof(stringa),"[RACE:] {8ECE46}%s{FFFFFF} finish the race. Position: {C14124}%d",nome,Gara[Giocatore[playerid][IdGara]][Podio]);
  808. GivePlayerMoney(playerid,floatround(Gara[Giocatore[playerid][IdGara]][Costo]*Gara[Giocatore[playerid][IdGara]][PartecipantiPronti]/Gara[Giocatore[playerid][IdGara]][Podio]));
  809. SendClientMessageToAll(BIANCO,stringa);
  810. }
  811. if(Gara[Giocatore[playerid][IdGara]][Inseguimento])
  812. {
  813. for(new i=0;i<MAX_PLAYERS;i++)
  814. {
  815. if(Giocatore[i][IdGara]==Giocatore[playerid][IdGara] && i!=playerid)
  816. {
  817. if(Giocatore[playerid][Punti]>=Giocatore[i][Punti])
  818. {
  819. GetPlayerName(playerid,nome,sizeof(nome));
  820. format(stringa,sizeof(stringa),"[RACE:] {8ECE46}%s{FFFFFF} wons the chase race with {C14124}%d{FFFFFF} points.",nome,Giocatore[playerid][Punti]);
  821. SendClientMessageToAll(BIANCO,stringa);
  822. GivePlayerMoney(playerid,Gara[Giocatore[playerid][IdGara]][Costo]*2);
  823. }
  824. if(Giocatore[playerid][Punti]<Giocatore[i][Punti])
  825. {
  826. GetPlayerName(i,nome,sizeof(nome));
  827. format(stringa,sizeof(stringa),"[RACE:] {8ECE46}%s{FFFFFF} wons the chase race with {C14124}%d{FFFFFF} points.",nome,Giocatore[i][Punti]);
  828. SendClientMessageToAll(BIANCO,stringa);
  829. GivePlayerMoney(i,Gara[Giocatore[playerid][IdGara]][Costo]*2);
  830. }
  831. LasciaGara(i);
  832. }
  833. }
  834. }
  835. DisablePlayerRaceCheckpoint(playerid);
  836. LasciaGara(playerid);
  837. return 1;
  838. }
  839. //========SEGIRO!=ULTIMO
  840. else
  841. {
  842. Giocatore[playerid][Giro]++;
  843. SetPlayerRaceCheckpoint(playerid,0,CheckpointGara[g][0][CXPos],CheckpointGara[g][0][CYPos],CheckpointGara[g][0][CZPos],CheckpointGara[g][1][CXPos],CheckpointGara[g][1][CYPos],CheckpointGara[g][1][CZPos],9);
  844. Giocatore[playerid][Checkpoint]=0;
  845. format(stringa,sizeof(stringa),"Laps: %d/%d",Giocatore[playerid][Giro],Gara[Giocatore[playerid][IdGara]][Giri]);
  846. TextDrawSetString(TextGiriContatore[playerid],stringa);
  847. return 1;
  848. }
  849. }
  850. //=========SECHECKPOINTNORMALE
  851. if(Giocatore[playerid][Checkpoint]<Gara[Giocatore[playerid][IdGara]][NumeroCheckpoint]-1)
  852. {
  853. Giocatore[playerid][Checkpoint]++;
  854. c=Giocatore[playerid][Checkpoint];
  855. SetPlayerRaceCheckpoint(playerid,0,CheckpointGara[g][c][CXPos],CheckpointGara[g][c][CYPos],CheckpointGara[g][c][CZPos],CheckpointGara[g][c+1][CXPos],CheckpointGara[g][c+1][CYPos],CheckpointGara[g][c+1][CZPos],9);
  856. return 1;
  857. }
  858. //=========SECHECKPOINTFINALE
  859. else if(Giocatore[playerid][Checkpoint]==Gara[Giocatore[playerid][IdGara]][NumeroCheckpoint]-1)
  860. {
  861. Giocatore[playerid][Checkpoint]++;
  862. c=Giocatore[playerid][Checkpoint];
  863. SetPlayerRaceCheckpoint(playerid,1,CheckpointGara[g][c][CXPos],CheckpointGara[g][c][CYPos],CheckpointGara[g][c][CZPos],CheckpointGara[g][c+1][CXPos],CheckpointGara[g][c+1][CYPos],CheckpointGara[g][c+1][CZPos],9);
  864. return 1;
  865. }
  866. return 1;
  867. }
  868. //===================================================ONPLAYERLEAVERACECHECKPOINT
  869. public OnPlayerLeaveRaceCheckpoint(playerid)
  870. {
  871. OnPlayerEnterRaceCheckpoint(playerid);
  872. return 1;
  873. }
  874. //==============================================================ONDIALOGRESPONSE
  875. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  876. {
  877. if(dialogid==DIALOGINFOGARA2)
  878. {
  879. Giocatore[playerid][AttivaCheck]=1;
  880. return 1;
  881. }
  882. if(dialogid==DIALOGINSEGUIMENTO)
  883. {
  884. if(strcmp(inputtext,"Yes",true) && strcmp(inputtext,"No",true)) return ShowPlayerDialog(playerid,DIALOGINSEGUIMENTO,DIALOG_STYLE_INPUT,"Chase option","{FFFFFF}ERROR:\nType Yes or No\nDo you want this race to be a Chase type?\n(Type Yes or No)","Continue","");
  885. format(stringa,sizeof(stringa),"Races/Race%d.txt",Giocatore[playerid][GaraEditorId]);
  886. new File:nomegara=fopen(stringa, io_append);
  887. if(!strcmp(inputtext,"Yes",true))
  888. fwrite(nomegara,",1");
  889. if(!strcmp(inputtext,"No",true))
  890. fwrite(nomegara,",0");
  891. fclose(nomegara);
  892. ShowPlayerDialog(playerid,DIALOGINFOGARA2,0,"Race Info Menu","{FFFFFF}You created the race's info file.\nNow you need a checkpoint list.\nUse the command \"{C14124}/check{FFFFFF}\" to create checkpoint for your race.\nOnce you've finished, type \"{C14124}/endcheck{FFFFFF}\" to exit builder mode and load the new race.","Go","");
  893. return 1;
  894. }
  895. if(dialogid==DIALOGCOSTOGARA)
  896. {
  897. if(!strlen(inputtext) || !isNumeric(inputtext) || strval(inputtext)<=0) return ShowPlayerDialog(playerid,DIALOGCOSTOGARA,DIALOG_STYLE_INPUT,"Race's Cost","{FFFFFF}Type the cost to join your race (min 1):","Continue","");
  898. format(stringa,sizeof(stringa),"Races/Race%d.txt",Giocatore[playerid][GaraEditorId]);
  899. new File:nomegara=fopen(stringa, io_append);
  900. GetPlayerName(playerid,nome,sizeof(nome));
  901. format(stringa,sizeof(stringa),"%d,1000,Nobody,%s",strval(inputtext),nome);
  902. fwrite(nomegara,stringa);
  903. fclose(nomegara);
  904. ShowPlayerDialog(playerid,DIALOGINSEGUIMENTO,DIALOG_STYLE_INPUT,"Chase option","{FFFFFF}Do you want this race to be a Chase type?\n(Type Yes or No)","Continue","");
  905. return 1;
  906. }
  907. if(dialogid==DIALOGGIRIGARA)
  908. {
  909. if(!strlen(inputtext) || !isNumeric(inputtext) || strval(inputtext)<=0) return ShowPlayerDialog(playerid,DIALOGGIRIGARA,DIALOG_STYLE_INPUT,"Race's Laps","{FFFFFF}ERROR:\nType the number of laps for your races (1:sprint 2-more:circuit)","Continue","");
  910. format(stringa,sizeof(stringa),"Races/Race%d.txt",Giocatore[playerid][GaraEditorId]);
  911. new File:nomegara=fopen(stringa, io_append);
  912. format(stringa,sizeof(stringa),"%d,",strval(inputtext));
  913. fwrite(nomegara,stringa);
  914. fclose(nomegara);
  915. ShowPlayerDialog(playerid,DIALOGCOSTOGARA,DIALOG_STYLE_INPUT,"Race's Cost","{FFFFFF}Type the cost to join your race (min 1):","Continue","");
  916. return 1;
  917. }
  918. if(dialogid==DIALOGNOMEGARA)
  919. {
  920. if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOGNOMEGARA,DIALOG_STYLE_INPUT,"Race's Name","{FFFFFF}ERROR:\nType the name of your race:","Continua","");
  921. format(stringa,sizeof(stringa),"Races/Race%d.txt",Giocatore[playerid][GaraEditorId]);
  922. new File:nomegara=fopen(stringa, io_write);
  923. format(stringa,sizeof(stringa),"%s,",inputtext);
  924. fwrite(nomegara,stringa);
  925. fclose(nomegara);
  926. ShowPlayerDialog(playerid,DIALOGGIRIGARA,DIALOG_STYLE_INPUT,"Race's Laps","{FFFFFF}Type the number of laps for your races (1:sprint 2-more:circuit)","Continue","");
  927. return 1;
  928. }
  929. if(dialogid==DIALOGINFOCOSTRUTTORE)
  930. {
  931. ShowPlayerDialog(playerid,DIALOGNOMEGARA,DIALOG_STYLE_INPUT,"Race's Name","{FFFFFF}Type the name of you race:","Continue","");
  932. return 1;
  933. }
  934. if(dialogid==DIALOGINFO) return 1;
  935. if(!response) return 1;
  936. if(Giocatore[playerid][IdGara]!=-1) return SendClientMessage(playerid,ROSSO,"[ERROR:] {FFFFFF}You already joined another race.");
  937. if(Gara[listitem][Avviata]==1) return SendClientMessage(playerid,ROSSO,"[ERROR:] {FFFFFF}This race is already started. Wait its ending before joining.");
  938. if(Gara[listitem][Inseguimento]==1)
  939. {
  940. if(Gara[listitem][Partecipanti]==2) return SendClientMessage(playerid,ROSSO,"[ERROR:] {FFFFFF}There are already two player in this race (chase race limit)");
  941. if(Gara[listitem][Partecipanti]==0)
  942. {
  943. SendClientMessage(playerid,BIANCO,"[RACE:] You are the hunted. When the race starts, stay in front of your opponent and try to escape.");
  944. }
  945. if(Gara[listitem][Partecipanti]==1)
  946. {
  947. SendClientMessage(playerid,BIANCO,"[RACE:] You are the hunter. When the race starts, stay behind your opponent and chase him.");
  948. Giocatore[playerid][Inseguitore]=1;
  949. }
  950. }
  951. Giocatore[playerid][IdGara]=listitem;
  952. GetPlayerName(playerid,nome,sizeof(nome));
  953. format(stringa,sizeof(stringa),"{8CE46C}%s {FFFFFF}join the race.",nome);
  954. GivePlayerMoney(playerid,-Gara[listitem][Costo]);
  955. MandaMessaggioPartecipanti(listitem,stringa);
  956. #if defined TELETRASPORTO_INIZIAGARA
  957. SetPlayerPos(playerid,CheckpointGara[listitem][0][CXPos],CheckpointGara[listitem][0][CYPos],CheckpointGara[listitem][0][CZPos]);
  958. SendClientMessage(playerid,BIANCO,"[RACE:] You join the race. Type \"{C14124}/Ready{FFFFFF}\" when you are ready.");
  959. #else
  960. SendClientMessage(playerid,BIANCO,"[RACE:] You join the race. Go to the checkpoint and type \"{C14124}/Ready{FFFFFF}\" when you are ready");
  961. #endif
  962. Gara[listitem][Partecipanti]++;
  963. SetPlayerRaceCheckpoint(playerid,0,CheckpointGara[listitem][0][CXPos],CheckpointGara[listitem][0][CYPos],CheckpointGara[listitem][0][CZPos],CheckpointGara[listitem][1][CXPos],CheckpointGara[listitem][1][CYPos],CheckpointGara[listitem][1][CZPos],9);
  964. new minuti=floatround(Gara[listitem][Record]/60);
  965. new secondi=Gara[listitem][Record]-(minuti*60);
  966. format(stringa,sizeof(stringa),"{FFFFFF}Track: {8CE46C}%s\n{FFFFFF}Laps: {8CE46C}%d\n{FFFFFF}Cost: {8CE46C}%d$\n{FFFFFF}Record: {8CE46C}%02d:%02d\n{FFFFFF}Player's Record: {8CE46C}%s\n{FFFFFF}Builder: {8CE46C}%s",Gara[listitem][Nome],Gara[listitem][Giri],Gara[listitem][Costo],minuti,secondi,Gara[listitem][GiocatoreRecord],Gara[listitem][Produttore]);
  967. ShowPlayerDialog(playerid,DIALOGINFO,0,"Race Info",stringa,"Quit","");
  968. return 1;
  969. }
  970. //====================================================MANDAMESSAGGIOPARTECIPANTI
  971. stock MandaMessaggioPartecipanti(idGara,Messaggio[])
  972. {
  973. for(new i=0;i<MAX_PLAYERS;i++)
  974. {
  975. if(Giocatore[i][IdGara]==idGara)
  976. SendClientMessage(i,BIANCO,Messaggio);
  977. }
  978. }
  979. //================================================================SUONOGIOCATORE
  980. stock SuonoGiocatore(playerid,idsuono)
  981. {
  982. new Float:SPosX,Float:SPosY,Float:SPosZ;
  983. GetPlayerPos(playerid,SPosX,SPosY,SPosZ);
  984. PlayerPlaySound(playerid,idsuono,SPosX,SPosY,SPosZ);
  985. return 1;
  986. }
  987. //=========================================================================SPLIT
  988. stock split(const strsrc[], strdest[][], delimiter)
  989. {
  990. new i, li,aNum,len;
  991. while(i <= strlen(strsrc))
  992. {
  993. if(strsrc[i]==delimiter || i==strlen(strsrc))
  994. {
  995. len = strmid(strdest[aNum], strsrc, li, i, 128);
  996. strdest[aNum][len] = 0;
  997. li = i+1;
  998. aNum++;
  999. }
  1000. i++;
  1001. }
  1002. return 1;
  1003. }
  1004. //=====================================================================ISNUMERIC
  1005. stock isNumeric(const string[]) {
  1006. new length=strlen(string);
  1007. if (length==0) return false;
  1008. for (new i = 0; i < length; i++) {
  1009. if (
  1010. (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+')
  1011. || (string[i]=='-' && i!=0)
  1012. || (string[i]=='+' && i!=0)
  1013. ) return false;
  1014. }
  1015. if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
  1016. return true;
  1017. }
Advertisement
Add Comment
Please, Sign In to add comment