y_races.inc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. \**--------------------------------------------------------------------------**/
  53. #if defined _INC_y_races
  54. #endinput
  55. #endif
  56. #define _INC_y_races
  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 "..\YSI_Players\y_text"
  66. #include "..\YSI_Data\y_bit"
  67. #include "..\YSI_Data\y_iterate"
  68. #include "..\YSI_Data\y_playerarray"
  69. #if defined RACE_POSITION
  70. #include "..\YSI_Coding\y_timers"
  71. #endif
  72. #if !defined MAX_RACES
  73. #define MAX_RACES 16
  74. #endif
  75. #define YSIM_U_DISABLE
  76. #define MASTER 53
  77. #include "..\YSI_Core\y_master"
  78. #define _GROUP_MAKE_NAME<%0...%1> %0Race%1
  79. #define _GROUP_MAKE_LIMIT MAX_RACES
  80. #include "..\YSI_Players\y_groups\_funcs"
  81. #include "..\YSI_Coding\y_hooks"
  82. stock _YSI_HAS_y_races(_do_not_call_me_ever_, _like_never_)
  83. {
  84. P:E("You called _YSI_HAS_y_races! Bad, don't do that!", _do_not_call_me_ever_, _like_never_);
  85. assert(false);
  86. return 0;
  87. }
  88. forward Race_Create(laps = 0, entry = 0, countdown = 3, bool:arial = false, bool:fixedPrize = true, exitTime = 0, interior = 0, world = 0, bool:restart = false);
  89. forward Race_Destroy(slot, bool:refund = false);
  90. foreign Race_AddCheckpoint(raceid, Float:x, Float:y, Float:z);
  91. foreign Race_AddStart(raceid, Float:x, Float:y, Float:z, Float:a);
  92. foreign void:Race_SetFixedWin(raceid, set);
  93. foreign void:Race_SetRestart(raceid, set);
  94. foreign void:Race_SetArial(raceid, set);
  95. foreign void:Race_SetCountdown(raceid, countdown);
  96. foreign void:Race_SetInterior(raceid, interior);
  97. foreign void:Race_SetWorld(raceid, world);
  98. foreign void:Race_SetPrize(raceid, position, amount);
  99. foreign void:Race_SetExitTime(raceid, time);
  100. foreign Race_IsActive(raceid);
  101. foreign void:Race_SetLaps(raceid, laps);
  102. foreign void:Race_SetEntry(raceid, cost);
  103. foreign Race_GetPlayerExitedTime(playerid);
  104. foreign Race_PlayerJoin(playerid, race);
  105. forward Race_PlayerLeave(playerid, bool:refund = false);
  106. foreign Race_Start(race);
  107. foreign Race_GetPlayerPosition(playerid);
  108. foreign Race_GetPlayerRaceTime(playerid);
  109. foreign Race_GetPlayerRace(playerid);
  110. foreign Race_SetPlayer(race, playerid, bool:set);
  111. #include "y_races/impl"
  112. #if defined YSI_TESTS
  113. #include "..\YSI_Core\y_testing"
  114. #include "y_races/tests"
  115. // Get some new IDs.
  116. #endif
  117. #undef _GROUP_MAKE_LIMIT
  118. #undef _GROUP_MAKE_NAME
  119. #include "..\YSI_Core\y_master"