y_lock.inc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 && _DEBUG >= 1
  63. #define y_lock%0; _DoYLock(%0);
  64. #else
  65. #define y_lock%0; _DoYLock();
  66. #endif
  67. #if !defined BIND_IP
  68. #if defined Y_LOCK_IP
  69. #define BIND_IP MAKE_LOCK_IP(Y_LOCK_IP)
  70. #else
  71. #define BIND_IP MAKE_LOCK_IP(127.0.0.1)
  72. #endif
  73. #endif
  74. // MASSIVE reliance on operator precedence here!
  75. #define MAKE_LOCK_IP(%0.%1.%2.%3) ((%0&0xFF)<<24|(%1&0xFF)<<16|(%2&0xFF)<<8|%3&0xFF)
  76. #define _LOCK_IP_0 (BIND_IP>>>24)
  77. #define _LOCK_IP_1 (BIND_IP>>>16&0xFF)
  78. #define _LOCK_IP_2 (BIND_IP>>>8&0xFF)
  79. #define _LOCK_IP_3 (BIND_IP&0xFF)
  80. #define UNHOOK for(from=AMX_HEADER_PUBLICS;from!=AMX_HEADER_NATIVES;from+= 8)AMX_Write(from,-1);
  81. #if _LOCK_IP_0 == 0
  82. #define _LOCK_LEN_0 1
  83. #else
  84. #define _LOCK_LEN_0 _LOCK_IP_0
  85. #endif
  86. #if _LOCK_IP_1 == 0
  87. #define _LOCK_LEN_1 1
  88. #else
  89. #define _LOCK_LEN_1 _LOCK_IP_1
  90. #endif
  91. #if _LOCK_IP_2 == 0
  92. #define _LOCK_LEN_2 1
  93. #else
  94. #define _LOCK_LEN_2 _LOCK_IP_2
  95. #endif
  96. #if _LOCK_IP_3 == 0
  97. #define _LOCK_LEN_3 1
  98. #else
  99. #define _LOCK_LEN_3 _LOCK_IP_3
  100. #endif
  101. #define YSI_LOCK_MODE
  102. #include "..\YSI_Internal\y_version"
  103. #include "..\YSI_Storage\y_amx"
  104. #include "..\YSI_Coding\y_hooks"
  105. _DoYLock(P:C(from);)
  106. {
  107. new
  108. arr[][] =
  109. {
  110. ";23#w",
  111. "32g2"
  112. };
  113. P:1("%d", from);
  114. #pragma unused arr
  115. #if !defined _DEBUG || _DEBUG < 1
  116. new from;
  117. #endif
  118. UNHOOK
  119. }