y_races.inc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**--------------------------------------------------------------------------**\
  2. ==============================
  3. y_hooks - Hook any callback!
  4. ==============================
  5. Description:
  6. Automatically hooks any callbacks with a very simple syntax.
  7. Legal:
  8. Version: MPL 1.1
  9. The contents of this file are subject to the Mozilla Public License Version
  10. 1.1 (the "License"); you may not use this file except in compliance with
  11. the License. You may obtain a copy of the License at
  12. http://www.mozilla.org/MPL/
  13. Software distributed under the License is distributed on an "AS IS" basis,
  14. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  15. for the specific language governing rights and limitations under the
  16. License.
  17. The Original Code is the SA:MP callback hooks include.
  18. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  19. Portions created by the Initial Developer are Copyright (C) 2008
  20. the Initial Developer. All Rights Reserved.
  21. Contributors:
  22. ZeeX, koolk, JoeBullet/Google63, g_aSlice/Slice
  23. Thanks:
  24. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  25. Peter, Cam - Support.
  26. ZeeX, g_aSlice/Slice, Popz, others - Very productive conversations.
  27. koolk - IsPlayerinAreaEx code.
  28. TheAlpha - Danish translation.
  29. breadfish - German translation.
  30. Fireburn - Dutch translation.
  31. yom - French translation.
  32. 50p - Polish translation.
  33. Zamaroht - Spanish translation.
  34. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  35. for me to strive to better.
  36. Pixels^ - Running XScripters where the idea was born.
  37. Matite - Pestering me to release it and using it.
  38. Very special thanks to:
  39. Thiadmer - PAWN, whose limits continue to amaze me!
  40. Kye/Kalcor - SA:MP.
  41. SA:MP Team past, present and future - SA:MP.
  42. Version:
  43. 2.0
  44. Changelog:
  45. 25/02/12:
  46. Extracted most of the code to a separate file.
  47. 17/03/11:
  48. Second complete re-write using another new technique. Now VERY fast!
  49. Updated OnPlayerUpdate code using Google63's SCTRL jump code.
  50. 06/08/10:
  51. First version
  52. </remarks>
  53. \**--------------------------------------------------------------------------**/
  54. #if !defined _inc_y_races
  55. #error Did you do <YSI/y_races> instead of the required <YSI\y_races>?
  56. #endif
  57. #if !defined YSI_NO_RACE_POSITION && !defined RACE_POSITION
  58. #define RACE_POSITION
  59. #endif
  60. #if defined YSI_TESTS
  61. #define _Y_RACES_STATIC
  62. #else
  63. #define _Y_RACES_STATIC static
  64. #endif
  65. #include "y_text"
  66. #include "y_bit"
  67. #include "y_iterate"
  68. #include "y_playerarray"
  69. #if defined RACE_POSITION
  70. #include "y_timers"
  71. #endif
  72. #include "y_hooks"
  73. #if !defined MAX_RACES
  74. #define MAX_RACES 16
  75. #endif
  76. #define _GROUP_MAKE_NAME_RACES<%0...%1> %0Race%1
  77. #define _GROUP_MAKE_LIMIT_RACES MAX_RACES
  78. #define YSIM_U_DISABLE
  79. #include "y_master"
  80. #include "y_groups"
  81. forward Race_Create(laps = 0, entry = 0, countdown = 3, bool:arial = false, bool:fixedPrize = true, exitTime = 0, interior = 0, world = 0, bool:restart = false);
  82. forward Race_Destroy(slot, bool:refund = false);
  83. foreign Race_AddCheckpoint(raceid, Float:x, Float:y, Float:z);
  84. foreign Race_AddStart(raceid, Float:x, Float:y, Float:z, Float:a);
  85. foreign void:Race_SetFixedWin(raceid, set);
  86. foreign void:Race_SetRestart(raceid, set);
  87. foreign void:Race_SetArial(raceid, set);
  88. foreign void:Race_SetCountdown(raceid, countdown);
  89. foreign void:Race_SetInterior(raceid, interior);
  90. foreign void:Race_SetWorld(raceid, world);
  91. foreign void:Race_SetPrize(raceid, position, amount);
  92. foreign void:Race_SetExitTime(raceid, time);
  93. foreign Race_IsActive(raceid);
  94. foreign void:Race_SetLaps(raceid, laps);
  95. foreign void:Race_SetEntry(raceid, cost);
  96. foreign Race_GetPlayerExitedTime(playerid);
  97. foreign Race_PlayerJoin(playerid, race);
  98. forward Race_PlayerLeave(playerid, bool:refund = false);
  99. foreign Race_Start(race);
  100. foreign Race_GetPlayerPosition(playerid);
  101. foreign Race_GetPlayerRaceTime(playerid);
  102. foreign Race_GetPlayerRace(playerid);
  103. foreign Race_SetPlayer(race, playerid, bool:set);
  104. #include "y_races/impl"
  105. #if defined YSI_TESTS
  106. #include "y_testing"
  107. #include "y_races/tests"
  108. // Get some new IDs.
  109. #endif
  110. #include "internal\y_grouprevert"