xMaCRoSx

PRaceSystem and turbo Integrated

Sep 4th, 2011
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 49.55 KB | None | 0 0
  1. /*
  2. ================================================================================
  3.                                Phanto's Script
  4. ________________________________________________________________________________
  5. •Script: PRaceSystem         •Scripter: Phanto90
  6. •Tipo: FS                    •Dimesione: 46 Kb(.pwn) / 57 Kb(.amx)
  7. •Righe: 1013                 •Versione: 1.2v
  8. ________________________________________________________________________________
  9.                               * Descrizione *
  10. Vi siete stancati del vostro server senza azione? Niente paura! Ecco a voi un
  11. Filterscript che vi permetterà di divertirvi con emozionanti gare!
  12. Con la versione 1.2 è stata aggiunta la nuovissima modalità di gara "Inseguimento"
  13. Assieme è compreso un piccolo editor e una guida che vi permetteranno di gestire
  14. al meglio l'intero sistema.
  15.  
  16. Caratteristiche:
  17. •3 tipologie di gare: Circuito, Sprint & Inseguimento.
  18. •Possibilità di costruire gare personalizzate facilmente.
  19. •Possibilità di svolgere più gare contemporaneamente da diversi giocatori.
  20. •Sistema funzionale, ma anche graficamente gradevole.
  21.  
  22. Bug Fixati e aggiunte:
  23. -Versione 1.1
  24. •Fixato un bug del comando /lasciagara a gara non iniziata
  25. •Inserito un editor gare totalmente ingame
  26. •Fixati bug minori
  27. -Versione 1.2
  28. •Inserita modalità gara Inseguimento
  29.  
  30.  
  31.               Grazie per aver scelto un prodotto Pawnoscripter!
  32.                      http://pawnoscripter.forumfree.it
  33.      
  34.                                                                       Phanto90
  35. ________________________________________________________________________________
  36.  
  37. Vi preghiamo di non rimuovere i crediti.
  38. ================================================================================
  39. */
  40. #include <a_samp>
  41. //===============MODIFICABILI
  42. #define TELETRASPORTO_INIZIAGARA // Commenta il define per disattivare l'opzione
  43. #define MAX_GARE 20
  44. #define MAX_CHECKPOINT 40
  45. //===============COLORI
  46. #define ROSSO    0xFF3233FF
  47. #define BIANCO   0xFFFFFFFF
  48. #define VERDE    0x00FF00FF
  49. #define TURCHESE 0x3C93FFFF
  50. //================DIALOG
  51. #define DIALOGGARE            10016
  52. #define DIALOGINFO            10017
  53. #define DIALOGINFOCOSTRUTTORE 10018
  54. #define DIALOGNOMEGARA        10019
  55. #define DIALOGGIRIGARA        10020
  56. #define DIALOGCOSTOGARA       10021
  57. #define DIALOGINFOGARA2       10022
  58. #define DIALOGINSEGUIMENTO    10023
  59. #define PREMUTO(%0) \
  60.             (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  61.     #define DIALOGTURBO      10005
  62.     #define COMANDOTURBO     "/turbo"
  63.     #define TASTOTURBO       KEY_ANALOG_UP  //Normalmente NUM8
  64.     #define TASTOSALTO       KEY_CROUCH     //Normalmente H o CAPS LOCK
  65.     #define TASTORIPARAZIONE KEY_SUBMISSION //Normalmente Tasto 2
  66.     #define RIPARAZIONEATTIVATA 1 //1=attiva altri valori=disabilita - modalità riparazione con tasto 2
  67.     #pragma tabsize 0
  68. //=========================FORWARD
  69. forward Tre(playerid);
  70. forward Due(playerid);
  71. forward Uno(playerid);
  72. forward Via(playerid);
  73. forward Secondo(playerid);
  74. forward Cronometro(playerid);
  75. //=========================VARIABILIGIOCATORE
  76. enum InfoGiocatore{IdGara,Tempo,Giro,Checkpoint,Pronto,Costruttore,GaraEditorId,AttivaCheck,Inseguitore,Punti};
  77. new Giocatore[MAX_PLAYERS][InfoGiocatore];
  78. new Float:XPosizione,Float:YPosizione,Float:ZPosizione;
  79. new nome[25];
  80. //turbo//
  81.  new Turbo[MAX_PLAYERS]=0;
  82.     new Float:VelX,Float:VelY,Float:VelZ;
  83. //fineturbo//
  84. //==============VARIABILIGARE
  85. enum InfoGara{Nome[50],Giri,NumeroCheckpoint,Inseguimento,Costo,Partecipanti,PartecipantiPronti,Avviata,Record,GiocatoreRecord[25],Produttore[25],Podio};
  86. new Gara[MAX_GARE][InfoGara];
  87. enum CheckInfo{Float:CXPos,Float:CYPos,Float:CZPos};
  88. new CheckpointGara[MAX_GARE][MAX_CHECKPOINT][CheckInfo];
  89. new TimerPlayers[MAX_PLAYERS];
  90. new GareCaricate,GareEditor;
  91. //=============VARIABILI
  92. new stringa[1000],stringa2[1000];
  93. new InfoSplit[7][250];
  94. new InfoCheck1[MAX_CHECKPOINT][256];
  95. new InfoCheck2[3][256];
  96. //============TEXTDRAW
  97. new Text:sfondo,Text:sfondorosso,Text:sfondogiallo,Text:sfondoverde,Text:rossoacceso,Text:gialloacceso,Text:verdeacceso; //Textdraw semaforo
  98. new Text:TimerSfondo,Text:TimerText[MAX_PLAYERS]; //Timer textdraw
  99. new Text:TextGiriSfondo,Text:TextGiriContatore[MAX_PLAYERS]; //Textdraw laps
  100. 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];
  101. //====================================================================CARICAGARE
  102. stock CaricaGare()
  103. {
  104.    new stringagara[1000];
  105.    for(new i=0;i<MAX_GARE;i++)
  106.    {
  107.    //==============CARICAMENTOINFOGARA
  108.    format(stringa,sizeof(stringa),"Gare/Gara%d.txt",i);
  109.    format(stringa2,sizeof(stringa2),"Gara %d non trovata. Caricamento fallito.",i);
  110.    if(!fexist(stringa)) return printf(stringa2);
  111.    new File:nomegara=fopen(stringa, io_read);
  112.    fread(nomegara,stringagara);
  113.    fclose(nomegara);
  114.    split(stringagara,InfoSplit,',');
  115.    format(Gara[i][Nome],50,InfoSplit[0]); //Nome,Giri,Costo,Record,GiocatoreRecord,Produttore
  116.    Gara[i][Giri]=strval(InfoSplit[1]);
  117.    Gara[i][Costo]=strval(InfoSplit[2]);
  118.    Gara[i][Record]=strval(InfoSplit[3]);
  119.    format(Gara[i][GiocatoreRecord],25,InfoSplit[4]);
  120.    format(Gara[i][Produttore],300,InfoSplit[5]);
  121.    Gara[i][Inseguimento]=strval(InfoSplit[6]);
  122.    Gara[i][NumeroCheckpoint]=-1;
  123.    format(stringa,sizeof(stringa),"%s,%d,%d$,%s,%s",Gara[i][Nome],Gara[i][Giri],Gara[i][Costo],Gara[i][GiocatoreRecord],Gara[i][Produttore]);
  124.    printf(stringa);
  125.    //================CARICAMENTOCHECKPOINT
  126.    format(stringagara,sizeof(stringagara),"");
  127.    format(stringa,sizeof(stringa),"Gare/Check%d.txt",i);
  128.    format(stringa2,sizeof(stringa2),"Lista Checkpoint Gara%d non trovata. Caricamento fallito.",i);
  129.    if(!fexist(stringa)) return printf(stringa2);
  130.    nomegara=fopen(stringa, io_read);
  131.    fread(nomegara,stringagara);
  132.    fclose(nomegara);
  133.    split(stringagara,InfoCheck1,'|');
  134.    print("____________________________________");
  135.    for(new j=0;j<MAX_CHECKPOINT;j++)
  136.     {
  137.     split(InfoCheck1[j],InfoCheck2,',');
  138.     if(floatstr(InfoCheck2[0])==0) {printf("%d Checkpoint caricati. Gara id: %d.",Gara[i][NumeroCheckpoint]+1,i);break;}
  139.     CheckpointGara[i][j][CXPos]=floatstr(InfoCheck2[0]);
  140.     CheckpointGara[i][j][CYPos]=floatstr(InfoCheck2[1]);
  141.     CheckpointGara[i][j][CZPos]=floatstr(InfoCheck2[2]);
  142.     Gara[i][NumeroCheckpoint]++;
  143.     }
  144.    GareCaricate=i;
  145.    GareEditor=i;
  146.    print("____________________________________");
  147.    }
  148.    return 1;
  149. }
  150. //====================================================================SALVAGARE
  151. stock SalvaGare()
  152. {
  153.    for(new i=0;i<GareCaricate;i++)
  154.    {
  155.    format(stringa,sizeof(stringa),"Gare/Gara%d.txt",i);
  156.    format(stringa2,sizeof(stringa2),"Gara %d non trovata. Salvataggio fallito",i);
  157.    if(!fexist(stringa)) return printf(stringa2);
  158.    new File:nomegara=fopen(stringa, io_write);
  159.    new stringagara[700];  
  160.    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]);
  161.    fwrite(nomegara,stringagara);
  162.    fclose(nomegara);
  163.    }
  164.    return 1;
  165. }
  166. //=====================================================================AVVIAGARA
  167. stock AvviaGara(idGara)
  168. {
  169.   format(stringa,sizeof(stringa),"[GARA:] La gara {446ED1}%s{FFFFFF} sta iniziando!",Gara[idGara][Nome]);
  170.   SendClientMessageToAll(BIANCO,stringa);
  171.   Gara[idGara][Avviata]=1;
  172.   for(new i=0;i<MAX_PLAYERS;i++)
  173.   {
  174.   if(Giocatore[i][IdGara]==idGara)
  175.    {
  176.    TogglePlayerControllable(i,0);
  177.    TextDrawShowForPlayer(i,sfondo);
  178.    TextDrawShowForPlayer(i,sfondorosso);
  179.    TextDrawShowForPlayer(i,sfondogiallo);
  180.    TextDrawShowForPlayer(i,sfondoverde);
  181.    TextDrawShowForPlayer(i,rossoacceso);
  182.    if(Gara[Giocatore[i][IdGara]][Inseguimento])
  183.    {
  184.     TextDrawShowForPlayer(i,TextSfondoInseguimento);
  185.     TextDrawShowForPlayer(i,SfondoInseguimentoRosso);
  186.     TextDrawShowForPlayer(i,SfondoInseguimentoGiallo);
  187.     TextDrawShowForPlayer(i,SfondoInseguimentoVerde);
  188.     TextDrawShowForPlayer(i,SfondoInseguimentoAzzurro);
  189.     TextDrawShowForPlayer(i,TextInseguimento);
  190.     TextDrawShowForPlayer(i,TextPessimo);
  191.     TextDrawShowForPlayer(i,TextMediocre);
  192.     TextDrawShowForPlayer(i,TextBuono);
  193.     TextDrawShowForPlayer(i,TextOttimo);
  194.     TextDrawSetString(TextPunti[i],"Punti: 0000");
  195.     TextDrawShowForPlayer(i,TextPunti[i]);
  196.    }
  197.    SetTimerEx("Tre",1000,false,"idx",i);
  198.    }
  199.   }
  200.   return 1;
  201. }
  202. //===========================================================================TRE
  203. public Tre(playerid)
  204. {
  205.  GameTextForPlayer(playerid,"~r~3",1000,3);
  206.  SuonoGiocatore(playerid,1056);
  207.  Giocatore[playerid][Tempo]=0;
  208.  Giocatore[playerid][Giro]=1;
  209.  format(stringa,sizeof(stringa),"Giri: 1/%d",Gara[Giocatore[playerid][IdGara]][Giri]);
  210.  TextDrawSetString(TextGiriContatore[playerid],stringa);
  211.  TextDrawSetString(TimerText[playerid],"00:00");
  212.  GetPlayerPos(playerid,XPosizione,YPosizione,ZPosizione);
  213.  SetPlayerCameraPos(playerid,XPosizione+4,YPosizione+2,ZPosizione+3);
  214.  SetPlayerCameraLookAt(playerid,XPosizione,YPosizione,ZPosizione);
  215.  TextDrawShowForPlayer(playerid,TimerSfondo);
  216.  TextDrawShowForPlayer(playerid,TimerText[playerid]);
  217.  TextDrawShowForPlayer(playerid,TextGiriSfondo);
  218.  TextDrawShowForPlayer(playerid,TextGiriContatore[playerid]);
  219.  SetTimerEx("Due",1000,false,"idx",playerid);
  220. }
  221. //===========================================================================DUE
  222. public Due(playerid)
  223. {
  224.  GameTextForPlayer(playerid,"~r~3~n~~y~2",1000,3);
  225.  SuonoGiocatore(playerid,1056);
  226.  GetPlayerPos(playerid,XPosizione,YPosizione,ZPosizione);
  227.  SetPlayerCameraPos(playerid,XPosizione-4,YPosizione-2,ZPosizione+3);
  228.  SetPlayerCameraLookAt(playerid,XPosizione,YPosizione,ZPosizione);
  229.  SetTimerEx("Uno",1000,false,"idx",playerid);
  230. }
  231. //===========================================================================UNO
  232. public Uno(playerid)
  233. {
  234.  GameTextForPlayer(playerid,"~r~3~n~~y~2~n~~g~~h~1",1000,3);
  235.  SuonoGiocatore(playerid,1056);
  236.  GetPlayerPos(playerid,XPosizione,YPosizione,ZPosizione);
  237.  SetPlayerCameraPos(playerid,XPosizione+4,YPosizione-2,ZPosizione+3);
  238.  SetPlayerCameraLookAt(playerid,XPosizione,YPosizione,ZPosizione);
  239.  TextDrawShowForPlayer(playerid,gialloacceso);
  240.  TextDrawHideForPlayer(playerid,rossoacceso);
  241.  SetTimerEx("Via",1000,false,"idx",playerid);
  242. }
  243. //===========================================================================VIA
  244. public Via(playerid)
  245. {
  246.  SetCameraBehindPlayer(playerid);
  247.  GameTextForPlayer(playerid,"~w~Via!",3000,3);
  248.  SuonoGiocatore(playerid,1057);
  249.  TogglePlayerControllable(playerid,1);
  250.  TextDrawShowForPlayer(playerid,verdeacceso);
  251.  TextDrawHideForPlayer(playerid,gialloacceso);
  252.  SetTimerEx("Secondo",1000,false,"idx",playerid);
  253.  TimerPlayers[playerid]=SetTimerEx("Cronometro",1000,true,"idx",playerid);
  254. }
  255. //=======================================================================SECONDO
  256. public Secondo(playerid)
  257. {
  258.  TextDrawHideForPlayer(playerid,sfondo);
  259.  TextDrawHideForPlayer(playerid,sfondorosso);
  260.  TextDrawHideForPlayer(playerid,sfondogiallo);
  261.  TextDrawHideForPlayer(playerid,sfondoverde);
  262.  TextDrawHideForPlayer(playerid,verdeacceso);
  263.  return 1;
  264. }
  265. //===================================================================CONTROMETRO
  266. public Cronometro(playerid)
  267. {
  268.  Giocatore[playerid][Tempo]++;
  269.  new Minuti=floatround(Giocatore[playerid][Tempo]/60);
  270.  new Secondi=Giocatore[playerid][Tempo]-(Minuti*60);
  271.  if(Minuti>20)
  272.  {
  273.  SendClientMessage(playerid,ROSSO,"[GARA:] {FFFFFF}Hai abbandonato la gara automaticamente per tempo eccessivo (20 minuti)");
  274.  LasciaGara(playerid);
  275.  return 1;
  276.  }
  277.  new stringatempo[10];
  278.  format(stringatempo,sizeof(stringatempo),"%02d:%02d",Minuti,Secondi);
  279.  TextDrawSetString(TimerText[playerid],stringatempo);
  280.  if(Gara[Giocatore[playerid][IdGara]][Inseguimento]==1)
  281.  {
  282.  for(new i=0;i<MAX_PLAYERS;i++)
  283.   {
  284.   if(Giocatore[i][IdGara]==Giocatore[playerid][IdGara] && i!=playerid)
  285.    {
  286.    GetPlayerPos(i,XPosizione,YPosizione,ZPosizione);
  287.    break;
  288.    }
  289.   }
  290.  TextDrawHideForPlayer(playerid,SfondoInseguimentoRosso);
  291.  TextDrawHideForPlayer(playerid,SfondoInseguimentoGiallo);
  292.  TextDrawHideForPlayer(playerid,SfondoInseguimentoVerde);
  293.  TextDrawHideForPlayer(playerid,SfondoInseguimentoAzzurro);
  294.  if(!Giocatore[playerid][Inseguitore])
  295.   {
  296.   if(IsPlayerInRangeOfPoint(playerid,15,XPosizione,YPosizione,ZPosizione)){
  297.   Giocatore[playerid][Punti]+=3; TextDrawShowForPlayer(playerid,SfondoInseguimentoRosso);}
  298.   else if (IsPlayerInRangeOfPoint(playerid,30,XPosizione,YPosizione,ZPosizione)){
  299.   Giocatore[playerid][Punti]+=5; TextDrawShowForPlayer(playerid,SfondoInseguimentoGiallo);}
  300.   else if(IsPlayerInRangeOfPoint(playerid,40,XPosizione,YPosizione,ZPosizione)){
  301.   Giocatore[playerid][Punti]+=7; TextDrawShowForPlayer(playerid,SfondoInseguimentoVerde);}
  302.   else{
  303.   Giocatore[playerid][Punti]+=8; TextDrawShowForPlayer(playerid,SfondoInseguimentoAzzurro);}
  304.   }
  305.  else
  306.   {
  307.   if(IsPlayerInRangeOfPoint(playerid,15,XPosizione,YPosizione,ZPosizione)){
  308.   Giocatore[playerid][Punti]+=8; TextDrawShowForPlayer(playerid,SfondoInseguimentoAzzurro);}
  309.   else if (IsPlayerInRangeOfPoint(playerid,30,XPosizione,YPosizione,ZPosizione)){
  310.   Giocatore[playerid][Punti]+=7; TextDrawShowForPlayer(playerid,SfondoInseguimentoVerde);}
  311.   else if(IsPlayerInRangeOfPoint(playerid,40,XPosizione,YPosizione,ZPosizione)){
  312.   Giocatore[playerid][Punti]+=5; TextDrawShowForPlayer(playerid,SfondoInseguimentoGiallo);}
  313.   else{
  314.   Giocatore[playerid][Punti]+=3; TextDrawShowForPlayer(playerid,SfondoInseguimentoRosso);}
  315.   }
  316.  format(stringa,sizeof(stringa),"Punti: %d",Giocatore[playerid][Punti]);
  317.  TextDrawSetString(TextPunti[playerid],stringa);
  318.  }
  319.  return 1;
  320. }
  321. //====================================================================LASCIAGARA
  322. stock LasciaGara(playerid)
  323. {
  324.     if(Giocatore[playerid][IdGara]==-1) return 1;
  325.     if(Gara[Giocatore[playerid][IdGara]][Avviata]==0)
  326.     {
  327.     if(Giocatore[playerid][Pronto]==1)
  328.     Gara[Giocatore[playerid][IdGara]][PartecipantiPronti]--;
  329.     }
  330.     KillTimer(TimerPlayers[playerid]);
  331.     Giocatore[playerid][Tempo]=0;
  332.     GetPlayerName(playerid,nome,sizeof(nome));
  333.     format(stringa,sizeof(stringa),"[GARA:] {8CE46C}%s {FFFFFF}ha abbandonato la gara.", nome);
  334.     MandaMessaggioPartecipanti(Giocatore[playerid][IdGara],stringa);
  335.     //==========TEXTBASE
  336.     TextDrawHideForPlayer(playerid,sfondo);
  337.     TextDrawHideForPlayer(playerid,TimerText[playerid]);
  338.     TextDrawHideForPlayer(playerid,TimerSfondo);
  339.     TextDrawHideForPlayer(playerid,sfondorosso);
  340.     TextDrawHideForPlayer(playerid,sfondogiallo);
  341.     TextDrawHideForPlayer(playerid,sfondoverde);
  342.     TextDrawHideForPlayer(playerid,rossoacceso);
  343.     TextDrawHideForPlayer(playerid,gialloacceso);
  344.     TextDrawHideForPlayer(playerid,verdeacceso);
  345.     TextDrawHideForPlayer(playerid,TextGiriSfondo);
  346.     //==========TEXTINSEGUIMENTO
  347.     TextDrawHideForPlayer(playerid,TextSfondoInseguimento);
  348.     TextDrawHideForPlayer(playerid,SfondoInseguimentoRosso);
  349.     TextDrawHideForPlayer(playerid,SfondoInseguimentoGiallo);
  350.     TextDrawHideForPlayer(playerid,SfondoInseguimentoVerde);
  351.     TextDrawHideForPlayer(playerid,SfondoInseguimentoAzzurro);
  352.     TextDrawHideForPlayer(playerid,TextInseguimento);
  353.     TextDrawHideForPlayer(playerid,TextPessimo);
  354.     TextDrawHideForPlayer(playerid,TextMediocre);
  355.     TextDrawHideForPlayer(playerid,TextBuono);
  356.     TextDrawHideForPlayer(playerid,TextOttimo);
  357.     TextDrawHideForPlayer(playerid,TextPunti[playerid]);
  358.    
  359.     TextDrawHideForPlayer(playerid,TextGiriContatore[playerid]);
  360.     TextDrawSetString(TimerText[playerid],"00:00");
  361.     Giocatore[playerid][Checkpoint]=0;
  362.     Gara[Giocatore[playerid][IdGara]][Partecipanti]--;
  363.     if(Gara[Giocatore[playerid][IdGara]][PartecipantiPronti]==Gara[Giocatore[playerid][IdGara]][Partecipanti] && Gara[Giocatore[playerid][IdGara]][Partecipanti]!=0 && Gara[Giocatore[playerid][IdGara]][Avviata]==0)
  364.     AvviaGara(Giocatore[playerid][IdGara]);
  365.     ChiudiGara(Giocatore[playerid][IdGara]);
  366.     Giocatore[playerid][IdGara]=-1;
  367.     Giocatore[playerid][Pronto]=0;
  368.     Giocatore[playerid][Giro]=1;
  369.     Giocatore[playerid][Inseguitore]=0;
  370.     Giocatore[playerid][Punti]=0;
  371.     DisablePlayerRaceCheckpoint(playerid);
  372.     return 1;
  373. }
  374. //====================================================================CHIUDIGARA
  375. stock ChiudiGara(idGara)
  376. {
  377.  if(Gara[idGara][Partecipanti]==0 && idGara!=-1)
  378.  {
  379.  format(stringa,sizeof(stringa),"[GARA:] {FFFFFF}La gara {446ED1}%s{FFFFFF} si è conclusa.",Gara[idGara][Nome]);
  380.  SendClientMessageToAll(BIANCO,stringa);
  381.  Gara[idGara][Podio]=0;
  382.  Gara[idGara][Avviata]=0;
  383.  Gara[idGara][Partecipanti]=0;
  384.  Gara[idGara][PartecipantiPronti]=0;
  385.  }
  386. }
  387. //============================================================ONFILTERSCRIPTINIT
  388. public OnFilterScriptInit()
  389.   {
  390.   print("_______________________________________________");
  391.   print(" PRaceSystem by Phanto90 caricato con successo ");
  392.   print("_______________________________________________");
  393.   CaricaGare();
  394.   TextGiriSfondo = TextDrawCreate(541.000000, 189.000000, "1");
  395.   TextDrawBackgroundColor(TextGiriSfondo, 0);
  396.   TextDrawFont(TextGiriSfondo, 1);
  397.   TextDrawLetterSize(TextGiriSfondo, 0.579999, 1.700000);
  398.   TextDrawColor(TextGiriSfondo, 0);
  399.   TextDrawSetOutline(TextGiriSfondo, 0);
  400.   TextDrawSetProportional(TextGiriSfondo, 1);
  401.   TextDrawSetShadow(TextGiriSfondo, 1);
  402.   TextDrawUseBox(TextGiriSfondo, 1);
  403.   TextDrawBoxColor(TextGiriSfondo, 1010580600);
  404.   TextDrawTextSize(TextGiriSfondo, 613.000000, 0.000000);
  405.  
  406.   TimerSfondo = TextDrawCreate(620.000000, 160.000000, ".sfo");
  407.   TextDrawBackgroundColor(TimerSfondo, 0);
  408.   TextDrawFont(TimerSfondo, 1);
  409.   TextDrawLetterSize(TimerSfondo, 0.500000, 2.499999);
  410.   TextDrawColor(TimerSfondo, 0);
  411.   TextDrawSetOutline(TimerSfondo, 0);
  412.   TextDrawSetProportional(TimerSfondo, 1);
  413.   TextDrawSetShadow(TimerSfondo, 1);
  414.   TextDrawUseBox(TimerSfondo, 1);
  415.   TextDrawBoxColor(TimerSfondo, 1010580580);
  416.   TextDrawTextSize(TimerSfondo, 535.000000, 0.000000);
  417.  
  418.   sfondo = TextDrawCreate(265.000000, 40.000000, "sfondo");
  419.   TextDrawBackgroundColor(sfondo, 0);
  420.   TextDrawFont(sfondo, 1);
  421.   TextDrawLetterSize(sfondo, 0.500000, 3.500000);
  422.   TextDrawColor(sfondo, 0);
  423.   TextDrawSetOutline(sfondo, 0);
  424.   TextDrawSetProportional(sfondo, 1);
  425.   TextDrawSetShadow(sfondo, 1);
  426.   TextDrawUseBox(sfondo, 1);
  427.   TextDrawBoxColor(sfondo, 338826495);
  428.   TextDrawTextSize(sfondo, 384.000000, 0.000000);
  429.  
  430.   sfondorosso = TextDrawCreate(278.000000, 48.000000, "sfondorosso");
  431.   TextDrawBackgroundColor(sfondorosso, 0);
  432.   TextDrawFont(sfondorosso, 1);
  433.   TextDrawLetterSize(sfondorosso, 0.500000, 1.800001);
  434.   TextDrawColor(sfondorosso, 0);
  435.   TextDrawSetOutline(sfondorosso, 0);
  436.   TextDrawSetProportional(sfondorosso, 1);
  437.   TextDrawSetShadow(sfondorosso, 1);
  438.   TextDrawUseBox(sfondorosso, 1);
  439.   TextDrawBoxColor(sfondorosso, 840176895);
  440.   TextDrawTextSize(sfondorosso, 293.000000, 0.000000);
  441.  
  442.   sfondogiallo = TextDrawCreate(320.000000, 48.000000, "sfondoarancione");
  443.   TextDrawBackgroundColor(sfondogiallo, 0);
  444.   TextDrawFont(sfondogiallo, 1);
  445.   TextDrawLetterSize(sfondogiallo, 0.500000, 1.800001);
  446.   TextDrawColor(sfondogiallo, 0);
  447.   TextDrawSetOutline(sfondogiallo, 0);
  448.   TextDrawSetProportional(sfondogiallo, 1);
  449.   TextDrawSetShadow(sfondogiallo, 1);
  450.   TextDrawUseBox(sfondogiallo, 1);
  451.   TextDrawBoxColor(sfondogiallo, 842142975);
  452.   TextDrawTextSize(sfondogiallo, 334.000000, 0.000000);
  453.  
  454.   sfondoverde = TextDrawCreate(359.000000, 48.000000, "sfondoverde");
  455.   TextDrawBackgroundColor(sfondoverde, 0);
  456.   TextDrawFont(sfondoverde, 1);
  457.   TextDrawLetterSize(sfondoverde, 0.500000, 1.800001);
  458.   TextDrawColor(sfondoverde, 0);
  459.   TextDrawSetOutline(sfondoverde, 0);
  460.   TextDrawSetProportional(sfondoverde, 1);
  461.   TextDrawSetShadow(sfondoverde, 1);
  462.   TextDrawUseBox(sfondoverde, 1);
  463.   TextDrawBoxColor(sfondoverde, 337515775);
  464.   TextDrawTextSize(sfondoverde, 373.000000, 0.000000);
  465.  
  466.   rossoacceso = TextDrawCreate(281.000000, 51.000000, "sfondorossoacceso");
  467.   TextDrawBackgroundColor(rossoacceso, 0);
  468.   TextDrawFont(rossoacceso, 1);
  469.   TextDrawLetterSize(rossoacceso, 0.500000, 1.100001);
  470.   TextDrawColor(rossoacceso, 0);
  471.   TextDrawSetOutline(rossoacceso, 0);
  472.   TextDrawSetProportional(rossoacceso, 1);
  473.   TextDrawSetShadow(rossoacceso, 1);
  474.   TextDrawUseBox(rossoacceso, 1);
  475.   TextDrawBoxColor(rossoacceso, -938208001);
  476.   TextDrawTextSize(rossoacceso, 291.000000, 0.000000);
  477.  
  478.   gialloacceso = TextDrawCreate(322.000000, 51.000000, "sfondoarancioneacceso");
  479.   TextDrawBackgroundColor(gialloacceso, 0);
  480.   TextDrawFont(gialloacceso, 1);
  481.   TextDrawLetterSize(gialloacceso, 0.500000, 1.100001);
  482.   TextDrawColor(gialloacceso, 0);
  483.   TextDrawSetOutline(gialloacceso, 0);
  484.   TextDrawSetProportional(gialloacceso, 1);
  485.   TextDrawSetShadow(gialloacceso, 1);
  486.   TextDrawUseBox(gialloacceso, 1);
  487.   TextDrawBoxColor(gialloacceso, -926411521);
  488.   TextDrawTextSize(gialloacceso, 332.000000, 0.000000);
  489.  
  490.   verdeacceso = TextDrawCreate(362.000000, 51.000000, "sfondoverdeacceso");
  491.   TextDrawBackgroundColor(verdeacceso, 0);
  492.   TextDrawFont(verdeacceso, 1);
  493.   TextDrawLetterSize(verdeacceso, 0.500000, 1.100001);
  494.   TextDrawColor(verdeacceso, 0);
  495.   TextDrawSetOutline(verdeacceso, 0);
  496.   TextDrawSetProportional(verdeacceso, 1);
  497.   TextDrawSetShadow(verdeacceso, 1);
  498.   TextDrawUseBox(verdeacceso, 1);
  499.   TextDrawBoxColor(verdeacceso, 348656895);
  500.   TextDrawTextSize(verdeacceso, 370.000000, 0.000000);
  501.  
  502.   TextSfondoInseguimento = TextDrawCreate(170.000000, 362.000000, "box");
  503.   TextDrawBackgroundColor(TextSfondoInseguimento, 0);
  504.   TextDrawFont(TextSfondoInseguimento, 1);
  505.   TextDrawLetterSize(TextSfondoInseguimento, 0.460000, 2.700011);
  506.   TextDrawColor(TextSfondoInseguimento, 0);
  507.   TextDrawSetOutline(TextSfondoInseguimento, 0);
  508.   TextDrawSetProportional(TextSfondoInseguimento, 1);
  509.   TextDrawSetShadow(TextSfondoInseguimento, 1);
  510.   TextDrawUseBox(TextSfondoInseguimento, 1);
  511.   TextDrawBoxColor(TextSfondoInseguimento, 505290340);
  512.   TextDrawTextSize(TextSfondoInseguimento, 467.000000, 0.000000);
  513.  
  514.   SfondoInseguimentoRosso = TextDrawCreate(174.000000, 366.000000, "boxrosso");
  515.   TextDrawBackgroundColor(SfondoInseguimentoRosso, 0);
  516.   TextDrawFont(SfondoInseguimentoRosso, 1);
  517.   TextDrawLetterSize(SfondoInseguimentoRosso, 0.460000, 1.600010);
  518.   TextDrawColor(SfondoInseguimentoRosso, 0);
  519.   TextDrawSetOutline(SfondoInseguimentoRosso, 0);
  520.   TextDrawSetProportional(SfondoInseguimentoRosso, 1);
  521.   TextDrawSetShadow(SfondoInseguimentoRosso, 1);
  522.   TextDrawUseBox(SfondoInseguimentoRosso, 1);
  523.   TextDrawBoxColor(SfondoInseguimentoRosso, -1776410956);
  524.   TextDrawTextSize(SfondoInseguimentoRosso, 243.000000, 0.000000);
  525.  
  526.   SfondoInseguimentoGiallo = TextDrawCreate(249.000000, 366.000000, "boxgiallo");
  527.   TextDrawBackgroundColor(SfondoInseguimentoGiallo, 0);
  528.   TextDrawFont(SfondoInseguimentoGiallo, 1);
  529.   TextDrawLetterSize(SfondoInseguimentoGiallo, 0.460000, 1.600010);
  530.   TextDrawColor(SfondoInseguimentoGiallo, 0);
  531.   TextDrawSetOutline(SfondoInseguimentoGiallo, 0);
  532.   TextDrawSetProportional(SfondoInseguimentoGiallo, 1);
  533.   TextDrawSetShadow(SfondoInseguimentoGiallo, 1);
  534.   TextDrawUseBox(SfondoInseguimentoGiallo, 1);
  535.   TextDrawBoxColor(SfondoInseguimentoGiallo, -1768546636);
  536.   TextDrawTextSize(SfondoInseguimentoGiallo, 319.000000, 0.000000);
  537.  
  538.   SfondoInseguimentoVerde = TextDrawCreate(325.000000, 366.000000, "boxverde");
  539.   TextDrawBackgroundColor(SfondoInseguimentoVerde, 0);
  540.   TextDrawFont(SfondoInseguimentoVerde, 1);
  541.   TextDrawLetterSize(SfondoInseguimentoVerde, 0.460000, 1.600010);
  542.   TextDrawColor(SfondoInseguimentoVerde, 0);
  543.   TextDrawSetOutline(SfondoInseguimentoVerde, 0);
  544.   TextDrawSetProportional(SfondoInseguimentoVerde, 1);
  545.   TextDrawSetShadow(SfondoInseguimentoVerde, 1);
  546.   TextDrawUseBox(SfondoInseguimentoVerde, 1);
  547.   TextDrawBoxColor(SfondoInseguimentoVerde, 513154740);
  548.   TextDrawTextSize(SfondoInseguimentoVerde, 394.000000, 0.000000);
  549.  
  550.   SfondoInseguimentoAzzurro = TextDrawCreate(400.000000, 366.000000, "boxazzurro");
  551.   TextDrawBackgroundColor(SfondoInseguimentoAzzurro, 0);
  552.   TextDrawFont(SfondoInseguimentoAzzurro, 1);
  553.   TextDrawLetterSize(SfondoInseguimentoAzzurro, 0.460000, 1.600010);
  554.   TextDrawColor(SfondoInseguimentoAzzurro, 0);
  555.   TextDrawSetOutline(SfondoInseguimentoAzzurro, 0);
  556.   TextDrawSetProportional(SfondoInseguimentoAzzurro, 1);
  557.   TextDrawSetShadow(SfondoInseguimentoAzzurro, 1);
  558.   TextDrawUseBox(SfondoInseguimentoAzzurro, 1);
  559.   TextDrawBoxColor(SfondoInseguimentoAzzurro, 513198260);
  560.   TextDrawTextSize(SfondoInseguimentoAzzurro, 463.000000, 0.000000);
  561.  
  562.   TextInseguimento = TextDrawCreate(274.000000, 339.000000, "Inseguimento");
  563.   TextDrawBackgroundColor(TextInseguimento, 255);
  564.   TextDrawFont(TextInseguimento, 0);
  565.   TextDrawLetterSize(TextInseguimento, 0.629999, 2.599999);
  566.   TextDrawColor(TextInseguimento, -1);
  567.   TextDrawSetOutline(TextInseguimento, 0);
  568.   TextDrawSetProportional(TextInseguimento, 1);
  569.   TextDrawSetShadow(TextInseguimento, 1);
  570.  
  571.   TextPessimo = TextDrawCreate(188.000000, 363.000000, "Pessimo");
  572.   TextDrawBackgroundColor(TextPessimo, 255);
  573.   TextDrawFont(TextPessimo, 1);
  574.   TextDrawLetterSize(TextPessimo, 0.339999, 2.000000);
  575.   TextDrawColor(TextPessimo, -1);
  576.   TextDrawSetOutline(TextPessimo, 0);
  577.   TextDrawSetProportional(TextPessimo, 1);
  578.   TextDrawSetShadow(TextPessimo, 1);
  579.  
  580.   TextMediocre = TextDrawCreate(258.000000, 363.000000, "Mediocre");
  581.   TextDrawBackgroundColor(TextMediocre, 255);
  582.   TextDrawFont(TextMediocre, 1);
  583.   TextDrawLetterSize(TextMediocre, 0.339999, 2.000000);
  584.   TextDrawColor(TextMediocre, -1);
  585.   TextDrawSetOutline(TextMediocre, 0);
  586.   TextDrawSetProportional(TextMediocre, 1);
  587.   TextDrawSetShadow(TextMediocre, 1);
  588.  
  589.   TextBuono = TextDrawCreate(344.000000, 363.000000, "Bene");
  590.   TextDrawBackgroundColor(TextBuono, 255);
  591.   TextDrawFont(TextBuono, 1);
  592.   TextDrawLetterSize(TextBuono, 0.339999, 2.000000);
  593.   TextDrawColor(TextBuono, -1);
  594.   TextDrawSetOutline(TextBuono, 0);
  595.   TextDrawSetProportional(TextBuono, 1);
  596.   TextDrawSetShadow(TextBuono, 1);
  597.  
  598.   TextOttimo = TextDrawCreate(411.000000, 363.000000, "Ottimo");
  599.   TextDrawBackgroundColor(TextOttimo, 255);
  600.   TextDrawFont(TextOttimo, 1);
  601.   TextDrawLetterSize(TextOttimo, 0.339999, 2.000000);
  602.   TextDrawColor(TextOttimo, -1);
  603.   TextDrawSetOutline(TextOttimo, 0);
  604.   TextDrawSetProportional(TextOttimo, 1);
  605.   TextDrawSetShadow(TextOttimo, 1);
  606.  
  607.   for(new i=0;i<MAX_PLAYERS;i++)
  608.   {
  609.     Giocatore[i][IdGara]=-1;
  610.  
  611.     TextPunti[i] = TextDrawCreate(288.000000, 386.000000, "Punti: 0000");
  612.     TextDrawBackgroundColor(TextPunti[i], 255);
  613.     TextDrawFont(TextPunti[i], 1);
  614.     TextDrawLetterSize(TextPunti[i], 0.339999, 2.000000);
  615.     TextDrawColor(TextPunti[i], -1);
  616.     TextDrawSetOutline(TextPunti[i], 0);
  617.     TextDrawSetProportional(TextPunti[i], 1);
  618.     TextDrawSetShadow(TextPunti[i], 1);
  619.  
  620.     TimerText[i] = TextDrawCreate(542.000000, 150.000000, "00:00");
  621.     TextDrawBackgroundColor(TimerText[i], 255);
  622.     TextDrawFont(TimerText[i], 2);
  623.     TextDrawLetterSize(TimerText[i], 0.610000, 4.099999);
  624.     TextDrawColor(TimerText[i], TURCHESE);
  625.     TextDrawSetOutline(TimerText[i], 0);
  626.     TextDrawSetProportional(TimerText[i], 1);
  627.     TextDrawSetShadow(TimerText[i], 1);
  628.    
  629.     TextGiriContatore[i] = TextDrawCreate(542.000000, 192.000000, "Giro: 1/3");
  630.     TextDrawBackgroundColor(TextGiriContatore[i], 255);
  631.     TextDrawFont(TextGiriContatore[i], 1);
  632.     TextDrawLetterSize(TextGiriContatore[i], 0.460000, 1.000000);
  633.     TextDrawColor(TextGiriContatore[i], -1);
  634.     TextDrawSetOutline(TextGiriContatore[i], 0);
  635.     TextDrawSetProportional(TextGiriContatore[i], 1);
  636.     TextDrawSetShadow(TextGiriContatore[i], 1);
  637.   }
  638.   return 1;
  639. }
  640. //============================================================ONFILTERSCRIPTEXIT
  641. public OnFilterScriptExit()
  642. {
  643.  SalvaGare();
  644.  return 1;
  645. }
  646. //===============================================================ONPLAYERCONNECT
  647. public OnPlayerConnect(playerid)
  648. {
  649.   return 1;
  650. }
  651. //============================================================ONPLAYERDISCONNECT
  652. public OnPlayerDisconnect(playerid, reason)
  653. {
  654.     if(Gara[Giocatore[playerid][IdGara]][Inseguimento] && Gara[Giocatore[playerid][IdGara]][Avviata]==1)
  655.     {
  656.     for(new i=0;i<MAX_PLAYERS;i++)
  657.      {
  658.      if(Giocatore[i][IdGara]==Giocatore[playerid][IdGara] && i!=playerid)
  659.       {
  660.       GetPlayerName(i,nome,sizeof(nome));
  661.       format(stringa,sizeof(stringa),"[GARA:] {8ECE46}%s{FFFFFF} vince la gara inseguimento per ritiro dell'avversario.",nome);
  662.       SendClientMessageToAll(BIANCO,stringa);
  663.       GivePlayerMoney(i,Gara[Giocatore[i][IdGara]][Costo]*2);
  664.       LasciaGara(i);
  665.       }
  666.      }
  667.     }
  668.     LasciaGara(playerid);
  669.     Giocatore[playerid][Costruttore]=0;
  670.     return 1;
  671. }
  672. public OnPlayerSpawn(playerid)
  673. {
  674.   return 1;
  675. }
  676. //===========================================================ONPLAYERCOMMANDTEXT
  677. public OnPlayerCommandText(playerid, cmdtext[])
  678. {
  679. //=====================================PROVVISORIO
  680.     if (strcmp(COMANDOTURBO, cmdtext, true, 10) == 0)
  681.             {
  682.                     ShowPlayerDialog(playerid,DIALOGTURBO,DIALOG_STYLE_INPUT,"Impostazioni turbo","{FFFFFF}Inserisci il {C14124}numero{FFFFFF} del moltiplicatore turbo.\nInserisci un numero nell'intervallo {C14124}1-4{FFFFFF}.","Setta","Esci");
  683.                     return 1;
  684.                     }
  685. //=====================================GARE
  686.     if(!strcmp(cmdtext,"/gare",true))
  687.     {
  688.     if(Giocatore[playerid][Costruttore]==1) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}Sei in modalità costruttore. Finisci prima di costruire la gara.");
  689.     format(stringa,sizeof(stringa),"");
  690.     for(new i=0;i<=GareCaricate; i++)
  691.      {
  692.      if(Gara[i][Giri]>1 && Gara[i][Inseguimento]==0)
  693.      format(stringa2,sizeof(stringa2),"{F58C5B}Circuito-{FFFFFF}%s (%d giri)",Gara[i][Nome],Gara[i][Giri]);
  694.      if(Gara[i][Giri]==1 && Gara[i][Inseguimento]==0)
  695.      format(stringa2,sizeof(stringa2),"{97EA68}Sprint-{FFFFFF}%s",Gara[i][Nome]);
  696.      if(Gara[i][Giri]>1 && Gara[i][Inseguimento]==1)
  697.      format(stringa2,sizeof(stringa2),"{C14124}Inseguimento-{FFFFFF}%s (%d giri)",Gara[i][Nome],Gara[i][Giri]);
  698.      if(Gara[i][Giri]==1 && Gara[i][Inseguimento]==1)
  699.      format(stringa2,sizeof(stringa2),"{C14124}Inseguimento-{FFFFFF}%s",Gara[i][Nome]);
  700.      strins(stringa,stringa2,strlen(stringa),sizeof(stringa));
  701.      if(i!=GareCaricate)
  702.      strins(stringa,"\n",strlen(stringa),sizeof(stringa));
  703.      }
  704.     ShowPlayerDialog(playerid,DIALOGGARE,DIALOG_STYLE_LIST,"Gare disponibili",stringa,"Entra","Esci");
  705.     return 1;
  706.     }
  707. //=====================================LASCIAGARA
  708.     if(!strcmp(cmdtext,"/lasciagara",true))
  709.     {
  710.     if(Giocatore[playerid][IdGara]==-1) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}Non stai partecipando a nessuna gara.");
  711.     if(Gara[Giocatore[playerid][IdGara]][Inseguimento] && Gara[Giocatore[playerid][IdGara]][Avviata]==1)
  712.     {
  713.     for(new i=0;i<MAX_PLAYERS;i++)
  714.      {
  715.      if(Giocatore[i][IdGara]==Giocatore[playerid][IdGara] && i!=playerid)
  716.       {
  717.       GetPlayerName(i,nome,sizeof(nome));
  718.       format(stringa,sizeof(stringa),"[GARA:] {8ECE46}%s{FFFFFF} vince la gara inseguimento per ritiro dell'avversario.",nome);
  719.       SendClientMessageToAll(BIANCO,stringa);
  720.       GivePlayerMoney(i,Gara[Giocatore[i][IdGara]][Costo]*2);
  721.       LasciaGara(i);
  722.       }
  723.      }
  724.     }
  725.     LasciaGara(playerid);
  726.     return 1;
  727.     }
  728. //=====================================PRONTO
  729.     if(!strcmp(cmdtext,"/pronto",true))
  730.     {
  731.     if (floatabs(VelX) < 0 && floatabs(VelY) < 0 && floatabs(VelZ) < 0)
  732.     if(Giocatore[playerid][IdGara]==-1) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}Non stai partecipando a nessuna gara.");
  733.     if(Giocatore[playerid][Pronto]==1) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF} Sei già pronto. Attendi gli altri giocatori.");
  734.     SendClientMessage(playerid,BIANCO,"[PRONTO:] Ora sei pronto. Attendi gli altri giocatori.");
  735.     Gara[Giocatore[playerid][IdGara]][PartecipantiPronti]++;
  736.     Giocatore[playerid][Pronto]=1;
  737.     if(Gara[Giocatore[playerid][IdGara]][Partecipanti]==Gara[Giocatore[playerid][IdGara]][PartecipantiPronti] && Gara[Giocatore[playerid][IdGara]][Inseguimento]==0)
  738.     AvviaGara(Giocatore[playerid][IdGara]);
  739.     if(Gara[Giocatore[playerid][IdGara]][PartecipantiPronti]==2 && Gara[Giocatore[playerid][IdGara]][Inseguimento]==1)
  740.     AvviaGara(Giocatore[playerid][IdGara]);
  741.     return 1;
  742.     }
  743. //=====================================COSTRUISCIGARA
  744.     if(!strcmp(cmdtext,"/costruttore",true))
  745.     {
  746.     if(!IsPlayerAdmin(playerid)) return 1;
  747.     if(Giocatore[playerid][IdGara]!=-1) return SendClientMessage(playerid,ROSSO,"[ERRORE:]{FFFFFF} Non puoi entrare in modalità costruttore mentre sei in gara.");
  748.     ShowPlayerDialog(playerid,DIALOGINFOCOSTRUTTORE,0,"Info modalità costruttore","{FFFFFF}Benvenuto nella modalità costruttore del {C14124}PRaceSystem{FFFFFF}.\nOra dovrai inserire alcune informazioni per la tua gara come segue:\n•Nome gara\n•Giri\n•Costo\n•Creazione lista checkpoint\n\nNota: Durante la modalità costruttore non potrai partecipare alle gare.","Procedi","");
  749.     GareEditor++;
  750.     Giocatore[playerid][GaraEditorId]=GareEditor;
  751.     Giocatore[playerid][Costruttore]=1;
  752.     format(stringa,sizeof(stringa),"Gare/Gara%d.txt",GareEditor);
  753.     new File:nomegara=fopen(stringa, io_write);
  754.     fwrite(nomegara,"Nome,1,50,1000,Nessuno");
  755.     fclose(nomegara);
  756.     return 1;
  757.     }
  758. //======================================CHECK
  759.     if (!strcmp("/check", cmdtext, true))
  760.     {
  761.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}Non sei loggato come admin RCON");
  762.     if(Giocatore[playerid][Costruttore]==0) return SendClientMessage(playerid,ROSSO,"[ERRORE:]{FFFFFF} Non sei in modalità costruttore.");
  763.     if(Giocatore[playerid][AttivaCheck]==0) return SendClientMessage(playerid,ROSSO,"[ERRORE:]{FFFFFF} Finisci prima di inserire le informazioni per la gara.");
  764.     SendClientMessage(playerid,VERDE,"[CHECKPOINT:] {FFFFFF}Checkpoint salvato.");
  765.     format(stringa,sizeof(stringa),"Gare/Check%d.txt",Giocatore[playerid][GaraEditorId]);
  766.     new File:nomegara=fopen(stringa, io_append);
  767.     new stringagara[150];
  768.     GetPlayerPos(playerid,XPosizione,YPosizione,ZPosizione);
  769.     format(stringagara,sizeof(stringagara),"%f,%f,%f|",XPosizione,YPosizione,ZPosizione);
  770.     SetPlayerCheckpoint(playerid,XPosizione,YPosizione,ZPosizione,9);
  771.     fwrite(nomegara,stringagara);
  772.     fclose(nomegara);
  773.     return 1;
  774.     }
  775. //====================================FINECHECK
  776.     if(!strcmp("/finecheck", cmdtext, true))
  777.     {
  778.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}Non sei loggato come admin RCON");
  779.     if(Giocatore[playerid][Costruttore]==0) return SendClientMessage(playerid,ROSSO,"[ERRORE:]{FFFFFF} Non sei in modalità costruttore.");
  780.     if(Giocatore[playerid][AttivaCheck]==0) return SendClientMessage(playerid,ROSSO,"[ERRORE:]{FFFFFF} Finisci prima di inserire le informazioni per la gara.");
  781.     Giocatore[playerid][Costruttore]=0;
  782.     Giocatore[playerid][AttivaCheck]=0;
  783.     SendClientMessage(playerid,BIANCO,"[EDITOR:] Hai completato la gara.");
  784.     DisablePlayerCheckpoint(playerid);
  785.     SalvaGare();
  786.     for(new i=0;i<MAX_PLAYERS;i++)
  787.     LasciaGara(i);
  788.     SendClientMessageToAll(BIANCO,"[ANNUNCIO:] L'amministratore ha terminato una gara. Affinchè la nuova gara possa essere caricata, sono state chiuse forzatamente le gare in corso.");
  789.     CaricaGare();
  790.     return 1;
  791.     }
  792.     return 0;
  793. }
  794.     public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  795.     {
  796.     //===================================KEY NUM8
  797.             if(PREMUTO(TASTOTURBO))
  798.             {
  799.             if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
  800.               {
  801.               GetVehicleVelocity(GetPlayerVehicleID(playerid),VelX,VelY,VelZ);
  802.               if (floatabs(VelX) < 3 && floatabs(VelY) < 3 && floatabs(VelZ) < 3)
  803.               SetVehicleVelocity(GetPlayerVehicleID(playerid),VelX*Turbo[playerid],VelY*Turbo[playerid],VelZ*Turbo[playerid]);
  804.               }
  805.             return 1;
  806.             }
  807.  
  808.     //===================================KEY CLACSON
  809.             if(PREMUTO(TASTOSALTO))
  810.             {
  811.             if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
  812.               {
  813.               GetVehicleVelocity(GetPlayerVehicleID(playerid),VelX,VelY,VelZ);
  814.               SetVehicleVelocity(GetPlayerVehicleID(playerid),VelX,VelY,VelZ+0.28);
  815.               }
  816.             return 1;
  817.             }
  818.     //===================================KEY 2
  819.             if(PREMUTO(TASTORIPARAZIONE))
  820.             {
  821.             if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER && RIPARAZIONEATTIVATA==1)
  822.         RepairVehicle(GetPlayerVehicleID(playerid));
  823.         return 1;
  824.             }
  825.             return 1;
  826.     }
  827. //===================================================ONPLAYERENTERRACECHECKPOINT
  828. public OnPlayerEnterRaceCheckpoint(playerid)
  829. {
  830.  if(Giocatore[playerid][IdGara]==-1) return 1;
  831.  new g=Giocatore[playerid][IdGara];
  832.  new c=Giocatore[playerid][Checkpoint];
  833.  if(Gara[Giocatore[playerid][IdGara]][Avviata]==0) return 1;
  834.  SuonoGiocatore(playerid,1138);
  835.  //==============SECHECKPOINT==ULTIMO
  836.  if(Giocatore[playerid][Checkpoint]==Gara[Giocatore[playerid][IdGara]][NumeroCheckpoint])
  837.   {
  838.   //===========SEGIRO=ULTIMO
  839.   if(Giocatore[playerid][Giro]==Gara[Giocatore[playerid][IdGara]][Giri])
  840.     {
  841.     GetPlayerName(playerid,nome,sizeof(nome));
  842.     Gara[Giocatore[playerid][IdGara]][Podio]++;
  843.     if(Giocatore[playerid][Tempo]<Gara[Giocatore[playerid][IdGara]][Record])
  844.     {
  845.     new Minuti=floatround(Giocatore[playerid][Tempo]/60);
  846.     new Secondi=Giocatore[playerid][Tempo]-(Minuti*60);
  847.     format(stringa,sizeof(stringa),"[RECORD:] Player:{8ECE46}%s{FFFFFF} Pista: {446ED1}%s{FFFFFF} Tempo: {C14124}%02d:%02d",nome,Gara[Giocatore[playerid][IdGara]][Nome],Minuti,Secondi);
  848.     SendClientMessageToAll(BIANCO,stringa);
  849.     Gara[Giocatore[playerid][IdGara]][Record]=Giocatore[playerid][Tempo];
  850.     format(Gara[Giocatore[playerid][IdGara]][GiocatoreRecord],25,nome);
  851.     }
  852.     if(!Gara[Giocatore[playerid][IdGara]][Inseguimento])
  853.     {
  854.     format(stringa,sizeof(stringa),"[GARA:] {8ECE46}%s{FFFFFF} termina la gara. Posizione: {C14124}%d",nome,Gara[Giocatore[playerid][IdGara]][Podio]);
  855.     GivePlayerMoney(playerid,floatround(Gara[Giocatore[playerid][IdGara]][Costo]*Gara[Giocatore[playerid][IdGara]][PartecipantiPronti]/Gara[Giocatore[playerid][IdGara]][Podio]));
  856.     SendClientMessageToAll(BIANCO,stringa);
  857.     }
  858.     if(Gara[Giocatore[playerid][IdGara]][Inseguimento])
  859.     {
  860.     for(new i=0;i<MAX_PLAYERS;i++)
  861.      {
  862.      if(Giocatore[i][IdGara]==Giocatore[playerid][IdGara] && i!=playerid)
  863.       {
  864.       if(Giocatore[playerid][Punti]>=Giocatore[i][Punti])
  865.         {
  866.         GetPlayerName(playerid,nome,sizeof(nome));
  867.         format(stringa,sizeof(stringa),"[GARA:] {8ECE46}%s{FFFFFF} vince la gara inseguimento con {C14124}%d{FFFFFF} punti.",nome,Giocatore[playerid][Punti]);
  868.         SendClientMessageToAll(BIANCO,stringa);
  869.         GivePlayerMoney(playerid,Gara[Giocatore[playerid][IdGara]][Costo]*2);
  870.         }
  871.       if(Giocatore[playerid][Punti]<Giocatore[i][Punti])
  872.         {
  873.         GetPlayerName(i,nome,sizeof(nome));
  874.         format(stringa,sizeof(stringa),"[GARA:] {8ECE46}%s{FFFFFF} vince la gara inseguimento con {C14124}%d{FFFFFF} punti.",nome,Giocatore[i][Punti]);
  875.         SendClientMessageToAll(BIANCO,stringa);
  876.         GivePlayerMoney(i,Gara[Giocatore[playerid][IdGara]][Costo]*2);
  877.         }
  878.       LasciaGara(i);
  879.       }
  880.      }
  881.     }
  882.     DisablePlayerRaceCheckpoint(playerid);
  883.     LasciaGara(playerid);
  884.     return 1;
  885.     }
  886.   //========SEGIRO!=ULTIMO
  887.   else
  888.     {
  889.     Giocatore[playerid][Giro]++;
  890.     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);
  891.     Giocatore[playerid][Checkpoint]=0;
  892.     format(stringa,sizeof(stringa),"Giro: %d/%d",Giocatore[playerid][Giro],Gara[Giocatore[playerid][IdGara]][Giri]);
  893.     TextDrawSetString(TextGiriContatore[playerid],stringa);
  894.     return 1;
  895.     }
  896.   }
  897.   //=========SECHECKPOINTNORMALE
  898.  if(Giocatore[playerid][Checkpoint]<Gara[Giocatore[playerid][IdGara]][NumeroCheckpoint]-1)
  899.   {
  900.   Giocatore[playerid][Checkpoint]++;
  901.   c=Giocatore[playerid][Checkpoint];
  902.   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);
  903.   return 1;
  904.   }
  905.  //=========SECHECKPOINTFINALE
  906.  else if(Giocatore[playerid][Checkpoint]==Gara[Giocatore[playerid][IdGara]][NumeroCheckpoint]-1)
  907.   {
  908.   Giocatore[playerid][Checkpoint]++;
  909.   c=Giocatore[playerid][Checkpoint];
  910.   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);
  911.   return 1;
  912.   }
  913.  return 1;
  914. }
  915. //===================================================ONPLAYERLEAVERACECHECKPOINT
  916. public OnPlayerLeaveRaceCheckpoint(playerid)
  917. {
  918.     OnPlayerEnterRaceCheckpoint(playerid);
  919.     return 1;
  920. }
  921. //==============================================================ONDIALOGRESPONSE
  922. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  923. {
  924.     if(dialogid==DIALOGINFOGARA2)
  925.       {
  926.       Giocatore[playerid][AttivaCheck]=1;
  927.       return 1;
  928.       }
  929.     if(dialogid==DIALOGINSEGUIMENTO)
  930.       {
  931.       if(strcmp(inputtext,"Si",true) && strcmp(inputtext,"No",true)) return ShowPlayerDialog(playerid,DIALOGINSEGUIMENTO,DIALOG_STYLE_INPUT,"Opzione inseguimento","{FFFFFF}ERRORE\nScrivi Si o No.\nVuoi che la gara venga salvata in modalità inseguimento?\n(Scrivi Si o No)","Vai","");
  932.       format(stringa,sizeof(stringa),"Gare/Gara%d.txt",Giocatore[playerid][GaraEditorId]);
  933.       new File:nomegara=fopen(stringa, io_append);
  934.       if(!strcmp(inputtext,"Si",true))
  935.       fwrite(nomegara,",1");
  936.       if(!strcmp(inputtext,"No",true))
  937.       fwrite(nomegara,",0");
  938.       fclose(nomegara);
  939.       ShowPlayerDialog(playerid,DIALOGINFOGARA2,0,"Informazioni","{FFFFFF}Complimenti ora hai creato il file Gara.\nAdesso devi creare il file Check.\nUtilizza il comando \"{C14124}/check{FFFFFF}\" per creare i checkpoint per la tua gara.\nQuando termini digita \"{C14124}/finecheck{FFFFFF}\" per uscire dalla modalità costruttore","Vai","");
  940.       return 1;
  941.       }
  942.     if(dialogid==DIALOGCOSTOGARA)
  943.       {
  944.       if(!strlen(inputtext) || !isNumeric(inputtext) || strval(inputtext)<=0) return ShowPlayerDialog(playerid,DIALOGCOSTOGARA,DIALOG_STYLE_INPUT,"Costo gara","{FFFFFF}ERRORE:\nInserisci il costo per partecipare alla tua gara:","Continua","");
  945.       format(stringa,sizeof(stringa),"Gare/Gara%d.txt",Giocatore[playerid][GaraEditorId]);
  946.       new File:nomegara=fopen(stringa, io_append);
  947.       GetPlayerName(playerid,nome,sizeof(nome));
  948.       format(stringa,sizeof(stringa),"%d,1000,Nessuno,%s",strval(inputtext),nome);
  949.       fwrite(nomegara,stringa);
  950.       fclose(nomegara);
  951.       ShowPlayerDialog(playerid,DIALOGINSEGUIMENTO,DIALOG_STYLE_INPUT,"Opzione inseguimento","{FFFFFF}Vuoi che la gara venga salvata in modalità inseguimento?\n(Scrivi Si o No)","Continua","");
  952.       return 1;
  953.       }
  954.     if(dialogid==DIALOGGIRIGARA)
  955.       {
  956.       if(!strlen(inputtext) || !isNumeric(inputtext) || strval(inputtext)<=0) return ShowPlayerDialog(playerid,DIALOGGIRIGARA,DIALOG_STYLE_INPUT,"Giri gara","{FFFFFF}ERRORE:\nInserisci il numero di giri per la tua gara:","Continua","");
  957.       format(stringa,sizeof(stringa),"Gare/Gara%d.txt",Giocatore[playerid][GaraEditorId]);
  958.       new File:nomegara=fopen(stringa, io_append);
  959.       format(stringa,sizeof(stringa),"%d,",strval(inputtext));
  960.       fwrite(nomegara,stringa);
  961.       fclose(nomegara);
  962.       ShowPlayerDialog(playerid,DIALOGCOSTOGARA,DIALOG_STYLE_INPUT,"Costo gara","{FFFFFF}Inserisci il costo per partecipare alla tua gara:","Continua","");
  963.       return 1;
  964.       }
  965.     if(dialogid==DIALOGNOMEGARA)
  966.       {
  967.       if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOGNOMEGARA,DIALOG_STYLE_INPUT,"Nome gara","{FFFFFF}ERRORE:\nInserisci il nome per la tua gara:","Continua","");
  968.       format(stringa,sizeof(stringa),"Gare/Gara%d.txt",Giocatore[playerid][GaraEditorId]);
  969.       new File:nomegara=fopen(stringa, io_write);
  970.       format(stringa,sizeof(stringa),"%s,",inputtext);
  971.       fwrite(nomegara,stringa);
  972.       fclose(nomegara);
  973.       ShowPlayerDialog(playerid,DIALOGGIRIGARA,DIALOG_STYLE_INPUT,"Giri gara","{FFFFFF}Inserisci il numero di giri per la tua gara:","Continua","");
  974.       return 1;
  975.       }
  976.     if(dialogid==DIALOGINFOCOSTRUTTORE)
  977.       {
  978.       ShowPlayerDialog(playerid,DIALOGNOMEGARA,DIALOG_STYLE_INPUT,"Nome gara","{FFFFFF}Inserisci il nome per la tua gara:","Continua","");
  979.       return 1;
  980.       }
  981.     if(dialogid==DIALOGINFO) return 1;
  982.     if(dialogid==DIALOGGARE && response)
  983.     {
  984.     if(Giocatore[playerid][IdGara]!=-1) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}Stai già partecipando ad un'altra gara.");
  985.     if(Gara[listitem][Avviata]==1) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}Questa gara è attualmente in corso. Attendi che finisca prima di parteciparvi.");
  986.     if(Gara[listitem][Inseguimento]==1)
  987.     {
  988.     if(Gara[listitem][Partecipanti]==2) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}Attualmente sono già presenti due partecipanti (limite per gare a inseguimento)");
  989.     if(Gara[listitem][Partecipanti]==0)
  990.      {
  991.      SendClientMessage(playerid,BIANCO,"[GARA:] Sei quello che fugge. A inizio gara posizionati davanti all'avversario e cerca di seminarlo.");
  992.      }
  993.     if(Gara[listitem][Partecipanti]==1)
  994.      {
  995.      SendClientMessage(playerid,BIANCO,"[GARA:] Sei l'inseguitore. A inizio gara posizionati dietro l'avversario e cerca di stargli dietro.");
  996.      Giocatore[playerid][Inseguitore]=1;
  997.      }
  998.     }
  999.     Giocatore[playerid][IdGara]=listitem;
  1000.     GetPlayerName(playerid,nome,sizeof(nome));
  1001.     format(stringa,sizeof(stringa),"{8CE46C}%s {FFFFFF}entra in gara.",nome);
  1002.     GivePlayerMoney(playerid,-Gara[listitem][Costo]);
  1003.     MandaMessaggioPartecipanti(listitem,stringa);
  1004.     #if defined TELETRASPORTO_INIZIAGARA
  1005.     SetPlayerPos(playerid,CheckpointGara[listitem][0][CXPos],CheckpointGara[listitem][0][CYPos],CheckpointGara[listitem][0][CZPos]);
  1006.     SendClientMessage(playerid,BIANCO,"[GARA:] Ora stai partecipando alla gara. Digita \"{C14124}/Pronto{FFFFFF}\" quando sei pronto.");
  1007.     #else
  1008.     SendClientMessage(playerid,BIANCO,"[GARA:] Ora stai partecipando alla gara. Vai al checkpoint e digita \"{C14124}/Pronto{FFFFFF}\" quando sei pronto");
  1009.     #endif
  1010.     Gara[listitem][Partecipanti]++;
  1011.     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);
  1012.     new minuti=floatround(Gara[listitem][Record]/60);
  1013.     new secondi=Gara[listitem][Record]-(minuti*60);
  1014.     format(stringa,sizeof(stringa),"{FFFFFF}Nome: {8CE46C}%s\n{FFFFFF}Giri: {8CE46C}%d\n{FFFFFF}Costo: {8CE46C}%d$\n{FFFFFF}Record: {8CE46C}%02d:%02d\n{FFFFFF}Giocatore Record: {8CE46C}%s\n{FFFFFF}Produttore gara: {8CE46C}%s",Gara[listitem][Nome],Gara[listitem][Giri],Gara[listitem][Costo],minuti,secondi,Gara[listitem][GiocatoreRecord],Gara[listitem][Produttore]);
  1015.     ShowPlayerDialog(playerid,DIALOGINFO,0,"Info Gara",stringa,"Esci","");
  1016.     return 1;
  1017.     }
  1018.             if(dialogid == DIALOGTURBO)
  1019.             {
  1020.             if(!isNumeric(inputtext)) return ShowPlayerDialog(playerid,DIALOGTURBO,DIALOG_STYLE_INPUT,"Impostazioni turbo","{C14124}ERRORE: Inserire un valore numerico.\n{FFFFFF}Inserisci il {C14124}numero{FFFFFF} del moltiplicatore turbo.\nInserisci un numero nell'intervallo {C14124}1-4{FFFFFF}.","Setta","Esci");
  1021.             if(strval(inputtext)<1 || strval(inputtext)>4) return ShowPlayerDialog(playerid,DIALOGTURBO,DIALOG_STYLE_INPUT,"Impostazioni turbo","{C14124}ERRORE: Inserire un valore numerico nell'intervallo 1-4.\n{FFFFFF}Inserisci il {C14124}numero{FFFFFF} del moltiplicatore turbo.\nInserisci un numero nell'intervallo {C14124}1-4{FFFFFF}.","Setta","Esci");
  1022.             format(stringa,sizeof(stringa),"TURBO: {FFFFFF}Hai impostato il moltiplicatore turbo a {8CE46C}%d{FFFFFF}.",strval(inputtext));
  1023.             SendClientMessage(playerid,0x338CD9FF,stringa);
  1024.             Turbo[playerid]=strval(inputtext);
  1025.             return 1;
  1026.             }
  1027.             return 1;
  1028.     }
  1029. //====================================================MANDAMESSAGGIOPARTECIPANTI
  1030. stock MandaMessaggioPartecipanti(idGara,Messaggio[])
  1031. {
  1032.  for(new i=0;i<MAX_PLAYERS;i++)
  1033.  {
  1034.  if(Giocatore[i][IdGara]==idGara)
  1035.  SendClientMessage(i,BIANCO,Messaggio);
  1036.  }
  1037. }
  1038. //================================================================SUONOGIOCATORE
  1039. stock SuonoGiocatore(playerid,idsuono)
  1040. {
  1041.  new Float:SPosX,Float:SPosY,Float:SPosZ;
  1042.  GetPlayerPos(playerid,SPosX,SPosY,SPosZ);
  1043.  PlayerPlaySound(playerid,idsuono,SPosX,SPosY,SPosZ);
  1044.  return 1;
  1045. }
  1046. //=========================================================================SPLIT
  1047. stock split(const strsrc[], strdest[][], delimiter)
  1048. {
  1049.     new i, li,aNum,len;
  1050.     while(i <= strlen(strsrc))
  1051.     {
  1052.         if(strsrc[i]==delimiter || i==strlen(strsrc))
  1053.         {
  1054.             len = strmid(strdest[aNum], strsrc, li, i, 128);
  1055.             strdest[aNum][len] = 0;
  1056.             li = i+1;
  1057.             aNum++;
  1058.         }
  1059.         i++;
  1060.     }
  1061.     return 1;
  1062. }
  1063. //=====================================================================ISNUMERIC
  1064. stock isNumeric(const string[]) {
  1065.     new length=strlen(string);
  1066.     if (length==0) return false;
  1067.     for (new i = 0; i < length; i++) {
  1068.         if (
  1069.         (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+')
  1070.         || (string[i]=='-' && i!=0)                                            
  1071.         || (string[i]=='+' && i!=0)                                            
  1072.         ) return false;
  1073.     }
  1074.     if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
  1075.     return true;
  1076. }
  1077.     stock isNumeric2(const string[])
  1078.     {
  1079.             new length=strlen(string);
  1080.             if (length==0) return false;
  1081.             for (new i = 0; i < length; i++)
  1082.             {
  1083.             if
  1084.             ((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') || (string[i]=='-' && i!=0)|| (string[i]=='+' && i!=0))
  1085.         return false;
  1086.             }
  1087.             if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
  1088.             return true;
  1089.     }
Advertisement
Add Comment
Please, Sign In to add comment