y_lock.inc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /**--------------------------------------------------------------------------**\
  2. =================================
  3. y_lock - Lock a server's IP.
  4. =================================
  5. Description:
  6. Ensures that the server is running on the IP specified by "bind".
  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 YSI utils include.
  18. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  19. Portions created by the Initial Developer are Copyright (C) 2011
  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. ZeeX - Very productive conversations.
  26. koolk - IsPlayerinAreaEx code.
  27. TheAlpha - Danish translation.
  28. breadfish - German translation.
  29. Fireburn - Dutch translation.
  30. yom - French translation.
  31. 50p - Polish translation.
  32. Zamaroht - Spanish translation.
  33. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  34. for me to strive to better.
  35. Pixels^ - Running XScripters where the idea was born.
  36. Matite - Pestering me to release it and using it.
  37. Very special thanks to:
  38. Thiadmer - PAWN, whose limits continue to amaze me!
  39. Kye/Kalcor - SA:MP.
  40. SA:MP Team past, present and future - SA:MP.
  41. Version:
  42. 0.1
  43. Changelog:
  44. 25/02/12:
  45. First version.
  46. Functions:
  47. Stock:
  48. -
  49. Inline:
  50. -
  51. Variables:
  52. Global:
  53. -
  54. \**--------------------------------------------------------------------------**/
  55. #if defined _INC_y_lock
  56. #endinput
  57. #endif
  58. #define _INC_y_lock
  59. #if defined _inc_y_version
  60. #error YSI\y_lock must be the first include if you want to use it.
  61. #endif
  62. #if defined _DEBUG
  63. #if _DEBUG >= 1
  64. #define y_lock%0; _DoYLock(%0);
  65. #else
  66. #define y_lock%0; _DoYLock();
  67. #endif
  68. #else
  69. #define y_lock%0; _DoYLock();
  70. #endif
  71. #if !defined BIND_IP
  72. #if defined Y_LOCK_IP
  73. #define BIND_IP MAKE_LOCK_IP(Y_LOCK_IP)
  74. #else
  75. #define BIND_IP MAKE_LOCK_IP(127.0.0.1)
  76. #endif
  77. #endif
  78. // MASSIVE reliance on operator precedence here!
  79. #define MAKE_LOCK_IP(%0.%1.%2.%3) ((%0&0xFF)<<24|(%1&0xFF)<<16|(%2&0xFF)<<8|%3&0xFF)
  80. #define _LOCK_IP_0 (BIND_IP>>>24)
  81. #define _LOCK_IP_1 (BIND_IP>>>16&0xFF)
  82. #define _LOCK_IP_2 (BIND_IP>>>8&0xFF)
  83. #define _LOCK_IP_3 (BIND_IP&0xFF)
  84. #define UNHOOK for(from=AMX_HEADER_PUBLICS;from!=AMX_HEADER_NATIVES;from+= 8)AMX_Write(from,-1);
  85. #if _LOCK_IP_0 == 0
  86. #define _LOCK_LEN_0 1
  87. #else
  88. #define _LOCK_LEN_0 _LOCK_IP_0
  89. #endif
  90. #if _LOCK_IP_1 == 0
  91. #define _LOCK_LEN_1 1
  92. #else
  93. #define _LOCK_LEN_1 _LOCK_IP_1
  94. #endif
  95. #if _LOCK_IP_2 == 0
  96. #define _LOCK_LEN_2 1
  97. #else
  98. #define _LOCK_LEN_2 _LOCK_IP_2
  99. #endif
  100. #if _LOCK_IP_3 == 0
  101. #define _LOCK_LEN_3 1
  102. #else
  103. #define _LOCK_LEN_3 _LOCK_IP_3
  104. #endif
  105. #define YSI_LOCK_MODE
  106. #include "..\YSI_Internal\y_version"
  107. #include "..\YSI_Storage\y_amx"
  108. #include "..\YSI_Coding\y_hooks"
  109. _DoYLock(P:C(from);)
  110. {
  111. new
  112. arr[][] =
  113. {
  114. ";23#w",
  115. "32g2"
  116. };
  117. P:1("%d", from);
  118. #pragma unused arr
  119. #if !defined _DEBUG || _DEBUG < 1
  120. new from;
  121. #endif
  122. UNHOOK
  123. }