Martex

Race

Apr 18th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. function LoadRaceNames()
  2. {
  3. new
  4. rNameFile[64],
  5. string[64]
  6. ;
  7. format(rNameFile, sizeof(rNameFile), "/rRaceSystem/RaceNames/RaceNames.txt");
  8. TotalRaces = dini_Int(rNameFile, "TotalRaces");
  9. Loop(x, TotalRaces)
  10. {
  11. format(string, sizeof(string), "Race_%d", x), strmid(RaceNames[x], dini_Get(rNameFile, string), 0, 20, sizeof(RaceNames));
  12. printf(">> Loaded Races: %s", RaceNames[x]);
  13. }
  14. return 1;
  15. }
  16. function LoadAutoRace(rName[])
  17. {
  18. new
  19. rFile[256],
  20. string[256]
  21. ;
  22. format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", rName);
  23. if(!dini_Exists(rFile)) return printf("Race \"%s\" doesn't exist!", rName);
  24. strmid(RaceName, rName, 0, strlen(rName), sizeof(RaceName));
  25. RaceVehicle = dini_Int(rFile, "vModel");
  26. RaceType = dini_Int(rFile, "rType");
  27. TotalCP = dini_Int(rFile, "TotalCP");
  28.  
  29. #if DEBUG_RACE == 1
  30. printf("VehicleModel: %d", RaceVehicle);
  31. printf("RaceType: %d", RaceType);
  32. printf("TotalCheckpoints: %d", TotalCP);
  33. #endif
  34.  
  35. Loop(x, 2)
  36. {
  37. format(string, sizeof(string), "vPosX_%d", x), RaceVehCoords[x][0] = dini_Float(rFile, string);
  38. format(string, sizeof(string), "vPosY_%d", x), RaceVehCoords[x][1] = dini_Float(rFile, string);
  39. format(string, sizeof(string), "vPosZ_%d", x), RaceVehCoords[x][2] = dini_Float(rFile, string);
  40. format(string, sizeof(string), "vAngle_%d", x), RaceVehCoords[x][3] = dini_Float(rFile, string);
  41. #if DEBUG_RACE == 1
  42. printf("VehiclePos %d: %f, %f, %f, %f", x, RaceVehCoords[x][0], RaceVehCoords[x][1], RaceVehCoords[x][2], RaceVehCoords[x][3]);
  43. #endif
  44. }
  45. Loop(x, TotalCP)
  46. {
  47. format(string, sizeof(string), "CP_%d_PosX", x), CPCoords[x][0] = dini_Float(rFile, string);
  48. format(string, sizeof(string), "CP_%d_PosY", x), CPCoords[x][1] = dini_Float(rFile, string);
  49. format(string, sizeof(string), "CP_%d_PosZ", x), CPCoords[x][2] = dini_Float(rFile, string);
  50. #if DEBUG_RACE == 1
  51. printf("RaceCheckPoint %d: %f, %f, %f", x, CPCoords[x][0], CPCoords[x][1], CPCoords[x][2]);
  52. #endif
  53. }
  54. Position = 0;
  55. FinishCount = 0;
  56. JoinCount = 0;
  57. Loop(x, 2) PlayersCount[x] = 0;
  58. CountAmount = COUNT_DOWN_TILL_RACE_START;
  59. RaceTime = MAX_RACE_TIME;
  60. RaceBusy = 0x01;
  61. CountTimer = SetTimer("CountTillRace", 999, 1);
  62. TimeProgress = 0;
  63. return 1;
  64. }
  65. function LoadRace(playerid, rName[])
  66. {
  67. new
  68. rFile[256],
  69. string[256]
  70. ;
  71. format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", rName);
  72. if(!dini_Exists(rFile)) return SendClientMessage(playerid, RED, "<!> Race doesn't exist!"), printf("Race \"%s\" doesn't exist!", rName);
  73. strmid(RaceName, rName, 0, strlen(rName), sizeof(RaceName));
  74. RaceVehicle = dini_Int(rFile, "vModel");
  75. RaceType = dini_Int(rFile, "rType");
  76. TotalCP = dini_Int(rFile, "TotalCP");
  77.  
  78. #if DEBUG_RACE == 1
  79. printf("VehicleModel: %d", RaceVehicle);
  80. printf("RaceType: %d", RaceType);
  81. printf("TotalCheckpoints: %d", TotalCP);
  82. #endif
  83.  
  84. Loop(x, 2)
  85. {
  86. format(string, sizeof(string), "vPosX_%d", x), RaceVehCoords[x][0] = dini_Float(rFile, string);
  87. format(string, sizeof(string), "vPosY_%d", x), RaceVehCoords[x][1] = dini_Float(rFile, string);
  88. format(string, sizeof(string), "vPosZ_%d", x), RaceVehCoords[x][2] = dini_Float(rFile, string);
  89. format(string, sizeof(string), "vAngle_%d", x), RaceVehCoords[x][3] = dini_Float(rFile, string);
  90. #if DEBUG_RACE == 1
  91. printf("VehiclePos %d: %f, %f, %f, %f", x, RaceVehCoords[x][0], RaceVehCoords[x][1], RaceVehCoords[x][2], RaceVehCoords[x][3]);
  92. #endif
  93. }
  94. Loop(x, TotalCP)
  95. {
  96. format(string, sizeof(string), "CP_%d_PosX", x), CPCoords[x][0] = dini_Float(rFile, string);
  97. format(string, sizeof(string), "CP_%d_PosY", x), CPCoords[x][1] = dini_Float(rFile, string);
  98. format(string, sizeof(string), "CP_%d_PosZ", x), CPCoords[x][2] = dini_Float(rFile, string);
  99. #if DEBUG_RACE == 1
  100. printf("RaceCheckPoint %d: %f, %f, %f", x, CPCoords[x][0], CPCoords[x][1], CPCoords[x][2]);
  101. #endif
  102. }
  103. Position = 0;
  104. FinishCount = 0;
  105. JoinCount = 0;
  106. Loop(x, 2) PlayersCount[x] = 0;
  107. Joined[playerid] = true;
  108. CountAmount = COUNT_DOWN_TILL_RACE_START;
  109. RaceTime = MAX_RACE_TIME;
  110. RaceBusy = 0x01;
  111. TimeProgress = 0;
  112. SetupRaceForPlayer(playerid);
  113. CountTimer = SetTimer("CountTillRace", 999, 1);
  114. return 1;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment