1
0

y_users.inc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. #if defined _INC_y_users
  2. #endinput
  3. #endif
  4. #define _INC_y_users
  5. /**
  6. * <library name="y_users">
  7. * <section>
  8. * Description
  9. * </section>
  10. * Provides access to a user system for registering and saving users.
  11. * <section>
  12. * Version
  13. * </section>
  14. * 2.2
  15. * </library>
  16. *//** *//*
  17. Legal:
  18. Version: MPL 1.1
  19. The contents of this file are subject to the Mozilla Public License Version
  20. 1.1 the "License"; you may not use this file except in compliance with
  21. the License. You may obtain a copy of the License at
  22. http://www.mozilla.org/MPL/
  23. Software distributed under the License is distributed on an "AS IS" basis,
  24. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  25. for the specific language governing rights and limitations under the
  26. License.
  27. The Original Code is the YSI framework.
  28. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  29. Portions created by the Initial Developer are Copyright C 2011
  30. the Initial Developer. All Rights Reserved.
  31. Contributors:
  32. Y_Less
  33. koolk
  34. JoeBullet/Google63
  35. g_aSlice/Slice
  36. Misiur
  37. samphunter
  38. tianmeta
  39. maddinat0r
  40. spacemud
  41. Crayder
  42. Dayvison
  43. Ahmad45123
  44. Zeex
  45. irinel1996
  46. Yiin-
  47. Chaprnks
  48. Konstantinos
  49. Masterchen09
  50. Southclaws
  51. PatchwerkQWER
  52. m0k1
  53. paulommu
  54. udan111
  55. Thanks:
  56. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  57. ZeeX - Very productive conversations.
  58. koolk - IsPlayerinAreaEx code.
  59. TheAlpha - Danish translation.
  60. breadfish - German translation.
  61. Fireburn - Dutch translation.
  62. yom - French translation.
  63. 50p - Polish translation.
  64. Zamaroht - Spanish translation.
  65. Los - Portuguese translation.
  66. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  67. me to strive to better.
  68. Pixels^ - Running XScripters where the idea was born.
  69. Matite - Pestering me to release it and using it.
  70. Very special thanks to:
  71. Thiadmer - PAWN, whose limits continue to amaze me!
  72. Kye/Kalcor - SA:MP.
  73. SA:MP Team past, present and future - SA:MP.
  74. Optional plugins:
  75. Gamer_Z - GPS.
  76. Incognito - Streamer.
  77. Me - sscanf2, fixes2, Whirlpool.
  78. */
  79. #if !defined MODE_NAME
  80. #error Please define "MODE_NAME" before including y_users.
  81. #endif
  82. #include <a_samp>
  83. forward OnPlayerLogin(playerid, uid);
  84. forward OnPlayerLogout(playerid, uid);
  85. forward OnPlayerSaved(playerid, uid);
  86. //#if !defined HAS_USER_CALLBACKS
  87. // #define HAS_USER_CALLBACKS
  88. //#endif
  89. #include "..\YSI_Internal\y_version"
  90. #include "..\YSI_Players\y_text"
  91. #include "..\YSI_Coding\y_remote"
  92. #include "..\YSI_Core\y_debug"
  93. #include "..\YSI_Storage\y_ini"
  94. #include "..\YSI_Core\y_utils"
  95. #include "..\YSI_Coding\y_timers"
  96. #define YSIM_U_DISABLE
  97. #define MASTER 55
  98. #include "..\YSI_Core\y_master"
  99. #define MAX_INDEX_LENGTH 8
  100. #include "..\YSI_Internal\y_plugins"
  101. #include "..\YSI_Internal\y_natives"
  102. #include "..\YSI_Coding\y_hooks"
  103. #if defined PP_ADLER32
  104. //#define MAX_PASSWORD_LENGTH 11
  105. #error Adler32 sucks!
  106. #elseif defined PP_MD5
  107. #if defined MD5_Hash
  108. #define MAX_PASSWORD_LENGTH 32
  109. #else
  110. #error Could not find MD5_Hash.
  111. #endif
  112. #elseif defined PP_SHA1
  113. #error SHA1 unsupported.
  114. #elseif defined PP_YSI
  115. #define MAX_PASSWORD_LENGTH 16
  116. #elseif defined PP_WP || defined PP_WHIRLPOOL
  117. #if defined _YSI_PLUGINS_WHIRLPOOL
  118. #define MAX_PASSWORD_LENGTH 128
  119. #else
  120. #error Could not find WP_Hash.
  121. #endif
  122. #else
  123. #error Default hash removed: See YSI topic for details.
  124. //#define PP_YSI
  125. //#define MAX_PASSWORD_LENGTH 16
  126. #endif
  127. //#define INDEX_DATA_LINE_LENGTH (MAX_INDEX_LENGTH + 1 + MAX_PLAYER_NAME + 1 + MAX_PASSWORD_LENGTH + 3 + 3 + 9 + 9)
  128. // MAX_INDEX_LENGTH - The player's ID.
  129. // 1 - Space.
  130. // MAX_PLAYER_NAME - The player's name.
  131. // 1 - Space.
  132. // MAX_PASSWORD_LENGTH - The password hash.
  133. // 1 - Space.
  134. // 2 - Language.
  135. // 1 - Space.
  136. // 8 - Free HEX bits.
  137. // 1 - Space.
  138. // 8 - Join timestamp.
  139. // 3 - Newline + Null.
  140. const
  141. INDEX_DATA_LINE_LENGTH = MAX_INDEX_LENGTH + 1 + MAX_PLAYER_NAME + 1 + MAX_PASSWORD_LENGTH + 1 + 2 + 1 + 8 + 1 + 8 + 3;
  142. #if !defined USER_FILE_PATH
  143. #if defined YSI_TESTS
  144. // Create a separate path for any test data so that we don't ruin any
  145. // live user data.
  146. #define USER_FILE_PATH "YSI/test_users/"
  147. #define USER_FILE_LENGTH 15
  148. #else
  149. #define USER_FILE_PATH "YSI/users/"
  150. #define USER_FILE_LENGTH 10
  151. #endif
  152. #endif
  153. #define OnUserData[%0](%1) @yU_%0(%1)
  154. #define PINI:%0(%1) forward OnUserData[%0](%1);public OnUserData[%0](%1)
  155. foreign Player_TryRegister(playerid, string:password[]);
  156. foreign Player_TryLogin(playerid, string:password[]);
  157. foreign Player_TryGroup(playerid, string:other[], string:password[]);
  158. foreign Player_ChangePassword(playerid, string:password[]);
  159. foreign Player_ForceGroup(playerid, string:other[]);
  160. foreign Player_ForceLogin(playerid);
  161. foreign Player_ChangeLanguage(playerid, string:code[]);
  162. #if defined USERS_USE_MYSQL
  163. /*
  164. #if _YSI_PLUGINS_MYSQL == 7
  165. #include "y_users/blueg7"
  166. #elseif _YSI_PLUGINS_MYSQL == 6
  167. #include "y_users/blueg6"
  168. #elseif _YSI_PLUGINS_MYSQL == 7
  169. #include "y_users/stricken"
  170. #else
  171. #error No MySQL plugin found.
  172. #endif
  173. */
  174. // I know it is a bit odd that this should need y_ini for database access, but
  175. // there is a very good reason (loading passwords).
  176. #include "..\YSI_Storage\y_ini"
  177. #include "..\YSI_Data\y_iterate"
  178. #include "y_users/dan10"
  179. #elseif defined USERS_USE_SQLITE
  180. #include "y_users/sqlite"
  181. #else
  182. #include "y_users/ini"
  183. #endif
  184. #if defined YSI_TESTS
  185. #include "..\YSI_Core\y_testing"
  186. #include "y_users/tests"
  187. #endif
  188. #include "..\YSI_Core\y_master"