y_lock.inc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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_version
  56. #error YSI\y_lock must be the first include if you want to use it.
  57. #endif
  58. #if defined _DEBUG && _DEBUG >= 1
  59. #define y_lock%0; _DoYLock(%0);
  60. #else
  61. #define y_lock%0; _DoYLock();
  62. #endif
  63. #if !defined BIND_IP
  64. #define BIND_IP MAKE_LOCK_IP(127.0.0.1)
  65. #endif
  66. // MASSIVE reliance on operator precedence here!
  67. #define MAKE_LOCK_IP(%0.%1.%2.%3) ((%0&0xFF)<<24|(%1&0xFF)<<16|(%2&0xFF)<<8|%3&0xFF)
  68. #define _LOCK_IP_0 (BIND_IP>>>24)
  69. #define _LOCK_IP_1 (BIND_IP>>>16&0xFF)
  70. #define _LOCK_IP_2 (BIND_IP>>>8&0xFF)
  71. #define _LOCK_IP_3 (BIND_IP&0xFF)
  72. #define UNHOOK for(from=AMX_HEADER_PUBLICS;from!=AMX_HEADER_NATIVES;from+= 8)AMX_Write(from,-1);
  73. #if _LOCK_IP_0 == 0
  74. #define _LOCK_LEN_0 1
  75. #else
  76. #define _LOCK_LEN_0 _LOCK_IP_0
  77. #endif
  78. #if _LOCK_IP_1 == 0
  79. #define _LOCK_LEN_1 1
  80. #else
  81. #define _LOCK_LEN_1 _LOCK_IP_1
  82. #endif
  83. #if _LOCK_IP_2 == 0
  84. #define _LOCK_LEN_2 1
  85. #else
  86. #define _LOCK_LEN_2 _LOCK_IP_2
  87. #endif
  88. #if _LOCK_IP_3 == 0
  89. #define _LOCK_LEN_3 1
  90. #else
  91. #define _LOCK_LEN_3 _LOCK_IP_3
  92. #endif
  93. #define YSI_LOCK_MODE
  94. #include "internal\y_version"
  95. #include "y_amx"
  96. #include "y_hooks"
  97. _DoYLock(P:C(from);)
  98. {
  99. new
  100. arr[][] =
  101. {
  102. ";23#w",
  103. "32g2"
  104. };
  105. P:1("%d", from);
  106. #pragma unused arr
  107. #if !defined _DEBUG || _DEBUG < 1
  108. new from;
  109. #endif
  110. UNHOOK
  111. }