Advertisement
Guest User

Aurimas

a guest
Feb 2nd, 2009
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 30.84 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3.  
  4. #define Min_Reward 10000
  5. #define Reward_Per_Health_Percent 100
  6. #define Reward_Discount_Per_Second 10
  7. #define MAX_MINUTES 6
  8.  
  9. new Float:RC[54][3] =
  10. {
  11.     {-2286.6353,-1700.7102,478.4358},
  12.     {-2288.1792,-1763.1018,454.9219},
  13.     {-2353.0198,-1816.9895,432.5812},
  14.     {-2447.4729,-1719.8342,431.6024},
  15.     {-2440.2600,-1809.7311,410.2217},
  16.     {-2522.0500,-1703.0638,402.0119},
  17.     {-2523.8193,-1610.5060,398.2629},
  18.     {-2477.2080,-1476.4357,390.5564},
  19.     {-2320.7549,-1455.6995,381.5133},
  20.     {-2256.2595,-1485.9067,378.5980},
  21.     {-2211.9927,-1620.1307,379.3380},
  22.     {-2212.8423,-1716.5380,376.4465},
  23.     {-2189.1406,-1710.7034,376.0816},
  24.     {-2197.8906,-1552.8011,361.3695},
  25.     {-2274.8806,-1430.9657,355.8955},
  26.     {-2358.8079,-1402.7571,359.7164},
  27.     {-2468.7893,-1429.2543,362.4955},
  28.     {-2551.0388,-1503.3468,358.7271},
  29.     {-2575.8269,-1500.5520,358.7248},
  30.     {-2572.9800,-1462.5763,358.3174},
  31.     {-2398.5942,-1343.1970,333.0944},
  32.     {-2337.2688,-1314.2493,309.5719},
  33.     {-2345.1946,-1285.9027,308.5854},
  34.     {-2387.1357,-1283.1084,300.8869},
  35.     {-2464.4963,-1273.0569,282.9333},
  36.     {-2524.6392,-1289.1597,270.6183},
  37.     {-2574.8892,-1359.1495,265.4158},
  38.     {-2613.3279,-1361.4434,263.3748},
  39.     {-2670.3860,-1396.1407,254.2419},
  40.     {-2637.0603,-1303.4363,232.6432},
  41.     {-2614.2776,-1226.5154,208.2767},
  42.     {-2587.7229,-1170.2632,190.0163},
  43.     {-2511.2334,-1124.0493,177.0565},
  44.     {-2540.7468,-1122.5959,175.6718},
  45.     {-2610.8096,-1155.4227,170.6376},
  46.     {-2713.4504,-1271.4304,154.7756},
  47.     {-2737.7273,-1342.7054,147.0784},
  48.     {-2755.1047,-1431.3491,140.1418},
  49.     {-2780.7881,-1743.0575,141.4138},
  50.     {-2759.0439,-1860.2391,141.5795},
  51.     {-2683.6941,-1878.9551,136.3070},
  52.     {-2653.3979,-1955.6143,127.2152},
  53.     {-2608.4011,-2084.2664,131.8737},
  54.     {-2565.3149,-2071.6523,130.3119},
  55.     {-2436.0454,-2087.6812,123.7501},
  56.     {-2343.6467,-2102.0376,112.9725},
  57.     {-2217.1072,-2046.2115,119.5078},
  58.     {-2161.1846,-1985.0746,118.3621},
  59.     {-2104.4814,-1882.6589,110.2269},
  60.     {-2108.4790,-1919.6836,103.1151},
  61.     {-2141.9709,-2005.1815,95.0584},
  62.     {-2200.7427,-2082.0625,79.5675},
  63.     {-2276.6218,-2150.2297,52.0756},
  64.     {-2391.8550,-2203.0520,32.9933}
  65. };
  66.  
  67. new bool:RaceStarted;
  68. new CurrentRacer = -1;
  69. new Float:LastPos[4], LastInterior;
  70. new Racecar;
  71. new CC;
  72. new StartTickcount;
  73. new CountdownTimer;
  74. new Count;
  75. new highscoretimes[11];
  76. new tmphighscoretimes[11];
  77. new highscorenames[11][MAX_PLAYER_NAME];
  78. new tmphighscorenames[11][MAX_PLAYER_NAME];
  79. new Text:HighScoreTable[4];
  80. new HighScoreTableString[4][128];
  81. new IsViewingHighScoreTable[MAX_PLAYERS];
  82. new Text:InfoBox;
  83. new InfoBoxString[128];
  84. new InfoTimer;
  85. new Died;
  86. new ExitVehicleTimer;
  87. new TimeOutOfVehicle;
  88. new CameraTimer, Float:CamCount;
  89. new max_minutes = MAX_MINUTES;
  90.  
  91. public OnFilterScriptInit()
  92. {
  93.     new tmp[3];
  94.     for(new i=1; i<11; i++)
  95.     {
  96.         format(tmp, 5, "T%d", i);
  97.         highscoretimes[i] = dini_Int("MCR-Highscores.txt", tmp);
  98.     }
  99.     for(new i=1; i<11; i++)
  100.     {
  101.         format(tmp, 5, "N%d", i);
  102.         format(highscorenames[i], MAX_PLAYER_NAME, "%s", dini_Get("MCR-Highscores.txt", tmp));
  103.     }
  104.     InfoBox = TextDrawCreate(200.0, 350.0, " ");
  105.     TextDrawUseBox(InfoBox,1);
  106.     TextDrawTextSize(InfoBox, 440, 410);
  107.     TextDrawBoxColor(InfoBox,0x00000066);
  108.     TextDrawSetOutline(InfoBox,1);
  109.     TextDrawLetterSize(InfoBox,0.5,1.2);
  110.     TextDrawSetShadow(InfoBox,0);
  111.     HighScoreTable[0] = TextDrawCreate(150.0,114.3," ");
  112.     HighScoreTable[1] = TextDrawCreate(150.0,161.0," ");
  113.     HighScoreTable[2] = TextDrawCreate(150.0,197.0," ");
  114.     HighScoreTable[3] = TextDrawCreate(150.0,233.0," ");
  115.     for(new i; i<4; i++)
  116.     {
  117.         TextDrawUseBox(HighScoreTable[i],1);
  118.         TextDrawTextSize(HighScoreTable[i], 550, 410);
  119.         TextDrawBoxColor(HighScoreTable[i],0x00000066);
  120.         TextDrawSetOutline(HighScoreTable[i],1);
  121.         TextDrawLetterSize(HighScoreTable[i],0.5,1.2);
  122.         TextDrawSetShadow(HighScoreTable[i],0);
  123.     }
  124.    
  125.  
  126.     return 1;
  127. }
  128.  
  129. public OnFilterScriptExit()
  130. {
  131.     DisablePlayerRaceCheckpoint(CurrentRacer);
  132.     RemovePlayerFromVehicle(CurrentRacer);
  133.     DestroyVehicle(Racecar);
  134.     DestroyHighScoreTable();
  135.     TextDrawHideForAll(InfoBox);
  136.     TextDrawDestroy(InfoBox);
  137.    
  138.     return 1;
  139. }
  140.  
  141. public OnPlayerConnect(playerid)
  142. {
  143.  
  144.     IsViewingHighScoreTable[playerid] = 0;
  145.     return 1;
  146. }
  147.  
  148. public OnPlayerDisconnect(playerid, reason)
  149. {
  150.     if(playerid == CurrentRacer)
  151.     {
  152.         KillTimer(ExitVehicleTimer);
  153.         FailedRace();
  154.  
  155.     }
  156.     return 1;
  157. }
  158.  
  159. public OnPlayerDeath(playerid, killerid, reason)
  160. {
  161.     if(playerid == CurrentRacer)
  162.     {
  163.         Died = 1;
  164.         KillTimer(ExitVehicleTimer);
  165.         FailedRace();
  166.        
  167.     }
  168.     return 1;
  169. }
  170.  
  171. public OnVehicleDeath(vehicleid, killerid)
  172. {
  173.     if(vehicleid == Racecar)
  174.     {
  175.         KillTimer(ExitVehicleTimer);
  176.         FailedRace();
  177.        
  178.     }
  179.     return 1;
  180. }
  181.  
  182. public OnPlayerCommandText(playerid, cmdtext[])
  183. {
  184.     if (strcmp("/mcrace", cmdtext, true) == 0)
  185.     {
  186.         if(RaceStarted == true)
  187.         {
  188.             new rName[MAX_PLAYER_NAME], str[128];
  189.             GetPlayerName(CurrentRacer, rName, sizeof(rName));
  190.             format(str, 128, "Atsiprasome, %s [ID %d] jau esa lenktynesia! palaukite kol ji/jis'pabaigs lenktynes!", rName, CurrentRacer);
  191.             SendClientMessage(playerid, 0xFF0000AA, str);
  192.             return 1;
  193.         }
  194.         RaceStarted = true;
  195.         CurrentRacer = playerid;
  196.         GetPlayerPos(playerid, LastPos[0], LastPos[1], LastPos[2]);
  197.         GetPlayerFacingAngle(playerid, LastPos[3]);
  198.         LastInterior = GetPlayerInterior(playerid);
  199.         Racecar = CreateVehicle(560, -2299.7456,-1673.9592,483.3256,206.6098, 0, 0, -1);
  200.         AddVehicleComponent(Racecar,1026);
  201.         AddVehicleComponent(Racecar,1027);
  202.         AddVehicleComponent(Racecar,1028);
  203.         AddVehicleComponent(Racecar,1032);
  204.         AddVehicleComponent(Racecar,1138);
  205.         AddVehicleComponent(Racecar,1141);
  206.         AddVehicleComponent(Racecar,1169);
  207.         AddVehicleComponent(Racecar,1074);
  208.         AddVehicleComponent(Racecar,1009); // 2x Nitro
  209.         SetPlayerInterior(playerid, 0);
  210.         PutPlayerInVehicle(playerid, Racecar, 0);
  211.         CC = 0;
  212.         SetPlayerRaceCheckpoint(playerid, 0, RC[CC][0], RC[CC][1], RC[CC][2], RC[CC+1][0], RC[CC+1][1], RC[CC+1][2], 3);
  213.         SetPlayerCameraPos(playerid, -2308.3823,-1705.7048,490.4961);
  214.         SetPlayerCameraLookAt(playerid, -2295.3433,-1722,475.4256);
  215.         CameraTimer = SetTimer("MoveCamera", 25, 1);
  216.         CamCount = 1722.0;
  217.        
  218.         TogglePlayerControllable(playerid, 0);
  219.         CountdownTimer = SetTimerEx("Countdown", 1000, 1, "i", playerid);
  220.         Count = 5;
  221.         GameTextForPlayer(playerid, "~r~Pasiruosti! ~n~~n~~b~5", 1500, 3);
  222.         return 1;
  223.     }
  224.    
  225.     if (strcmp("/showhighscore", cmdtext, true) == 0)
  226.     {
  227.         if(IsViewingHighScoreTable[playerid] == 0)
  228.         {
  229.             SendClientMessage(playerid, 0x00FF00AA, "Yrasykite /hidehighscore paziureti rezultatu lentele");
  230.             ShowHighScoreTable(playerid, 999);
  231.         }
  232.         return 1;
  233.     }
  234.     if (strcmp("/hidehighscore", cmdtext, true) == 0)
  235.     {
  236.         if(IsViewingHighScoreTable[playerid] == 1)
  237.         {
  238.             HideHighScoreTable(playerid);
  239.         }
  240.         return 1;
  241.     }
  242.     if (strcmp("/exitrace", cmdtext, true) == 0)
  243.     {
  244.         if(playerid == CurrentRacer)
  245.         {
  246.             FailedRace();
  247.         }
  248.         return 1;
  249.     }
  250.     return 0;
  251. }
  252.  
  253. public OnPlayerStateChange(playerid, newstate, oldstate)
  254. {
  255.     if(playerid == CurrentRacer)
  256.     {
  257.         if(oldstate == PLAYER_STATE_DRIVER)
  258.         {
  259.             GameTextForPlayer(playerid, "~r~Tu turi ~y~10 ~r~sekundziu ~n~kad sugryzrum~n~y savo masina!!", 1500, 3);
  260.             TimeOutOfVehicle = 10;
  261.             ExitVehicleTimer = SetTimer("OutOfVehicle", 1000, 1);
  262.         }
  263.         if(newstate == PLAYER_STATE_DRIVER)
  264.         {
  265.             GameTextForPlayer(playerid, " ", 10, 3);
  266.             KillTimer(ExitVehicleTimer);
  267.         }
  268.     }
  269. }
  270.  
  271. forward OutOfVehicle();
  272. public OutOfVehicle()
  273. {
  274.     TimeOutOfVehicle--;
  275.     new str[128];
  276.     format(str, 128, "~r~Tu turi ~y~10 ~r~sekundziu ~n~kad sugryzrum~n~y savo masina!!", TimeOutOfVehicle);
  277.     GameTextForPlayer(CurrentRacer, str, 1500, 3);
  278.     if(TimeOutOfVehicle == 0)
  279.     {
  280.         FailedRace();
  281.         KillTimer(ExitVehicleTimer);
  282.     }
  283. }
  284.  
  285. public OnPlayerEnterRaceCheckpoint(playerid)
  286. {
  287.     if(CC < 52) //Show Normal Checkpoints
  288.     {
  289.         CC++;
  290.         SetPlayerRaceCheckpoint(playerid, 0, RC[CC][0], RC[CC][1], RC[CC][2], RC[CC+1][0], RC[CC+1][1], RC[CC+1][2], 3);
  291.     }
  292.     else if(CC == 52) //Show Finish Checkpoint
  293.     {
  294.         CC++;
  295.         SetPlayerRaceCheckpoint(playerid, 1, RC[CC][0], RC[CC][1], RC[CC][2], RC[CC][0], RC[CC][1], RC[CC][2], 4);
  296.     }
  297.     else if(CC == 53) //Player Is In Last Checkpoint!
  298.     {
  299.         DisablePlayerRaceCheckpoint(playerid);
  300.         WinnerRace(playerid);
  301.         GameTextForPlayer(CurrentRacer, "~n~~n~~n~~n~~n~~y~Laimetojas!!", 3500, 3);
  302.     }
  303.     return 1;
  304. }
  305.  
  306. public OnPlayerLeaveRaceCheckpoint(playerid)
  307. {
  308.     return 1;
  309. }
  310.  
  311. forward Countdown(playerid);
  312. public Countdown(playerid)
  313. {
  314.     if(Count > 1)
  315.     {
  316.         Count--;
  317.         new str[30];
  318.         format(str, sizeof(str), "~r~Pasiruosti! ~n~~n~~b~%d", Count);
  319.         GameTextForPlayer(playerid, str, 3000, 3);
  320.     }
  321.     else
  322.     {
  323.         KillTimer(CountdownTimer);
  324.         GameTextForPlayer(playerid, "~r~Pradekite Lengtynes!", 1500, 3);
  325.         StartTickcount = GetTickCount();
  326.         TogglePlayerControllable(playerid, 1);
  327.         InfoTimer = SetTimer("UpdateInfoBox", 100, 1);
  328.     }
  329. }
  330.  
  331. WinnerRace(playerid)
  332. {
  333.     new Time = GetTickCount()-StartTickcount;
  334.     new Float:Health;
  335.     GetVehicleHealth(Racecar, Health);
  336.     Health = (Health/10);
  337.     new Min, Sec, Mil;
  338.     ConvertTime(Time, Min, Sec, Mil);
  339.     new Reward = (floatround(Min_Reward + (Health*Reward_Per_Health_Percent)) - ((Min*60+Sec)*Reward_Discount_Per_Second));
  340.     GivePlayerMoney(playerid, Reward);
  341.     new rName[MAX_PLAYER_NAME], str[128];
  342.    
  343.     GetPlayerName(CurrentRacer, rName, sizeof(rName));
  344.     if(Time < highscoretimes[1])
  345.     {
  346.         format(str, 128, "%s finisavo Mount Chiliad Lengtynes !!. Jisai/Jinai Laimejo $%d!!", rName, Reward);
  347.         SendClientMessageToAll(0x7FFF00AA, str);
  348.         format(str, 128, "%s sulauze nauja rekorda: %02d:%02d:%03d!!", rName, Min, Sec, Mil);
  349.         SendClientMessageToAll(0x7FFF00AA, str);
  350.     }
  351.     else
  352.     {
  353.         format(str, 128, "%s finisavo Mount Chiliad Lengtynes per %02d:%02d:%03d!!. Jisai/Jinai Laimejo $%d!!", rName, Min, Sec, Mil, Reward);
  354.         SendClientMessageToAll(0x7FFF00AA, str);
  355.     }
  356.     GameTextForPlayer(CurrentRacer, "~y~Laimetojas!!", 3500, 3);
  357.     TogglePlayerControllable(playerid, 0);
  358.     SetScoreInHighscoreTable(playerid, Time);
  359.     DisablePlayerRaceCheckpoint(CurrentRacer);
  360.     KillTimer(InfoTimer);
  361. }
  362.  
  363. FailedRace()
  364. {
  365.     GameTextForPlayer(CurrentRacer, "~r~Zaidimo Pabaiga", 3500, 3);
  366.     DisablePlayerRaceCheckpoint(CurrentRacer);
  367.     new rName[MAX_PLAYER_NAME], str[128];
  368.     GetPlayerName(CurrentRacer, rName, sizeof(rName));
  369.     format(str, 128, "%s tuneyvigdiai Mount Chiliad Lengtyniu. Jeigu norite pabandyti dar karta yrasykite /mcrace", rName);
  370.     SendClientMessageToAll(0xFFA500AA, str);
  371.     KillTimer(InfoTimer);
  372.     if(IsPlayerConnected(CurrentRacer))
  373.     {
  374.         SetTimerEx("ResetRace", 5000, 0, "i", CurrentRacer);
  375.     }
  376.     else
  377.     {
  378.         ResetRace(CurrentRacer);
  379.     }
  380. }
  381.  
  382. forward ResetRace(playerid);
  383. public ResetRace(playerid)
  384. {
  385.  
  386.     if(Died == 0)
  387.     {
  388.         SetPlayerInterior(CurrentRacer, LastInterior);
  389.         SetPlayerPos(CurrentRacer, LastPos[0], LastPos[1], LastPos[2]);
  390.         SetPlayerFacingAngle(CurrentRacer, LastPos[3]);
  391.     }
  392.     Died = 0;
  393.     TogglePlayerControllable(playerid, 1);
  394.     RemovePlayerFromVehicle(CurrentRacer);
  395.     SetCameraBehindPlayer(CurrentRacer);
  396.     DestroyVehicle(Racecar);
  397.     DisablePlayerRaceCheckpoint(CurrentRacer);
  398.     Racecar = -1;
  399.     RaceStarted = false;
  400.     CurrentRacer = -1;
  401.     GameTextForPlayer(playerid, " ", 10, 3);
  402.     PlayerPlaySound(playerid, 1188, -1633.0308,-2240.3904,37.3984);
  403.     HideHighScoreTable(playerid);
  404.     TextDrawHideForPlayer(playerid, InfoBox);
  405. }
  406.  
  407.  
  408. stock SetScoreInHighscoreTable(playerid, time)
  409. {
  410.     new Position = 999;
  411.     for(new i=1; i<11; i++)
  412.     {
  413.         if(time < highscoretimes[i])
  414.         {
  415.             Position = i;
  416.             break;
  417.         }
  418.     }
  419.     if(Position != 999 && Position != 10)
  420.     {
  421.         for(new j=Position; j<10; j++)
  422.         {
  423.             tmphighscoretimes[j+1] = highscoretimes[j];
  424.             format(tmphighscorenames[j+1], 24, "%s",highscorenames[j]);
  425.         }
  426.         for(new j=Position; j<10; j++)
  427.         {
  428.             highscoretimes[j+1] = tmphighscoretimes[j+1];
  429.             format(highscorenames[j+1], 24, "%s", tmphighscorenames[j+1]);
  430.         }
  431.         highscoretimes[Position] = time;
  432.         GetPlayerName(playerid, highscorenames[Position], 24);
  433.         WriteScoresToFile();
  434.     }
  435.     if(Position == 10)
  436.     {
  437.         highscoretimes[10] = time;
  438.         GetPlayerName(playerid, highscorenames[10], 24);
  439.         WriteScoresToFile();
  440.     }
  441.     ShowHighScoreTable(playerid, Position);
  442.     PlayerPlaySound(playerid, 1187, -1633.0308,-2240.3904,37.3984);
  443.     SetTimerEx("ResetRace", 10000, 0, "i", playerid);
  444. }
  445.  
  446. WriteScoresToFile()
  447. {
  448.     new tmp[5];
  449.     for(new i=1; i<11; i++)
  450.     {
  451.         format(tmp, 5, "T%d", i);
  452.         dini_IntSet("MCR-Highscores.txt", tmp, highscoretimes[i]);
  453.     }
  454.     for(new i=1; i<11; i++)
  455.     {
  456.         format(tmp, 5, "N%d", i);
  457.         dini_Set("MCR-Highscores.txt", tmp, highscorenames[i]);
  458.     }
  459. }
  460.  
  461. ShowHighScoreTable(playerid, Position)
  462. {
  463.     new mt[10], sc[10], ms[10];
  464.     switch(Position)
  465.     {
  466.         case 1:
  467.         {
  468.             ConvertTime(highscoretimes[1], mt[0], sc[0], ms[0]); ConvertTime(highscoretimes[2], mt[1], sc[1], ms[1]);
  469.             format(HighScoreTableString[0], 128, "~y~       Highscores:~n~~r~# %5s %10s~n~~y~01: %d:%02d:%03d - %s~n~~g~02: %d:%02d:%03d - %s", "Time", "Name", mt[0], sc[0], ms[0], highscorenames[1], mt[1], sc[1], ms[1], highscorenames[2]);
  470.             ConvertTime(highscoretimes[3], mt[2], sc[2], ms[2]); ConvertTime(highscoretimes[4], mt[3], sc[3], ms[3]); ConvertTime(highscoretimes[5], mt[4], sc[4], ms[4]);
  471.             format(HighScoreTableString[1], 128, "~g~03: %d:%02d:%03d - %s~n~~g~04: %d:%02d:%03d - %s~n~~g~05: %d:%02d:%03d - %s", mt[2], sc[2], ms[2], highscorenames[3], mt[3], sc[3], ms[3], highscorenames[4], mt[4], sc[4], ms[4], highscorenames[5]);
  472.             ConvertTime(highscoretimes[6], mt[5], sc[5], ms[5]); ConvertTime(highscoretimes[7], mt[6], sc[6], ms[6]); ConvertTime(highscoretimes[8], mt[7], sc[7], ms[7]);
  473.             format(HighScoreTableString[2], 128, "~g~06: %d:%02d:%03d - %s~n~~g~07: %d:%02d:%03d - %s~n~~g~08: %d:%02d:%03d - %s", mt[5], sc[5], ms[5], highscorenames[6], mt[6], sc[6], ms[6], highscorenames[7], mt[7], sc[7], ms[7], highscorenames[8]);
  474.             ConvertTime(highscoretimes[9], mt[8], sc[8], ms[8]); ConvertTime(highscoretimes[10], mt[9], sc[9], ms[9]);
  475.             format(HighScoreTableString[3], 128, "~g~09: %d:%02d:%03d - %s~n~~g~10: %d:%02d:%03d - %s", mt[8], sc[8], ms[8], highscorenames[9], mt[9], sc[9], ms[9], highscorenames[10]);
  476.         }
  477.         case 2:
  478.         {
  479.             ConvertTime(highscoretimes[1], mt[0], sc[0], ms[0]); ConvertTime(highscoretimes[2], mt[1], sc[1], ms[1]);
  480.             format(HighScoreTableString[0], 128, "~y~       Highscores:~n~~r~# %5s %10s~n~~g~01: %d:%02d:%03d - %s~n~~y~02: %d:%02d:%03d - %s", "Time", "Name", mt[0], sc[0], ms[0], highscorenames[1], mt[1], sc[1], ms[1], highscorenames[2]);
  481.             ConvertTime(highscoretimes[3], mt[2], sc[2], ms[2]); ConvertTime(highscoretimes[4], mt[3], sc[3], ms[3]); ConvertTime(highscoretimes[5], mt[4], sc[4], ms[4]);
  482.             format(HighScoreTableString[1], 128, "~g~03: %d:%02d:%03d - %s~n~~g~04: %d:%02d:%03d - %s~n~~g~05: %d:%02d:%03d - %s", mt[2], sc[2], ms[2], highscorenames[3], mt[3], sc[3], ms[3], highscorenames[4], mt[4], sc[4], ms[4], highscorenames[5]);
  483.             ConvertTime(highscoretimes[6], mt[5], sc[5], ms[5]); ConvertTime(highscoretimes[7], mt[6], sc[6], ms[6]); ConvertTime(highscoretimes[8], mt[7], sc[7], ms[7]);
  484.             format(HighScoreTableString[2], 128, "~g~06: %d:%02d:%03d - %s~n~~g~07: %d:%02d:%03d - %s~n~~g~08: %d:%02d:%03d - %s", mt[5], sc[5], ms[5], highscorenames[6], mt[6], sc[6], ms[6], highscorenames[7], mt[7], sc[7], ms[7], highscorenames[8]);
  485.             ConvertTime(highscoretimes[9], mt[8], sc[8], ms[8]); ConvertTime(highscoretimes[10], mt[9], sc[9], ms[9]);
  486.             format(HighScoreTableString[3], 128, "~g~09: %d:%02d:%03d - %s~n~~g~10: %d:%02d:%03d - %s", mt[8], sc[8], ms[8], highscorenames[9], mt[9], sc[9], ms[9], highscorenames[10]);
  487.         }
  488.         case 3:
  489.         {
  490.             ConvertTime(highscoretimes[1], mt[0], sc[0], ms[0]); ConvertTime(highscoretimes[2], mt[1], sc[1], ms[1]);
  491.             format(HighScoreTableString[0], 128, "~y~       Highscores:~n~~r~# %5s %10s~n~~g~01: %d:%02d:%03d - %s~n~~g~02: %d:%02d:%03d - %s", "Time", "Name", mt[0], sc[0], ms[0], highscorenames[1], mt[1], sc[1], ms[1], highscorenames[2]);
  492.             ConvertTime(highscoretimes[3], mt[2], sc[2], ms[2]); ConvertTime(highscoretimes[4], mt[3], sc[3], ms[3]); ConvertTime(highscoretimes[5], mt[4], sc[4], ms[4]);
  493.             format(HighScoreTableString[1], 128, "~y~03: %d:%02d:%03d - %s~n~~g~04: %d:%02d:%03d - %s~n~~g~05: %d:%02d:%03d - %s", mt[2], sc[2], ms[2], highscorenames[3], mt[3], sc[3], ms[3], highscorenames[4], mt[4], sc[4], ms[4], highscorenames[5]);
  494.             ConvertTime(highscoretimes[6], mt[5], sc[5], ms[5]); ConvertTime(highscoretimes[7], mt[6], sc[6], ms[6]); ConvertTime(highscoretimes[8], mt[7], sc[7], ms[7]);
  495.             format(HighScoreTableString[2], 128, "~g~06: %d:%02d:%03d - %s~n~~g~07: %d:%02d:%03d - %s~n~~g~08: %d:%02d:%03d - %s", mt[5], sc[5], ms[5], highscorenames[6], mt[6], sc[6], ms[6], highscorenames[7], mt[7], sc[7], ms[7], highscorenames[8]);
  496.             ConvertTime(highscoretimes[9], mt[8], sc[8], ms[8]); ConvertTime(highscoretimes[10], mt[9], sc[9], ms[9]);
  497.             format(HighScoreTableString[3], 128, "~g~09: %d:%02d:%03d - %s~n~~g~10: %d:%02d:%03d - %s", mt[8], sc[8], ms[8], highscorenames[9], mt[9], sc[9], ms[9], highscorenames[10]);
  498.         }
  499.         case 4:
  500.         {
  501.             ConvertTime(highscoretimes[1], mt[0], sc[0], ms[0]); ConvertTime(highscoretimes[2], mt[1], sc[1], ms[1]);
  502.             format(HighScoreTableString[0], 128, "~y~       Highscores:~n~~r~# %5s %10s~n~~g~01: %d:%02d:%03d - %s~n~~g~02: %d:%02d:%03d - %s", "Time", "Name", mt[0], sc[0], ms[0], highscorenames[1], mt[1], sc[1], ms[1], highscorenames[2]);
  503.             ConvertTime(highscoretimes[3], mt[2], sc[2], ms[2]); ConvertTime(highscoretimes[4], mt[3], sc[3], ms[3]); ConvertTime(highscoretimes[5], mt[4], sc[4], ms[4]);
  504.             format(HighScoreTableString[1], 128, "~g~03: %d:%02d:%03d - %s~n~~y~04: %d:%02d:%03d - %s~n~~g~05: %d:%02d:%03d - %s", mt[2], sc[2], ms[2], highscorenames[3], mt[3], sc[3], ms[3], highscorenames[4], mt[4], sc[4], ms[4], highscorenames[5]);
  505.             ConvertTime(highscoretimes[6], mt[5], sc[5], ms[5]); ConvertTime(highscoretimes[7], mt[6], sc[6], ms[6]); ConvertTime(highscoretimes[8], mt[7], sc[7], ms[7]);
  506.             format(HighScoreTableString[2], 128, "~g~06: %d:%02d:%03d - %s~n~~g~07: %d:%02d:%03d - %s~n~~g~08: %d:%02d:%03d - %s", mt[5], sc[5], ms[5], highscorenames[6], mt[6], sc[6], ms[6], highscorenames[7], mt[7], sc[7], ms[7], highscorenames[8]);
  507.             ConvertTime(highscoretimes[9], mt[8], sc[8], ms[8]); ConvertTime(highscoretimes[10], mt[9], sc[9], ms[9]);
  508.             format(HighScoreTableString[3], 128, "~g~09: %d:%02d:%03d - %s~n~~g~10: %d:%02d:%03d - %s", mt[8], sc[8], ms[8], highscorenames[9], mt[9], sc[9], ms[9], highscorenames[10]);
  509.         }
  510.         case 5:
  511.         {
  512.             ConvertTime(highscoretimes[1], mt[0], sc[0], ms[0]); ConvertTime(highscoretimes[2], mt[1], sc[1], ms[1]);
  513.             format(HighScoreTableString[0], 128, "~y~       Highscores:~n~~r~# %5s %10s~n~~g~01: %d:%02d:%03d - %s~n~~g~02: %d:%02d:%03d - %s", "Time", "Name", mt[0], sc[0], ms[0], highscorenames[1], mt[1], sc[1], ms[1], highscorenames[2]);
  514.             ConvertTime(highscoretimes[3], mt[2], sc[2], ms[2]); ConvertTime(highscoretimes[4], mt[3], sc[3], ms[3]); ConvertTime(highscoretimes[5], mt[4], sc[4], ms[4]);
  515.             format(HighScoreTableString[1], 128, "~g~03: %d:%02d:%03d - %s~n~~g~04: %d:%02d:%03d - %s~n~~y~05: %d:%02d:%03d - %s", mt[2], sc[2], ms[2], highscorenames[3], mt[3], sc[3], ms[3], highscorenames[4], mt[4], sc[4], ms[4], highscorenames[5]);
  516.             ConvertTime(highscoretimes[6], mt[5], sc[5], ms[5]); ConvertTime(highscoretimes[7], mt[6], sc[6], ms[6]); ConvertTime(highscoretimes[8], mt[7], sc[7], ms[7]);
  517.             format(HighScoreTableString[2], 128, "~g~06: %d:%02d:%03d - %s~n~~g~07: %d:%02d:%03d - %s~n~~g~08: %d:%02d:%03d - %s", mt[5], sc[5], ms[5], highscorenames[6], mt[6], sc[6], ms[6], highscorenames[7], mt[7], sc[7], ms[7], highscorenames[8]);
  518.             ConvertTime(highscoretimes[9], mt[8], sc[8], ms[8]); ConvertTime(highscoretimes[10], mt[9], sc[9], ms[9]);
  519.             format(HighScoreTableString[3], 128, "~g~09: %d:%02d:%03d - %s~n~~g~10: %d:%02d:%03d - %s", mt[8], sc[8], ms[8], highscorenames[9], mt[9], sc[9], ms[9], highscorenames[10]);
  520.         }
  521.         case 6:
  522.         {
  523.             ConvertTime(highscoretimes[1], mt[0], sc[0], ms[0]); ConvertTime(highscoretimes[2], mt[1], sc[1], ms[1]);
  524.             format(HighScoreTableString[0], 128, "~y~       Highscores:~n~~r~# %5s %10s~n~~g~01: %d:%02d:%03d - %s~n~~g~02: %d:%02d:%03d - %s", "Time", "Name", mt[0], sc[0], ms[0], highscorenames[1], mt[1], sc[1], ms[1], highscorenames[2]);
  525.             ConvertTime(highscoretimes[3], mt[2], sc[2], ms[2]); ConvertTime(highscoretimes[4], mt[3], sc[3], ms[3]); ConvertTime(highscoretimes[5], mt[4], sc[4], ms[4]);
  526.             format(HighScoreTableString[1], 128, "~g~03: %d:%02d:%03d - %s~n~~g~04: %d:%02d:%03d - %s~n~~g~05: %d:%02d:%03d - %s", mt[2], sc[2], ms[2], highscorenames[3], mt[3], sc[3], ms[3], highscorenames[4], mt[4], sc[4], ms[4], highscorenames[5]);
  527.             ConvertTime(highscoretimes[6], mt[5], sc[5], ms[5]); ConvertTime(highscoretimes[7], mt[6], sc[6], ms[6]); ConvertTime(highscoretimes[8], mt[7], sc[7], ms[7]);
  528.             format(HighScoreTableString[2], 128, "~y~06: %d:%02d:%03d - %s~n~~g~07: %d:%02d:%03d - %s~n~~g~08: %d:%02d:%03d - %s", mt[5], sc[5], ms[5], highscorenames[6], mt[6], sc[6], ms[6], highscorenames[7], mt[7], sc[7], ms[7], highscorenames[8]);
  529.             ConvertTime(highscoretimes[9], mt[8], sc[8], ms[8]); ConvertTime(highscoretimes[10], mt[9], sc[9], ms[9]);
  530.             format(HighScoreTableString[3], 128, "~g~09: %d:%02d:%03d - %s~n~~g~10: %d:%02d:%03d - %s", mt[8], sc[8], ms[8], highscorenames[9], mt[9], sc[9], ms[9], highscorenames[10]);
  531.         }
  532.         case 7:
  533.         {
  534.             ConvertTime(highscoretimes[1], mt[0], sc[0], ms[0]); ConvertTime(highscoretimes[2], mt[1], sc[1], ms[1]);
  535.             format(HighScoreTableString[0], 128, "~y~       Highscores:~n~~r~# %5s %10s~n~~g~01: %d:%02d:%03d - %s~n~~g~02: %d:%02d:%03d - %s", "Time", "Name", mt[0], sc[0], ms[0], highscorenames[1], mt[1], sc[1], ms[1], highscorenames[2]);
  536.             ConvertTime(highscoretimes[3], mt[2], sc[2], ms[2]); ConvertTime(highscoretimes[4], mt[3], sc[3], ms[3]); ConvertTime(highscoretimes[5], mt[4], sc[4], ms[4]);
  537.             format(HighScoreTableString[1], 128, "~g~03: %d:%02d:%03d - %s~n~~g~04: %d:%02d:%03d - %s~n~~g~05: %d:%02d:%03d - %s", mt[2], sc[2], ms[2], highscorenames[3], mt[3], sc[3], ms[3], highscorenames[4], mt[4], sc[4], ms[4], highscorenames[5]);
  538.             ConvertTime(highscoretimes[6], mt[5], sc[5], ms[5]); ConvertTime(highscoretimes[7], mt[6], sc[6], ms[6]); ConvertTime(highscoretimes[8], mt[7], sc[7], ms[7]);
  539.             format(HighScoreTableString[2], 128, "~g~06: %d:%02d:%03d - %s~n~~y~07: %d:%02d:%03d - %s~n~~g~08: %d:%02d:%03d - %s", mt[5], sc[5], ms[5], highscorenames[6], mt[6], sc[6], ms[6], highscorenames[7], mt[7], sc[7], ms[7], highscorenames[8]);
  540.             ConvertTime(highscoretimes[9], mt[8], sc[8], ms[8]); ConvertTime(highscoretimes[10], mt[9], sc[9], ms[9]);
  541.             format(HighScoreTableString[3], 128, "~g~09: %d:%02d:%03d - %s~n~~g~10: %d:%02d:%03d - %s", mt[8], sc[8], ms[8], highscorenames[9], mt[9], sc[9], ms[9], highscorenames[10]);
  542.         }
  543.         case 8:
  544.         {
  545.             ConvertTime(highscoretimes[1], mt[0], sc[0], ms[0]); ConvertTime(highscoretimes[2], mt[1], sc[1], ms[1]);
  546.             format(HighScoreTableString[0], 128, "~y~       Highscores:~n~~r~# %5s %10s~n~~g~01: %d:%02d:%03d - %s~n~~g~02: %d:%02d:%03d - %s", "Time", "Name", mt[0], sc[0], ms[0], highscorenames[1], mt[1], sc[1], ms[1], highscorenames[2]);
  547.             ConvertTime(highscoretimes[3], mt[2], sc[2], ms[2]); ConvertTime(highscoretimes[4], mt[3], sc[3], ms[3]); ConvertTime(highscoretimes[5], mt[4], sc[4], ms[4]);
  548.             format(HighScoreTableString[1], 128, "~g~03: %d:%02d:%03d - %s~n~~g~04: %d:%02d:%03d - %s~n~~g~05: %d:%02d:%03d - %s", mt[2], sc[2], ms[2], highscorenames[3], mt[3], sc[3], ms[3], highscorenames[4], mt[4], sc[4], ms[4], highscorenames[5]);
  549.             ConvertTime(highscoretimes[6], mt[5], sc[5], ms[5]); ConvertTime(highscoretimes[7], mt[6], sc[6], ms[6]); ConvertTime(highscoretimes[8], mt[7], sc[7], ms[7]);
  550.             format(HighScoreTableString[2], 128, "~g~06: %d:%02d:%03d - %s~n~~g~07: %d:%02d:%03d - %s~n~~y~08: %d:%02d:%03d - %s", mt[5], sc[5], ms[5], highscorenames[6], mt[6], sc[6], ms[6], highscorenames[7], mt[7], sc[7], ms[7], highscorenames[8]);
  551.             ConvertTime(highscoretimes[9], mt[8], sc[8], ms[8]); ConvertTime(highscoretimes[10], mt[9], sc[9], ms[9]);
  552.             format(HighScoreTableString[3], 128, "~g~09: %d:%02d:%03d - %s~n~~g~10: %d:%02d:%03d - %s", mt[8], sc[8], ms[8], highscorenames[9], mt[9], sc[9], ms[9], highscorenames[10]);
  553.         }
  554.         case 9:
  555.         {
  556.             ConvertTime(highscoretimes[1], mt[0], sc[0], ms[0]); ConvertTime(highscoretimes[2], mt[1], sc[1], ms[1]);
  557.             format(HighScoreTableString[0], 128, "~y~       Highscores:~n~~r~# %5s %10s~n~~g~01: %d:%02d:%03d - %s~n~~g~02: %d:%02d:%03d - %s", "Time", "Name", mt[0], sc[0], ms[0], highscorenames[1], mt[1], sc[1], ms[1], highscorenames[2]);
  558.             ConvertTime(highscoretimes[3], mt[2], sc[2], ms[2]); ConvertTime(highscoretimes[4], mt[3], sc[3], ms[3]); ConvertTime(highscoretimes[5], mt[4], sc[4], ms[4]);
  559.             format(HighScoreTableString[1], 128, "~g~03: %d:%02d:%03d - %s~n~~g~04: %d:%02d:%03d - %s~n~~g~05: %d:%02d:%03d - %s", mt[2], sc[2], ms[2], highscorenames[3], mt[3], sc[3], ms[3], highscorenames[4], mt[4], sc[4], ms[4], highscorenames[5]);
  560.             ConvertTime(highscoretimes[6], mt[5], sc[5], ms[5]); ConvertTime(highscoretimes[7], mt[6], sc[6], ms[6]); ConvertTime(highscoretimes[8], mt[7], sc[7], ms[7]);
  561.             format(HighScoreTableString[2], 128, "~g~06: %d:%02d:%03d - %s~n~~g~07: %d:%02d:%03d - %s~n~~g~08: %d:%02d:%03d - %s", mt[5], sc[5], ms[5], highscorenames[6], mt[6], sc[6], ms[6], highscorenames[7], mt[7], sc[7], ms[7], highscorenames[8]);
  562.             ConvertTime(highscoretimes[9], mt[8], sc[8], ms[8]); ConvertTime(highscoretimes[10], mt[9], sc[9], ms[9]);
  563.             format(HighScoreTableString[3], 128, "~y~09: %d:%02d:%03d - %s~n~~g~10: %d:%02d:%03d - %s", mt[8], sc[8], ms[8], highscorenames[9], mt[9], sc[9], ms[9], highscorenames[10]);
  564.         }
  565.         case 10:
  566.         {
  567.             ConvertTime(highscoretimes[1], mt[0], sc[0], ms[0]); ConvertTime(highscoretimes[2], mt[1], sc[1], ms[1]);
  568.             format(HighScoreTableString[0], 128, "~y~       Highscores:~n~~r~# %5s %10s~n~~g~01: %d:%02d:%03d - %s~n~~g~02: %d:%02d:%03d - %s", "Time", "Name", mt[0], sc[0], ms[0], highscorenames[1], mt[1], sc[1], ms[1], highscorenames[2]);
  569.             ConvertTime(highscoretimes[3], mt[2], sc[2], ms[2]); ConvertTime(highscoretimes[4], mt[3], sc[3], ms[3]); ConvertTime(highscoretimes[5], mt[4], sc[4], ms[4]);
  570.             format(HighScoreTableString[1], 128, "~g~03: %d:%02d:%03d - %s~n~~g~04: %d:%02d:%03d - %s~n~~g~05: %d:%02d:%03d - %s", mt[2], sc[2], ms[2], highscorenames[3], mt[3], sc[3], ms[3], highscorenames[4], mt[4], sc[4], ms[4], highscorenames[5]);
  571.             ConvertTime(highscoretimes[6], mt[5], sc[5], ms[5]); ConvertTime(highscoretimes[7], mt[6], sc[6], ms[6]); ConvertTime(highscoretimes[8], mt[7], sc[7], ms[7]);
  572.             format(HighScoreTableString[2], 128, "~g~06: %d:%02d:%03d - %s~n~~g~07: %d:%02d:%03d - %s~n~~g~08: %d:%02d:%03d - %s", mt[5], sc[5], ms[5], highscorenames[6], mt[6], sc[6], ms[6], highscorenames[7], mt[7], sc[7], ms[7], highscorenames[8]);
  573.             ConvertTime(highscoretimes[9], mt[8], sc[8], ms[8]); ConvertTime(highscoretimes[10], mt[9], sc[9], ms[9]);
  574.             format(HighScoreTableString[3], 128, "~g~09: %d:%02d:%03d - %s~n~~y~10: %d:%02d:%03d - %s", mt[8], sc[8], ms[8], highscorenames[9], mt[9], sc[9], ms[9], highscorenames[10]);
  575.         }
  576.         case 999:
  577.         {
  578.             ConvertTime(highscoretimes[1], mt[0], sc[0], ms[0]); ConvertTime(highscoretimes[2], mt[1], sc[1], ms[1]);
  579.             format(HighScoreTableString[0], 128, "~y~       Highscores:~n~~r~# %5s %10s~n~~g~01: %d:%02d:%03d - %s~n~~g~02: %d:%02d:%03d - %s", "Time", "Name", mt[0], sc[0], ms[0], highscorenames[1], mt[1], sc[1], ms[1], highscorenames[2]);
  580.             ConvertTime(highscoretimes[3], mt[2], sc[2], ms[2]); ConvertTime(highscoretimes[4], mt[3], sc[3], ms[3]); ConvertTime(highscoretimes[5], mt[4], sc[4], ms[4]);
  581.             format(HighScoreTableString[1], 128, "~g~03: %d:%02d:%03d - %s~n~~g~04: %d:%02d:%03d - %s~n~~g~05: %d:%02d:%03d - %s", mt[2], sc[2], ms[2], highscorenames[3], mt[3], sc[3], ms[3], highscorenames[4], mt[4], sc[4], ms[4], highscorenames[5]);
  582.             ConvertTime(highscoretimes[6], mt[5], sc[5], ms[5]); ConvertTime(highscoretimes[7], mt[6], sc[6], ms[6]); ConvertTime(highscoretimes[8], mt[7], sc[7], ms[7]);
  583.             format(HighScoreTableString[2], 128, "~g~06: %d:%02d:%03d - %s~n~~g~07: %d:%02d:%03d - %s~n~~g~08: %d:%02d:%03d - %s", mt[5], sc[5], ms[5], highscorenames[6], mt[6], sc[6], ms[6], highscorenames[7], mt[7], sc[7], ms[7], highscorenames[8]);
  584.             ConvertTime(highscoretimes[9], mt[8], sc[8], ms[8]); ConvertTime(highscoretimes[10], mt[9], sc[9], ms[9]);
  585.             format(HighScoreTableString[3], 128, "~g~09: %d:%02d:%03d - %s~n~~g~10: %d:%02d:%03d - %s", mt[8], sc[8], ms[8], highscorenames[9], mt[9], sc[9], ms[9], highscorenames[10]);
  586.         }
  587.     }
  588.     for(new i; i<4; i++)
  589.     {
  590.         TextDrawSetString(HighScoreTable[i], HighScoreTableString[i]);
  591.         TextDrawShowForPlayer(playerid, HighScoreTable[i]);
  592.         IsViewingHighScoreTable[playerid] = 1;
  593.     }
  594. }
  595.  
  596.  
  597. HideHighScoreTable(playerid)
  598. {
  599.     for(new i; i<4; i++)
  600.     {
  601.         TextDrawHideForPlayer(playerid, HighScoreTable[i]);
  602.         IsViewingHighScoreTable[playerid] = 0;
  603.     }
  604. }
  605.  
  606.  
  607. DestroyHighScoreTable()
  608. {
  609.     for(new i; i<4; i++)
  610.     {
  611.         TextDrawHideForAll(HighScoreTable[i]);
  612.         TextDrawDestroy(HighScoreTable[i]);
  613.     }
  614. }
  615.  
  616. forward UpdateInfoBox();
  617. public UpdateInfoBox()
  618. {
  619.     new Reward, Float:Health;
  620.     GetVehicleHealth(Racecar, Health);
  621.     Health = (Health/10);
  622.     new Time = GetTickCount()-StartTickcount;
  623.     new Min, Sec, Mil;
  624.     ConvertTime(Time, Min, Sec, Mil);
  625.     Reward = (floatround(Min_Reward + (Health*Reward_Per_Health_Percent)) - (Min*60+Sec*Reward_Discount_Per_Second));
  626.     format(InfoBoxString, 128, "~r~Checkpoint: ~y~%d/54~n~~r~Time Elapsed: ~y~%01d:%02d:%02d~n~~r~CarHealth: ~y~%.1f~n~~r~Estimated Reward: ~y~$%d", CC, Min, Sec, Mil, Health, Reward);
  627.     TextDrawHideForPlayer(CurrentRacer, InfoBox);
  628.     TextDrawSetString(InfoBox, InfoBoxString);
  629.     TextDrawShowForPlayer(CurrentRacer, InfoBox);
  630.     if(Min == max_minutes-1 && Sec == 0)
  631.     {
  632.         GameTextForPlayer(CurrentRacer, "~r~1 minute left!!", 2000, 3);
  633.     }
  634.     if(Min == max_minutes-1 && Sec == 50)
  635.     {
  636.         GameTextForPlayer(CurrentRacer, "~r~10 seconds left!!", 1500, 3);
  637.     }
  638.     if(Min == max_minutes)
  639.     {
  640.         FailedRace();
  641.     }
  642. }
  643.  
  644. forward MoveCamera(playerid);
  645. public MoveCamera(playerid)
  646. {
  647.  
  648.     CamCount = CamCount- 0.35;
  649.     SetPlayerCameraLookAt(CurrentRacer, -2295.3433,-CamCount,475.4256);
  650.     if(CamCount < 1670.0)
  651.     {
  652.         KillTimer(CameraTimer);
  653.         SetTimer("CBP", 1000, 0);
  654.     }
  655. }
  656.  
  657. forward CBP();
  658. public CBP()
  659. {
  660.     SetCameraBehindPlayer(CurrentRacer);
  661. }
  662.  
  663. ConvertTime(tm, &minutes, &seconds, &milliseconds)
  664. {
  665.     for(new i; i<1000; i++)
  666.     {
  667.         if(tm >= 1000)
  668.         {
  669.             tm = tm-1000;
  670.             seconds++;
  671.             if(seconds == 60)
  672.             {
  673.                 seconds = 0;
  674.                 minutes++;
  675.             }
  676.         }
  677.         else
  678.         {
  679.             milliseconds = tm;
  680.             break;
  681.         }
  682.     }
  683. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement