Advertisement
Guest User

rRace...para modificar!

a guest
Sep 28th, 2011
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.58 KB | None | 0 0
  1. /*
  2. Release:
  3. » Race System Filterscript
  4.  
  5. Author:
  6. » » RyDeR «
  7.  
  8. Last Update:
  9. » 26/04/2010
  10.  
  11. ChangeLog:
  12. » v0.1a:
  13. - Initial release
  14.  
  15. » v0.2a:
  16. - Major Bugs fixed!
  17. - Racing in other worlds added (enable/disbable with uncomment/comment-ing the define)
  18. - New Commands added:
  19. - /startautorace: You can enable that the script starts automaticly a race after the previous one is done.
  20. - /stopautorace: You can disable the command above.
  21. - /exitrace: To exit the race safely
  22. - Best Race Times added (Top 5 best time laps; You will see a message when the record is broken).
  23. - Crash while creating a race is fixed.
  24. - Etc..
  25.  
  26. Bugs:
  27. » No bugs
  28.  
  29. Version:
  30. » v0.2a
  31.  
  32. Functions:
  33. » IsPlayerInRace(playerid); >> UseFull in stunt servers to disable speedhack, nitro etc. while racing.
  34.  
  35. Credits:
  36. » Joker: He knows why ;)
  37. » Joe Torran C, ModrLicC: For testing.
  38. » DracoBlue: 'Dini' include.
  39. » Y_Less: 'IsOdd' function.
  40. » Seif_: 'function' function.
  41. » ZeeX: 'zcmd' include.
  42. » Switch: InRace Position function.
  43. */
  44.  
  45. #include <a_samp>
  46. #include <dini>
  47. #include <zcmd>
  48.  
  49. #pragma unused \
  50. ret_memcpy
  51.  
  52. #define ForEach(%0,%1) \
  53. for(new %0 = 0; %0 != %1; %0++) if(IsPlayerConnected(%0) && !IsPlayerNPC(%0))
  54.  
  55. #define Loop(%0,%1) \
  56. for(new %0 = 0; %0 != %1; %0++)
  57.  
  58. #define IsOdd(%1) \
  59. ((%1) & 1)
  60.  
  61. #define ConvertTime(%0,%1,%2,%3,%4) \
  62. new \
  63. Float: %0 = floatdiv(%1, 60000) \
  64. ;\
  65. %2 = floatround(%0, floatround_tozero); \
  66. %3 = floatround(floatmul(%0 - %2, 60), floatround_tozero); \
  67. %4 = floatround(floatmul(floatmul(%0 - %2, 60) - %3, 1000), floatround_tozero)
  68.  
  69. #define function%0(%1) \
  70. forward%0(%1); public%0(%1)
  71.  
  72. #define MAX_RACE_CHECKPOINTS_EACH_RACE \
  73. 120
  74.  
  75. #define MAX_RACES \
  76. 100
  77.  
  78. #define COUNT_DOWN_TILL_RACE_START \
  79. 30 // seconds
  80.  
  81. #define MAX_RACE_TIME \
  82. 300 // seconds
  83.  
  84. #define RACE_CHECKPOINT_SIZE \
  85. 12.0
  86.  
  87. #define DEBUG_RACE \
  88. 1
  89.  
  90. //#define RACE_IN_OTHER_WORLD // Uncomment to enable
  91.  
  92. #define GREY \
  93. 0xAFAFAFAA
  94.  
  95. #define GREEN \
  96. 0x9FFF00FF
  97.  
  98. #define RED \
  99. 0xE60000FF
  100.  
  101. #define YELLOW \
  102. 0xFFFF00AA
  103.  
  104. #define WHITE \
  105. 0xFFFFFFAA
  106.  
  107. new
  108. vNames[212][] =
  109. {
  110. {"Landstalker"},
  111. {"Bravura"},
  112. {"Buffalo"},
  113. {"Linerunner"},
  114. {"Perrenial"},
  115. {"Sentinel"},
  116. {"Dumper"},
  117. {"Firetruck"},
  118. {"Trashmaster"},
  119. {"Stretch"},
  120. {"Manana"},
  121. {"Infernus"},
  122. {"Voodoo"},
  123. {"Pony"},
  124. {"Mule"},
  125. {"Cheetah"},
  126. {"Ambulance"},
  127. {"Leviathan"},
  128. {"Moonbeam"},
  129. {"Esperanto"},
  130. {"Taxi"},
  131. {"Washington"},
  132. {"Bobcat"},
  133. {"Mr Whoopee"},
  134. {"BF Injection"},
  135. {"Hunter"},
  136. {"Premier"},
  137. {"Enforcer"},
  138. {"Securicar"},
  139. {"Banshee"},
  140. {"Predator"},
  141. {"Bus"},
  142. {"Rhino"},
  143. {"Barracks"},
  144. {"Hotknife"},
  145. {"Trailer 1"},
  146. {"Previon"},
  147. {"Coach"},
  148. {"Cabbie"},
  149. {"Stallion"},
  150. {"Rumpo"},
  151. {"RC Bandit"},
  152. {"Romero"},
  153. {"Packer"},
  154. {"Monster"},
  155. {"Admiral"},
  156. {"Squalo"},
  157. {"Seasparrow"},
  158. {"Pizzaboy"},
  159. {"Tram"},
  160. {"Trailer 2"},
  161. {"Turismo"},
  162. {"Speeder"},
  163. {"Reefer"},
  164. {"Tropic"},
  165. {"Flatbed"},
  166. {"Yankee"},
  167. {"Caddy"},
  168. {"Solair"},
  169. {"Berkley's RC Van"},
  170. {"Skimmer"},
  171. {"PCJ-600"},
  172. {"Faggio"},
  173. {"Freeway"},
  174. {"RC Baron"},
  175. {"RC Raider"},
  176. {"Glendale"},
  177. {"Oceanic"},
  178. {"Sanchez"},
  179. {"Sparrow"},
  180. {"Patriot"},
  181. {"Quad"},
  182. {"Coastguard"},
  183. {"Dinghy"},
  184. {"Hermes"},
  185. {"Sabre"},
  186. {"Rustler"},
  187. {"ZR-350"},
  188. {"Walton"},
  189. {"Regina"},
  190. {"Comet"},
  191. {"BMX"},
  192. {"Burrito"},
  193. {"Camper"},
  194. {"Marquis"},
  195. {"Baggage"},
  196. {"Dozer"},
  197. {"Maverick"},
  198. {"News Chopper"},
  199. {"Rancher"},
  200. {"FBI Rancher"},
  201. {"Virgo"},
  202. {"Greenwood"},
  203. {"Jetmax"},
  204. {"Hotring"},
  205. {"Sandking"},
  206. {"Blista Compact"},
  207. {"Police Maverick"},
  208. {"Boxville"},
  209. {"Benson"},
  210. {"Mesa"},
  211. {"RC Goblin"},
  212. {"Hotring Racer A"},
  213. {"Hotring Racer B"},
  214. {"Bloodring Banger"},
  215. {"Rancher"},
  216. {"Super GT"},
  217. {"Elegant"},
  218. {"Journey"},
  219. {"Bike"},
  220. {"Mountain Bike"},
  221. {"Beagle"},
  222. {"Cropdust"},
  223. {"Stunt"},
  224. {"Tanker"},
  225. {"Roadtrain"},
  226. {"Nebula"},
  227. {"Majestic"},
  228. {"Buccaneer"},
  229. {"Shamal"},
  230. {"Hydra"},
  231. {"FCR-900"},
  232. {"NRG-500"},
  233. {"HPV1000"},
  234. {"Cement Truck"},
  235. {"Tow Truck"},
  236. {"Fortune"},
  237. {"Cadrona"},
  238. {"FBI Truck"},
  239. {"Willard"},
  240. {"Forklift"},
  241. {"Tractor"},
  242. {"Combine"},
  243. {"Feltzer"},
  244. {"Remington"},
  245. {"Slamvan"},
  246. {"Blade"},
  247. {"Freight"},
  248. {"Streak"},
  249. {"Vortex"},
  250. {"Vincent"},
  251. {"Bullet"},
  252. {"Clover"},
  253. {"Sadler"},
  254. {"Firetruck LA"},
  255. {"Hustler"},
  256. {"Intruder"},
  257. {"Primo"},
  258. {"Cargobob"},
  259. {"Tampa"},
  260. {"Sunrise"},
  261. {"Merit"},
  262. {"Utility"},
  263. {"Nevada"},
  264. {"Yosemite"},
  265. {"Windsor"},
  266. {"Monster A"},
  267. {"Monster B"},
  268. {"Uranus"},
  269. {"Jester"},
  270. {"Sultan"},
  271. {"Stratum"},
  272. {"Elegy"},
  273. {"Raindance"},
  274. {"RC Tiger"},
  275. {"Flash"},
  276. {"Tahoma"},
  277. {"Savanna"},
  278. {"Bandito"},
  279. {"Freight Flat"},
  280. {"Streak Carriage"},
  281. {"Kart"},
  282. {"Mower"},
  283. {"Duneride"},
  284. {"Sweeper"},
  285. {"Broadway"},
  286. {"Tornado"},
  287. {"AT-400"},
  288. {"DFT-30"},
  289. {"Huntley"},
  290. {"Stafford"},
  291. {"BF-400"},
  292. {"Newsvan"},
  293. {"Tug"},
  294. {"Trailer 3"},
  295. {"Emperor"},
  296. {"Wayfarer"},
  297. {"Euros"},
  298. {"Hotdog"},
  299. {"Club"},
  300. {"Freight Carriage"},
  301. {"Trailer 3"},
  302. {"Andromada"},
  303. {"Dodo"},
  304. {"RC Cam"},
  305. {"Launch"},
  306. {"Police Car (LSPD)"},
  307. {"Police Car (SFPD)"},
  308. {"Police Car (LVPD)"},
  309. {"Police Ranger"},
  310. {"Picador"},
  311. {"S.W.A.T. Van"},
  312. {"Alpha"},
  313. {"Phoenix"},
  314. {"Glendale"},
  315. {"Sadler"},
  316. {"Luggage Trailer A"},
  317. {"Luggage Trailer B"},
  318. {"Stair Trailer"},
  319. {"Boxville"},
  320. {"Farm Plow"},
  321. {"Utility Trailer"}
  322. },
  323. BuildRace,
  324. BuildRaceType,
  325. BuildVehicle,
  326. BuildCreatedVehicle,
  327. BuildModeVID,
  328. BuildName[30],
  329. bool: BuildTakeVehPos,
  330. BuildVehPosCount,
  331. bool: BuildTakeCheckpoints,
  332. BuildCheckPointCount,
  333. RaceBusy = 0x00,
  334. RaceName[30],
  335. RaceVehicle,
  336. RaceType,
  337. TotalCP,
  338. Float: RaceVehCoords[2][4],
  339. Float: CPCoords[MAX_RACE_CHECKPOINTS_EACH_RACE][4],
  340. CreatedRaceVeh[MAX_PLAYERS],
  341. Index,
  342. PlayersCount[2],
  343. CountTimer,
  344. CountAmount,
  345. bool: Joined[MAX_PLAYERS],
  346. RaceTick,
  347. RaceStarted,
  348. CPProgess[MAX_PLAYERS],
  349. Position,
  350. FinishCount,
  351. JoinCount,
  352. rCounter,
  353. RaceTime,
  354. Text: RaceInfo[MAX_PLAYERS],
  355. InfoTimer[MAX_PLAYERS],
  356. RacePosition[MAX_PLAYERS],
  357. RaceNames[MAX_RACES][128],
  358. TotalRaces,
  359. bool: AutomaticRace,
  360. TimeProgress
  361.  
  362. ;
  363.  
  364. public OnFilterScriptExit()
  365. {
  366. BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
  367. KillTimer(rCounter);
  368. KillTimer(CountTimer);
  369. Loop(i, MAX_PLAYERS)
  370. {
  371. DisablePlayerRaceCheckpoint(i);
  372. TextDrawDestroy(RaceInfo[i]);
  373. DestroyVehicle(CreatedRaceVeh[i]);
  374. Joined[i] = false;
  375. KillTimer(InfoTimer[i]);
  376. }
  377. JoinCount = 0;
  378. FinishCount = 0;
  379. TimeProgress = 0;
  380. AutomaticRace = false;
  381. return 1;
  382. }
  383.  
  384. CMD:armarcarrera(playerid, params[])
  385. {
  386. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "<!> You are not an administrator!");
  387. if(BuildRace != 0) return SendClientMessage(playerid, RED, "<!> There's already someone building a race!");
  388. if(RaceBusy == 0x01) return SendClientMessage(playerid, RED, "<!> Wait first till race ends!");
  389. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "<!> Please leave your vehicle first!");
  390. BuildRace = playerid+1;
  391. ShowDialog(playerid, 599);
  392. return 1;
  393. }
  394. CMD:abrircarrera(playerid, params[])
  395. {
  396. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "<!> You are not an administrator!");
  397. if(AutomaticRace == true) return SendClientMessage(playerid, RED, "<!> Not possible. Automatic race is enabled!");
  398. if(BuildRace != 0) return SendClientMessage(playerid, RED, "<!> There's someone building a race!");
  399. if(RaceBusy == 0x01 || RaceStarted == 1) return SendClientMessage(playerid, RED, "<!> There's a race currently. Wait first till race ends!");
  400. if(isnull(params)) return SendClientMessage(playerid, RED, "<!> /abrircarrera [nombre]");
  401. LoadRace(playerid, params);
  402. return 1;
  403. }
  404. CMD:pararcarrera(playerid, params[])
  405. {
  406. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "<!> You are not an administrator!");
  407. if(RaceBusy == 0x00 || RaceStarted == 0) return SendClientMessage(playerid, RED, "<!> There's no race to stop!");
  408. return StopRace();
  409. }
  410. CMD:join(playerid, params[])
  411. {
  412. if(RaceStarted == 1) return SendClientMessage(playerid, RED, "<!> La Carrera ya empeso! Espera que termine!");
  413. if(RaceBusy == 0x00) return SendClientMessage(playerid, RED, "<!> No hay carreras para entrar!");
  414. if(Joined[playerid] == true) return SendClientMessage(playerid, RED, "<!> Has Entrado a la carrera!");
  415. if(IsPlayerInAnyVehicle(playerid)) return SetTimerEx("SetupRaceForPlayer", 2500, 0, "e", playerid), RemovePlayerFromVehicle(playerid), Joined[playerid] = true;
  416. SetupRaceForPlayer(playerid);
  417. Joined[playerid] = true;
  418. return 1;
  419. }
  420. CMD:carrerason(playerid, params[])
  421. {
  422. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "<!> You are not an administrator!");
  423. if(RaceBusy == 0x01 || RaceStarted == 1) return SendClientMessage(playerid, RED, "<!> There's a race currently. Wait first till race ends!");
  424. if(AutomaticRace == true) return SendClientMessage(playerid, RED, "<!> It's already enabled!");
  425. LoadRaceNames();
  426. LoadAutoRace(RaceNames[random(TotalRaces)]);
  427. AutomaticRace = true;
  428. SendClientMessage(playerid, GREEN, ">> You stared auto race. The filterscript will start a random race everytime the previous race is over!");
  429. return 1;
  430. }
  431. CMD:carrerasoff(playerid, params[])
  432. {
  433. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "<!> You are not an administrator!");
  434. if(AutomaticRace == false) return SendClientMessage(playerid, RED, "<!> It's already disabled!");
  435. AutomaticRace = false;
  436. return 1;
  437. }
  438. CMD:exit(playerid, params[])
  439. {
  440. if(Joined[playerid] == true)
  441. {
  442. JoinCount--;
  443. Joined[playerid] = false;
  444. DestroyVehicle(CreatedRaceVeh[playerid]);
  445. DisablePlayerRaceCheckpoint(playerid);
  446. TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
  447. CPProgess[playerid] = 0;
  448. KillTimer(InfoTimer[playerid]);
  449. TogglePlayerControllable(playerid, true);
  450. SetCameraBehindPlayer(playerid);
  451. #if defined RACE_IN_OTHER_WORLD
  452. SetPlayerVirtualWorld(playerid, 0);
  453. #endif
  454. } else return SendClientMessage(playerid, RED, "<!> No estas en una carrera!");
  455. return 1;
  456. }
  457.  
  458. public OnPlayerEnterRaceCheckpoint(playerid)
  459. {
  460. if(CPProgess[playerid] == TotalCP -1)
  461. {
  462. new
  463. TimeStamp,
  464. TotalRaceTime,
  465. string[256],
  466. rFile[256],
  467. pName[MAX_PLAYER_NAME],
  468. rTime[3],
  469. Prize[2],
  470. TempTotalTime,
  471. TempTime[3]
  472. ;
  473. Position++;
  474. GetPlayerName(playerid, pName, sizeof(pName));
  475. TimeStamp = GetTickCount();
  476. TotalRaceTime = TimeStamp - RaceTick;
  477. ConvertTime(var, TotalRaceTime, rTime[0], rTime[1], rTime[2]);
  478. switch(Position)
  479. {
  480. case 1: Prize[0] = (random(random(5000)) + 10000), Prize[1] = 10;
  481. case 2: Prize[0] = (random(random(4500)) + 9000), Prize[1] = 9;
  482. case 3: Prize[0] = (random(random(4000)) + 8000), Prize[1] = 8;
  483. case 4: Prize[0] = (random(random(3500)) + 7000), Prize[1] = 7;
  484. case 5: Prize[0] = (random(random(3000)) + 6000), Prize[1] = 6;
  485. case 6: Prize[0] = (random(random(2500)) + 5000), Prize[1] = 5;
  486. case 7: Prize[0] = (random(random(2000)) + 4000), Prize[1] = 4;
  487. case 8: Prize[0] = (random(random(1500)) + 3000), Prize[1] = 3;
  488. case 9: Prize[0] = (random(random(1000)) + 2000), Prize[1] = 2;
  489. default: Prize[0] = random(random(1000)), Prize[1] = 1;
  490. }
  491. format(string, sizeof(string), ">> \"%s\" Termino la carrera en Posicion \"%d\".", pName, Position);
  492. SendClientMessageToAll(WHITE, string);
  493. format(string, sizeof(string), ">> Tiempo: \"%d:%d.%d\".", rTime[0], rTime[1], rTime[2]);
  494. SendClientMessageToAll(WHITE, string);
  495.  
  496. if(FinishCount <= 5)
  497. {
  498. format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", RaceName);
  499. format(string, sizeof(string), "BestRacerTime_%d", TimeProgress);
  500. TempTotalTime = dini_Int(rFile, string);
  501. ConvertTime(var1, TempTotalTime, TempTime[0], TempTime[1], TempTime[2]);
  502. if(TotalRaceTime <= dini_Int(rFile, string) || TempTotalTime == 0)
  503. {
  504. dini_IntSet(rFile, string, TotalRaceTime);
  505. format(string, sizeof(string), "BestRacer_%d", TimeProgress);
  506. if(TempTotalTime != 0) format(string, sizeof(string), ">> \"%s\" Ha rompido el record de \"%s\" con \"%d\" Segundos Menos en la Posicion \"%d\"'!", pName, dini_Get(rFile, string), -(rTime[1] - TempTime[1]), TimeProgress+1);
  507. else format(string, sizeof(string), ">> \"%s\" Ha rompido un Nuevo Record! en \"%d\"'Lugar!", pName, TimeProgress+1);
  508. SendClientMessageToAll(GREEN, " ");
  509. SendClientMessageToAll(GREEN, string);
  510. SendClientMessageToAll(GREEN, " ");
  511. format(string, sizeof(string), "BestRacer_%d", TimeProgress);
  512. dini_Set(rFile, string, pName);
  513. TimeProgress++;
  514. }
  515. }
  516. FinishCount++;
  517. GivePlayerMoney(playerid, Prize[0]);
  518. DisablePlayerRaceCheckpoint(playerid);
  519. CPProgess[playerid]++;
  520. if(FinishCount >= JoinCount) return StopRace();
  521. }
  522. else
  523. {
  524. CPProgess[playerid]++;
  525. CPCoords[CPProgess[playerid]][3]++;
  526. RacePosition[playerid] = floatround(CPCoords[CPProgess[playerid]][3], floatround_floor);
  527. SetCP(playerid, CPProgess[playerid], CPProgess[playerid]+1, TotalCP, RaceType);
  528. PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0);
  529. }
  530. return 1;
  531. }
  532.  
  533. public OnPlayerDisconnect(playerid)
  534. {
  535. if(Joined[playerid] == true)
  536. {
  537. JoinCount--;
  538. Joined[playerid] = false;
  539. DestroyVehicle(CreatedRaceVeh[playerid]);
  540. DisablePlayerRaceCheckpoint(playerid);
  541. TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
  542. CPProgess[playerid] = 0;
  543. KillTimer(InfoTimer[playerid]);
  544. #if defined RACE_IN_OTHER_WORLD
  545. SetPlayerVirtualWorld(playerid, 0);
  546. #endif
  547. }
  548. TextDrawDestroy(RaceInfo[playerid]);
  549. if(BuildRace == playerid+1) BuildRace = 0;
  550. return 1;
  551. }
  552.  
  553. public OnPlayerConnect(playerid)
  554. {
  555. RaceInfo[playerid] = TextDrawCreate(633.000000, 348.000000, " ");
  556. TextDrawAlignment(RaceInfo[playerid], 3);
  557. TextDrawBackgroundColor(RaceInfo[playerid], 255);
  558. TextDrawFont(RaceInfo[playerid], 1);
  559. TextDrawLetterSize(RaceInfo[playerid], 0.240000, 1.100000);
  560. TextDrawColor(RaceInfo[playerid], -687931137);
  561. TextDrawSetOutline(RaceInfo[playerid], 0);
  562. TextDrawSetProportional(RaceInfo[playerid], 1);
  563. TextDrawSetShadow(RaceInfo[playerid], 1);
  564. return 1;
  565. }
  566.  
  567. public OnPlayerDeath(playerid)
  568. {
  569. if(Joined[playerid] == true)
  570. {
  571. JoinCount--;
  572. Joined[playerid] = false;
  573. DestroyVehicle(CreatedRaceVeh[playerid]);
  574. DisablePlayerRaceCheckpoint(playerid);
  575. TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
  576. CPProgess[playerid] = 0;
  577. KillTimer(InfoTimer[playerid]);
  578. #if defined RACE_IN_OTHER_WORLD
  579. SetPlayerVirtualWorld(playerid, 0);
  580. #endif
  581. }
  582. if(BuildRace == playerid+1) BuildRace = 0;
  583. return 1;
  584. }
  585.  
  586. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  587. {
  588. switch(dialogid)
  589. {
  590. case 599:
  591. {
  592. if(!response) return BuildRace = 0;
  593. switch(listitem)
  594. {
  595. case 0: BuildRaceType = 0;
  596. case 1: BuildRaceType = 3;
  597. }
  598. ShowDialog(playerid, 600);
  599. }
  600. case 600..601:
  601. {
  602. if(!response) return ShowDialog(playerid, 599);
  603. if(!strlen(inputtext)) return ShowDialog(playerid, 601);
  604. if(strlen(inputtext) < 1 || strlen(inputtext) > 20) return ShowDialog(playerid, 601);
  605. strmid(BuildName, inputtext, 0, strlen(inputtext), sizeof(BuildName));
  606. ShowDialog(playerid, 602);
  607. }
  608. case 602..603:
  609. {
  610. if(!response) return ShowDialog(playerid, 600);
  611. if(!strlen(inputtext)) return ShowDialog(playerid, 603);
  612. if(isNumeric(inputtext))
  613. {
  614.  
  615. if(!IsValidVehicle(strval(inputtext))) return ShowDialog(playerid, 603);
  616. new
  617. Float: pPos[4]
  618. ;
  619. GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  620. GetPlayerFacingAngle(playerid, pPos[3]);
  621. BuildModeVID = strval(inputtext);
  622. BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
  623. BuildVehicle = CreateVehicle(strval(inputtext), pPos[0], pPos[1], pPos[2], pPos[3], random(126), random(126), (60 * 60));
  624. PutPlayerInVehicle(playerid, BuildVehicle, 0);
  625. BuildCreatedVehicle = 0x01;
  626. ShowDialog(playerid, 604);
  627. }
  628. else
  629. {
  630. if(!IsValidVehicle(ReturnVehicleID(inputtext))) return ShowDialog(playerid, 603);
  631. new
  632. Float: pPos[4]
  633. ;
  634. GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  635. GetPlayerFacingAngle(playerid, pPos[3]);
  636. BuildModeVID = ReturnVehicleID(inputtext);
  637. BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
  638. BuildVehicle = CreateVehicle(ReturnVehicleID(inputtext), pPos[0], pPos[1], pPos[2], pPos[3], random(126), random(126), (60 * 60));
  639. PutPlayerInVehicle(playerid, BuildVehicle, 0);
  640. BuildCreatedVehicle = 0x01;
  641. ShowDialog(playerid, 604);
  642. }
  643. }
  644. case 604:
  645. {
  646. if(!response) return ShowDialog(playerid, 602);
  647. SendClientMessage(playerid, GREEN, ">> Ir a la línea de salida en la carretera a la izquierda y pulse 'KEY_FIRE' y hacer lo mismo con la Derecha!.");
  648. SendClientMessage(playerid, GREEN, " - When this is done, you will see a dialog to continue.");
  649. BuildVehPosCount = 0;
  650. BuildTakeVehPos = true;
  651. }
  652. case 605:
  653. {
  654. if(!response) return ShowDialog(playerid, 604);
  655. SendClientMessage(playerid, GREEN, ">> Comience a tomar los puestos de control ahora haciendo click 'KEY_FIRE'.");
  656. SendClientMessage(playerid, GREEN, " - Presione 'ENTER' cuando haya terminado con los puntos de control: IMPORTANTE! Si no reacciona de aprete otra vez.");
  657. BuildCheckPointCount = 0;
  658. BuildTakeCheckpoints = true;
  659. }
  660. case 606:
  661. {
  662. if(!response) return ShowDialog(playerid, 606);
  663. BuildRace = 0;
  664. BuildCheckPointCount = 0;
  665. BuildVehPosCount = 0;
  666. BuildTakeCheckpoints = false;
  667. BuildTakeVehPos = false;
  668. BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
  669. }
  670. }
  671. return 1;
  672. }
  673.  
  674. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  675. {
  676. new
  677. string[256],
  678. rNameFile[256],
  679. rFile[256],
  680. Float: vPos[4]
  681. ;
  682. if(newkeys & KEY_FIRE)
  683. {
  684. if(BuildRace == playerid+1)
  685. {
  686. if(BuildTakeVehPos == true)
  687. {
  688. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, ">> You need to be in a vehicle");
  689. format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", BuildName);
  690. GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
  691. GetVehicleZAngle(GetPlayerVehicleID(playerid), vPos[3]);
  692. dini_Create(rFile);
  693. dini_IntSet(rFile, "vModel", BuildModeVID);
  694. dini_IntSet(rFile, "rType", BuildRaceType);
  695. format(string, sizeof(string), "vPosX_%d", BuildVehPosCount), dini_FloatSet(rFile, string, vPos[0]);
  696. format(string, sizeof(string), "vPosY_%d", BuildVehPosCount), dini_FloatSet(rFile, string, vPos[1]);
  697. format(string, sizeof(string), "vPosZ_%d", BuildVehPosCount), dini_FloatSet(rFile, string, vPos[2]);
  698. format(string, sizeof(string), "vAngle_%d", BuildVehPosCount), dini_FloatSet(rFile, string, vPos[3]);
  699. format(string, sizeof(string), ">> Posicion del Vehiculo N° '%d' Bien Puesta!.", BuildVehPosCount+1);
  700. SendClientMessage(playerid, YELLOW, string);
  701. BuildVehPosCount++;
  702. }
  703. if(BuildVehPosCount >= 2)
  704. {
  705. BuildVehPosCount = 0;
  706. BuildTakeVehPos = false;
  707. ShowDialog(playerid, 605);
  708. }
  709. if(BuildTakeCheckpoints == true)
  710. {
  711. if(BuildCheckPointCount > MAX_RACE_CHECKPOINTS_EACH_RACE) return SendClientMessage(playerid, RED, ">> You reached the maximum amount of checkpoints!");
  712. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, ">> You need to be in a vehicle");
  713. format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", BuildName);
  714. GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
  715. format(string, sizeof(string), "CP_%d_PosX", BuildCheckPointCount), dini_FloatSet(rFile, string, vPos[0]);
  716. format(string, sizeof(string), "CP_%d_PosY", BuildCheckPointCount), dini_FloatSet(rFile, string, vPos[1]);
  717. format(string, sizeof(string), "CP_%d_PosZ", BuildCheckPointCount), dini_FloatSet(rFile, string, vPos[2]);
  718. format(string, sizeof(string), ">> Checkpoint '%d' Bien Colocado!", BuildCheckPointCount+1);
  719. SendClientMessage(playerid, YELLOW, string);
  720. BuildCheckPointCount++;
  721. }
  722. }
  723. }
  724. if(newkeys & KEY_SECONDARY_ATTACK)
  725. {
  726. if(BuildTakeCheckpoints == true)
  727. {
  728. ShowDialog(playerid, 606);
  729. format(rNameFile, sizeof(rNameFile), "/rRaceSystem/RaceNames/RaceNames.txt");
  730. TotalRaces = dini_Int(rNameFile, "TotalRaces");
  731. TotalRaces++;
  732. dini_IntSet(rNameFile, "TotalRaces", TotalRaces);
  733. format(string, sizeof(string), "Race_%d", TotalRaces-1);
  734. format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", BuildName);
  735. dini_Set(rNameFile, string, BuildName);
  736. dini_IntSet(rFile, "TotalCP", BuildCheckPointCount);
  737. Loop(x, 5)
  738. {
  739. format(string, sizeof(string), "BestRacerTime_%d", x);
  740. dini_Set(rFile, string, "0");
  741. format(string, sizeof(string), "BestRacer_%d", x);
  742. dini_Set(rFile, string, "noone");
  743. }
  744. }
  745. }
  746. return 1;
  747. }
  748.  
  749. function LoadRaceNames()
  750. {
  751. new
  752. rNameFile[64],
  753. string[64]
  754. ;
  755. format(rNameFile, sizeof(rNameFile), "/rRaceSystem/RaceNames/RaceNames.txt");
  756. TotalRaces = dini_Int(rNameFile, "TotalRaces");
  757. Loop(x, TotalRaces)
  758. {
  759. format(string, sizeof(string), "Race_%d", x), strmid(RaceNames[x], dini_Get(rNameFile, string), 0, 20, sizeof(RaceNames));
  760. printf(">> Loaded Races: %s", RaceNames[x]);
  761. }
  762. return 1;
  763. }
  764.  
  765. function LoadAutoRace(rName[])
  766. {
  767. new
  768. rFile[256],
  769. string[256]
  770. ;
  771. format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", rName);
  772. if(!dini_Exists(rFile)) return printf("Race \"%s\" doesn't exist!", rName);
  773. strmid(RaceName, rName, 0, strlen(rName), sizeof(RaceName));
  774. RaceVehicle = dini_Int(rFile, "vModel");
  775. RaceType = dini_Int(rFile, "rType");
  776. TotalCP = dini_Int(rFile, "TotalCP");
  777.  
  778. #if DEBUG_RACE == 1
  779. printf("VehicleModel: %d", RaceVehicle);
  780. printf("RaceType: %d", RaceType);
  781. printf("TotalCheckpoints: %d", TotalCP);
  782. #endif
  783.  
  784. Loop(x, 2)
  785. {
  786. format(string, sizeof(string), "vPosX_%d", x), RaceVehCoords[x][0] = dini_Float(rFile, string);
  787. format(string, sizeof(string), "vPosY_%d", x), RaceVehCoords[x][1] = dini_Float(rFile, string);
  788. format(string, sizeof(string), "vPosZ_%d", x), RaceVehCoords[x][2] = dini_Float(rFile, string);
  789. format(string, sizeof(string), "vAngle_%d", x), RaceVehCoords[x][3] = dini_Float(rFile, string);
  790. #if DEBUG_RACE == 1
  791. printf("VehiclePos %d: %f, %f, %f, %f", x, RaceVehCoords[x][0], RaceVehCoords[x][1], RaceVehCoords[x][2], RaceVehCoords[x][3]);
  792. #endif
  793. }
  794. Loop(x, TotalCP)
  795. {
  796. format(string, sizeof(string), "CP_%d_PosX", x), CPCoords[x][0] = dini_Float(rFile, string);
  797. format(string, sizeof(string), "CP_%d_PosY", x), CPCoords[x][1] = dini_Float(rFile, string);
  798. format(string, sizeof(string), "CP_%d_PosZ", x), CPCoords[x][2] = dini_Float(rFile, string);
  799. #if DEBUG_RACE == 1
  800. printf("RaceCheckPoint %d: %f, %f, %f", x, CPCoords[x][0], CPCoords[x][1], CPCoords[x][2]);
  801. #endif
  802. }
  803. Position = 0;
  804. FinishCount = 0;
  805. JoinCount = 0;
  806. Loop(x, 2) PlayersCount[x] = 0;
  807. CountAmount = COUNT_DOWN_TILL_RACE_START;
  808. RaceTime = MAX_RACE_TIME;
  809. RaceBusy = 0x01;
  810. CountTimer = SetTimer("CountTillRace", 999, 1);
  811. TimeProgress = 0;
  812. return 1;
  813. }
  814.  
  815. function LoadRace(playerid, rName[])
  816. {
  817. new
  818. rFile[256],
  819. string[256]
  820. ;
  821. format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", rName);
  822. if(!dini_Exists(rFile)) return SendClientMessage(playerid, RED, "<!> Race doesn't exist!"), printf("Race \"%s\" doesn't exist!", rName);
  823. strmid(RaceName, rName, 0, strlen(rName), sizeof(RaceName));
  824. RaceVehicle = dini_Int(rFile, "vModel");
  825. RaceType = dini_Int(rFile, "rType");
  826. TotalCP = dini_Int(rFile, "TotalCP");
  827.  
  828. #if DEBUG_RACE == 1
  829. printf("VehicleModel: %d", RaceVehicle);
  830. printf("RaceType: %d", RaceType);
  831. printf("TotalCheckpoints: %d", TotalCP);
  832. #endif
  833.  
  834. Loop(x, 2)
  835. {
  836. format(string, sizeof(string), "vPosX_%d", x), RaceVehCoords[x][0] = dini_Float(rFile, string);
  837. format(string, sizeof(string), "vPosY_%d", x), RaceVehCoords[x][1] = dini_Float(rFile, string);
  838. format(string, sizeof(string), "vPosZ_%d", x), RaceVehCoords[x][2] = dini_Float(rFile, string);
  839. format(string, sizeof(string), "vAngle_%d", x), RaceVehCoords[x][3] = dini_Float(rFile, string);
  840. #if DEBUG_RACE == 1
  841. printf("VehiclePos %d: %f, %f, %f, %f", x, RaceVehCoords[x][0], RaceVehCoords[x][1], RaceVehCoords[x][2], RaceVehCoords[x][3]);
  842. #endif
  843. }
  844. Loop(x, TotalCP)
  845. {
  846. format(string, sizeof(string), "CP_%d_PosX", x), CPCoords[x][0] = dini_Float(rFile, string);
  847. format(string, sizeof(string), "CP_%d_PosY", x), CPCoords[x][1] = dini_Float(rFile, string);
  848. format(string, sizeof(string), "CP_%d_PosZ", x), CPCoords[x][2] = dini_Float(rFile, string);
  849. #if DEBUG_RACE == 1
  850. printf("RaceCheckPoint %d: %f, %f, %f", x, CPCoords[x][0], CPCoords[x][1], CPCoords[x][2]);
  851. #endif
  852. }
  853. Position = 0;
  854. FinishCount = 0;
  855. JoinCount = 0;
  856. Loop(x, 2) PlayersCount[x] = 0;
  857. Joined[playerid] = true;
  858. CountAmount = COUNT_DOWN_TILL_RACE_START;
  859. RaceTime = MAX_RACE_TIME;
  860. RaceBusy = 0x01;
  861. TimeProgress = 0;
  862. SetupRaceForPlayer(playerid);
  863. CountTimer = SetTimer("CountTillRace", 999, 1);
  864. return 1;
  865. }
  866.  
  867. function SetCP(playerid, PrevCP, NextCP, MaxCP, Type)
  868. {
  869. if(Type == 0)
  870. {
  871. if(NextCP == MaxCP) SetPlayerRaceCheckpoint(playerid, 1, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], RACE_CHECKPOINT_SIZE);
  872. else SetPlayerRaceCheckpoint(playerid, 0, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], RACE_CHECKPOINT_SIZE);
  873. }
  874. else if(Type == 3)
  875. {
  876. if(NextCP == MaxCP) SetPlayerRaceCheckpoint(playerid, 4, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], RACE_CHECKPOINT_SIZE);
  877. else SetPlayerRaceCheckpoint(playerid, 3, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], RACE_CHECKPOINT_SIZE);
  878. }
  879. return 1;
  880. }
  881.  
  882. function SetupRaceForPlayer(playerid)
  883. {
  884. CPProgess[playerid] = 0;
  885. TogglePlayerControllable(playerid, false);
  886. CPCoords[playerid][3] = 0;
  887. SetCP(playerid, CPProgess[playerid], CPProgess[playerid]+1, TotalCP, RaceType);
  888. if(IsOdd(playerid)) Index = 1;
  889. else Index = 0;
  890.  
  891. switch(Index)
  892. {
  893. case 0:
  894. {
  895. if(PlayersCount[0] == 1)
  896. {
  897. RaceVehCoords[0][0] -= (6 * floatsin(-RaceVehCoords[0][3], degrees));
  898. RaceVehCoords[0][1] -= (6 * floatcos(-RaceVehCoords[0][3], degrees));
  899. CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicle, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2, RaceVehCoords[0][3], random(126), random(126), (60 * 60));
  900. SetPlayerPos(playerid, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2);
  901. SetPlayerFacingAngle(playerid, RaceVehCoords[0][3]);
  902. PutPlayerInVehicle(playerid, CreatedRaceVeh[playerid], 0);
  903. Camera(playerid, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2], RaceVehCoords[0][3], 20);
  904. }
  905. }
  906. case 1:
  907. {
  908. if(PlayersCount[1] == 1)
  909. {
  910. RaceVehCoords[1][0] -= (6 * floatsin(-RaceVehCoords[1][3], degrees));
  911. RaceVehCoords[1][1] -= (6 * floatcos(-RaceVehCoords[1][3], degrees));
  912. CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicle, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2, RaceVehCoords[1][3], random(126), random(126), (60 * 60));
  913. SetPlayerPos(playerid, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2);
  914. SetPlayerFacingAngle(playerid, RaceVehCoords[1][3]);
  915. PutPlayerInVehicle(playerid, CreatedRaceVeh[playerid], 0);
  916. Camera(playerid, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2], RaceVehCoords[1][3], 20);
  917. }
  918. }
  919. }
  920. switch(Index)
  921. {
  922. case 0:
  923. {
  924. if(PlayersCount[0] != 1)
  925. {
  926. CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicle, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2, RaceVehCoords[0][3], random(126), random(126), (60 * 60));
  927. SetPlayerPos(playerid, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2);
  928. SetPlayerFacingAngle(playerid, RaceVehCoords[0][3]);
  929. PutPlayerInVehicle(playerid, CreatedRaceVeh[playerid], 0);
  930. Camera(playerid, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2], RaceVehCoords[0][3], 20);
  931. PlayersCount[0] = 1;
  932. }
  933. }
  934. case 1:
  935. {
  936. if(PlayersCount[1] != 1)
  937. {
  938. CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicle, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2, RaceVehCoords[1][3], random(126), random(126), (60 * 60));
  939. SetPlayerPos(playerid, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2);
  940. SetPlayerFacingAngle(playerid, RaceVehCoords[1][3]);
  941. PutPlayerInVehicle(playerid, CreatedRaceVeh[playerid], 0);
  942. Camera(playerid, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2], RaceVehCoords[1][3], 20);
  943. PlayersCount[1] = 1;
  944. }
  945. }
  946. }
  947. new
  948. string[128]
  949. ;
  950. #if defined RACE_IN_OTHER_WORLD
  951. SetPlayerVirtualWorld(playerid, 10);
  952. #endif
  953. InfoTimer[playerid] = SetTimerEx("TextInfo", 500, 1, "e", playerid);
  954. if(JoinCount == 1) format(string, sizeof(string), "RaceName: ~w~%s~n~~p~~h~Checkpoint: ~w~%d/%d~n~~b~~h~RaceTime: ~w~%s~n~~y~RacePosition: ~w~1/1~n~ ", RaceName, CPProgess[playerid], TotalCP, TimeConvert(RaceTime));
  955. else format(string, sizeof(string), "RaceName: ~w~%s~n~~p~~h~Checkpoint: ~w~%d/%d~n~~b~~h~RaceTime: ~w~%s~n~~y~RacePosition: ~w~%d/%d~n~ ", RaceName, CPProgess[playerid], TotalCP, TimeConvert(RaceTime), RacePosition[playerid], JoinCount);
  956. TextDrawSetString(RaceInfo[playerid], string);
  957. TextDrawShowForPlayer(playerid, RaceInfo[playerid]);
  958. JoinCount++;
  959. return 1;
  960. }
  961.  
  962. function CountTillRace()
  963. {
  964. switch(CountAmount)
  965. {
  966. case 0:
  967. {
  968. ForEach(i, MAX_PLAYERS)
  969. {
  970. if(Joined[i] == false)
  971. {
  972. }
  973. }
  974. StartRace();
  975. }
  976. case 1..5:
  977. {
  978. new
  979. string[10]
  980. ;
  981. format(string, sizeof(string), "~b~%d", CountAmount);
  982. ForEach(i, MAX_PLAYERS)
  983. {
  984. if(Joined[i] == true)
  985. {
  986. GameTextForPlayer(i, string, 999, 5);
  987. PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
  988. }
  989. }
  990. }
  991. case 60, 50, 40, 30, 20, 10:
  992. {
  993. new
  994. string[128];
  995. format(string, sizeof(string), "{00FF00}>> En \"%d\" Segundos La Carrera {CC00FF}\"%s\" {00FF00}Empieza! Escribi \"/join\" Para Entrar!.", CountAmount, RaceName);
  996. SendClientMessageToAll(GREEN, string);
  997. }
  998. }
  999. return CountAmount--;
  1000. }
  1001.  
  1002. function StartRace()
  1003. {
  1004. ForEach(i, MAX_PLAYERS)
  1005. {
  1006. if(Joined[i] == true)
  1007. {
  1008. TogglePlayerControllable(i, true);
  1009. PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
  1010. GameTextForPlayer(i, "~g~~h~~h~GO ~r~~h~~h~GO ~p~GO", 2000, 5);
  1011. SetCameraBehindPlayer(i);
  1012. }
  1013. }
  1014. rCounter = SetTimer("RaceCounter", 900, 1);
  1015. RaceTick = GetTickCount();
  1016. RaceStarted = 1;
  1017. KillTimer(CountTimer);
  1018. return 1;
  1019. }
  1020.  
  1021. function StopRace()
  1022. {
  1023. KillTimer(rCounter);
  1024. RaceStarted = 0;
  1025. RaceTick = 0;
  1026. RaceBusy = 0x00;
  1027. JoinCount = 0;
  1028. FinishCount = 0;
  1029. TimeProgress = 0;
  1030.  
  1031. ForEach(i, MAX_PLAYERS)
  1032. {
  1033. if(Joined[i] == true)
  1034. {
  1035. DisablePlayerRaceCheckpoint(i);
  1036. DestroyVehicle(CreatedRaceVeh[i]);
  1037. Joined[i] = false;
  1038. TextDrawHideForPlayer(i, RaceInfo[i]);
  1039. CPProgess[i] = 0;
  1040. KillTimer(InfoTimer[i]);
  1041. }
  1042. }
  1043. if(AutomaticRace == true) LoadRaceNames(), LoadAutoRace(RaceNames[random(TotalRaces)]);
  1044. return 1;
  1045. }
  1046.  
  1047. function RaceCounter()
  1048. {
  1049. if(RaceStarted == 1)
  1050. {
  1051. RaceTime--;
  1052. if(JoinCount <= 0)
  1053. {
  1054. StopRace();
  1055. }
  1056. }
  1057. if(RaceTime <= 0)
  1058. {
  1059. StopRace();
  1060. }
  1061. return 1;
  1062. }
  1063.  
  1064. function TextInfo(playerid)
  1065. {
  1066. new
  1067. string[128]
  1068. ;
  1069. if(JoinCount == 1) format(string, sizeof(string), "RaceName: ~w~%s~n~~p~~h~Checkpoint: ~w~%d/%d~n~~b~~h~RaceTime: ~w~%s~n~~y~RacePosition: ~w~1/1~n~", RaceName, CPProgess[playerid], TotalCP, TimeConvert(RaceTime));
  1070. else format(string, sizeof(string), "RaceName: ~w~%s~n~~p~~h~Checkpoint: ~w~%d/%d~n~~b~~h~RaceTime: ~w~%s~n~~y~RacePosition: ~w~%d/%d~n~", RaceName, CPProgess[playerid], TotalCP, TimeConvert(RaceTime), RacePosition[playerid], JoinCount);
  1071. TextDrawSetString(RaceInfo[playerid], string);
  1072. TextDrawShowForPlayer(playerid, RaceInfo[playerid]);
  1073. }
  1074.  
  1075. function Camera(playerid, Float:X, Float:Y, Float:Z, Float:A, Mul)
  1076. {
  1077. SetPlayerCameraLookAt(playerid, X, Y, Z);
  1078. SetPlayerCameraPos(playerid, X + (Mul * floatsin(-A, degrees)), Y + (Mul * floatcos(-A, degrees)), Z+6);
  1079. }
  1080.  
  1081. function IsPlayerInRace(playerid)
  1082. {
  1083. if(Joined[playerid] == true) return true;
  1084. else return false;
  1085. }
  1086.  
  1087. function ShowDialog(playerid, dialogid)
  1088. {
  1089. switch(dialogid)
  1090. {
  1091. case 599: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, CreateCaption("Build New Race"), "\
  1092. Normal Race\n\
  1093. Air Race", "Next", "Exit");
  1094.  
  1095. case 600: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Build New Race (Step 1/4)"), "\
  1096. Step 1:\n\
  1097. ********\n\
  1098. Welcome to wizard 'Build New Race'.\n\
  1099. Before getting started, I need to know the name (e.g. SFRace) of the to save it under.\n\n\
  1100. >> Give the NAME below and press 'Next' to continue.", "Next", "Back");
  1101.  
  1102. case 601: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Build New Race (Step 1/4)"), "\
  1103. ERROR: Name too short or too long! (min. 1 - max. 20)\n\n\n\
  1104. Step 1:\n\
  1105. ********\n\
  1106. Welcome to wizard 'Build New Race'.\n\
  1107. Before getting started, I need to know the name (e.g. SFRace) of the to save it under.\n\n\
  1108. >> Give the NAME below and press 'Next' to continue.", "Next", "Back");
  1109.  
  1110. case 602: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Build New Race (Step 2/4)"), "\
  1111. Step 2:\n\
  1112. ********\n\
  1113. Please give the ID or NAME of the vehicle that's going to be used in the race you are creating now.\n\n\
  1114. >> Give the ID or NAME of the vehicle below and press 'Next' to continue. 'Back' to change something.", "Next", "Back");
  1115.  
  1116. case 603: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Build New Race (Step 2/4)"), "\
  1117. ERROR: Invalid Vehilce ID/Name\n\n\n\
  1118. Step 2:\n\
  1119. ********\n\
  1120. Please give the ID or NAME of the vehicle that's going to be used in the race you are creating now.\n\n\
  1121. >> Give the ID or NAME of the vehicle below and press 'Next' to continue. 'Back' to change something.", "Next", "Back");
  1122.  
  1123. case 604: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Build New Race (Step 3/4)"),
  1124. "\
  1125. Step 3:\n\
  1126. ********\n\
  1127. We are almost done! Now go to the start line where the first and second car should stand.\n\
  1128. Note: When you click 'OK' you will be free. Use 'KEY_FIRE' to set the first position and second position.\n\
  1129. Note: After you got these positions you will automaticly see a dialog to continue the wizard.\n\n\
  1130. >> Press 'OK' to do the things above. 'Back' to change something.", "OK", "Back");
  1131.  
  1132. case 605: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Build New Race (Step 4/4)"),
  1133. "\
  1134. Step 4:\n\
  1135. ********\n\
  1136. Welcome to the last stap. In this stap you have to set the checkpoints; so if you click 'OK' you can set the checkpoints.\n\
  1137. You can set the checkpoints with 'KEY_FIRE'. Each checkpoint you set will save.\n\
  1138. You have to press 'ENTER' button when you're done with everything. You race is aviable then!\n\n\
  1139. >> Press 'OK' to do the things above. 'Back' to change something.", "OK", "Back");
  1140.  
  1141. case 606: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Build New Race (Done)"),
  1142. "\
  1143. You have created your race and it's ready to use now.\n\n\
  1144. >> Press 'Finish' to finish. 'Exit' - Has no effect.", "Finish", "Exit");
  1145. }
  1146. return 1;
  1147. }
  1148.  
  1149. CreateCaption(arguments[])
  1150. {
  1151. new
  1152. string[128 char]
  1153. ;
  1154. format(string, sizeof(string), "RyDeR's Race System - %s", arguments);
  1155. return string;
  1156. }
  1157.  
  1158. stock IsValidVehicle(vehicleid)
  1159. {
  1160. if(vehicleid < 400 || vehicleid > 611) return false;
  1161. else return true;
  1162. }
  1163.  
  1164. ReturnVehicleID(vName[])
  1165. {
  1166. Loop(x, 211)
  1167. {
  1168. if(strfind(vNames[x], vName, true) != -1)
  1169. return x + 400;
  1170. }
  1171. return -1;
  1172. }
  1173.  
  1174. TimeConvert(seconds)
  1175. {
  1176. new tmp[16];
  1177. new minutes = floatround(seconds/60);
  1178. seconds -= minutes*60;
  1179. format(tmp, sizeof(tmp), "%d:%02d", minutes, seconds);
  1180. return tmp;
  1181. }
  1182.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement