Advertisement
Phanto90

PRaceSystem v1.3

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