Guest User

help ;)

a guest
Aug 6th, 2010
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.23 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. #include <dutils>
  4. #define FILTERSCRIPT
  5. #if defined FILTERSCRIPT
  6. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  7. #define COLOUR_GREEN 0x33AA33AA
  8. #define COLOUR_RED 0xAA3333AA
  9. #define COLOUR_YELLOW 0xFFFF00AA
  10. #define COLOUR_LIGHTBLUE 0x33CCFFAA
  11. #define COLOUR_ORANGE 0xFF9900AA
  12.  
  13. #define PlayerFile "AdminScript/Users/%s.ini"
  14. #define SettingFile "AdminScript/Settings/MainSettings.ini"
  15. #define CommandFile "AdminScript/Settings/Commands.ini"
  16.  
  17. public OnFilterScriptInit()
  18. {
  19. print("\n****************************************");
  20. print("* U-Admin FS by Ubisoft *");
  21. print("****************************************\n");
  22. return 1;
  23. }
  24.  
  25. #endif
  26.  
  27. enum PLAYER_MAIN {
  28. PLAYER_NAME[MAX_PLAYER_NAME],
  29. PLAYER_IP[16],
  30. PLAYER_REGGED,
  31. PLAYER_PASS,
  32. PLAYER_LOGGED,
  33. PLAYER_LEVEL,
  34. PLAYER_WIRED,
  35. PLAYER_JAILED
  36. }
  37.  
  38.  
  39. new gPlayerInfo[MAX_PLAYERS][PLAYER_MAIN];
  40.  
  41.  
  42. public OnPlayerConnect(playerid)
  43. {
  44. new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  45. if(!dini_Exists(file)) {
  46. dini_Create(file);
  47. dini_Set(file,"Name",Name);
  48. dini_Set(file,"Ip",Ip);
  49. dini_IntSet(file,"Registered",-1);
  50. dini_IntSet(file,"Password",0);
  51. dini_IntSet(file,"Level",0);
  52. dini_IntSet(file,"Wired",0);
  53. dini_IntSet(file,"Jailed",0);
  54. SendClientMessage(playerid,COLOUR_ORANGE,"You're username is not recognized on this server. Please /register to continue.");
  55. }
  56. strcat(gPlayerInfo[playerid][PLAYER_NAME], dini_Get(file,"Name"));
  57. strcat(gPlayerInfo[playerid][PLAYER_IP], dini_Get(file,"Ip"));
  58. gPlayerInfo[playerid][PLAYER_REGGED] = dini_Int(file,"Registered");
  59. gPlayerInfo[playerid][PLAYER_PASS] = dini_Int(file,"Password");
  60. gPlayerInfo[playerid][PLAYER_LEVEL] = dini_Int(file,"Level");
  61. gPlayerInfo[playerid][PLAYER_WIRED] = dini_Int(file,"Wired");
  62. gPlayerInfo[playerid][PLAYER_JAILED] = dini_Int(file,"Jailed");
  63. if(gPlayerInfo[playerid][PLAYER_REGGED] == 0) SendClientMessage(playerid,COLOUR_ORANGE,"You're username is recognised on this server, but you have not registered. Please /register to continue.");
  64. else if(gPlayerInfo[playerid][PLAYER_REGGED] == 1) SendClientMessage(playerid,COLOUR_ORANGE,"You're username is recognised on this server. Please /login to continue.");
  65. gPlayerInfo[playerid][PLAYER_REGGED] = 0;
  66. return 1;
  67. }
  68.  
  69.  
  70.  
  71.  
  72. public OnPlayerDisconnect(playerid, reason)
  73. {
  74. new file[100];
  75. format(file,sizeof(file),PlayerFile,gPlayerInfo[playerid][PLAYER_NAME]);
  76. dini_Set(file,"Name",gPlayerInfo[playerid][PLAYER_NAME]);
  77. dini_Set(file,"Ip",gPlayerInfo[playerid][PLAYER_IP]);
  78. dini_IntSet(file,"Registered",gPlayerInfo[playerid][PLAYER_REGGED]);
  79. dini_IntSet(file,"Password",gPlayerInfo[playerid][PLAYER_PASS]);
  80. dini_IntSet(file,"Level",gPlayerInfo[playerid][PLAYER_LEVEL]);
  81. dini_IntSet(file,"Wired",gPlayerInfo[playerid][PLAYER_WIRED]);
  82. dini_IntSet(file,"Jailed",gPlayerInfo[playerid][PLAYER_JAILED]);
  83. gPlayerInfo[playerid][PLAYER_NAME] = 0;
  84. gPlayerInfo[playerid][PLAYER_IP] = 0;
  85. gPlayerInfo[playerid][PLAYER_REGGED] = 0;
  86. gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
  87. gPlayerInfo[playerid][PLAYER_PASS] = 0;
  88. gPlayerInfo[playerid][PLAYER_LEVEL] = 0;
  89. gPlayerInfo[playerid][PLAYER_WIRED] = 0;
  90. gPlayerInfo[playerid][PLAYER_JAILED] = 0;
  91. return 1;
  92. }
  93.  
  94.  
  95.  
  96. public OnPlayerCommandText(playerid, cmdtext[])
  97. {
  98. dcmd(register, 8, cmdtext);
  99. dcmd(login, 5, cmdtext);
  100. dcmd(logout, 6, cmdtext);
  101. dcmd(password, 8, cmdtext);
  102.  
  103. return 0;
  104. }
  105.  
  106.  
  107. dcmd_register(playerid, params[])
  108. {
  109. if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)
  110. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You have already registered!");
  111. else if(!params[0])
  112. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /register [password]");
  113. /*else if(strlen(params) < gSettings[PASS_MIN] || strlen(params) > gSettings[PASS_MAX])
  114. {
  115. new string[128];
  116. format(string, sizeof(string), "ERROR: Password must be between %d and %d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
  117. return SendClientMessage(playerid, COLOUR_ORANGE, string);
  118. }*/
  119. else
  120. {
  121. new password = num_hash(params);
  122. gPlayerInfo[playerid][PLAYER_PASS] = password;
  123. gPlayerInfo[playerid][PLAYER_REGGED] = 1;
  124. gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
  125. GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
  126. new string[128]; format(string, sizeof(string), "You have successfully registered your account with the password \'%s\'. You have been automatically logged in.", params);
  127. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  128. }
  129. }
  130.  
  131.  
  132.  
  133. dcmd_login(playerid, params[])
  134. {
  135. if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  136. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
  137. else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 1)
  138. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged-in.");
  139. else if(!params[0])
  140. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /login [password]");
  141. else
  142. {
  143. new password = num_hash(params);
  144. if(gPlayerInfo[playerid][PLAYER_PASS] == password)
  145. {
  146. gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
  147. GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
  148. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged in to your account.");
  149. }
  150. else
  151. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
  152. }
  153. }
  154.  
  155.  
  156.  
  157. dcmd_logout(playerid, params[])
  158. {
  159. #pragma unused params
  160. if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  161. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register.");
  162. else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
  163. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged-out.");
  164. else
  165. {
  166. gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
  167. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged out of your account.");
  168. }
  169. }
  170.  
  171.  
  172.  
  173. dcmd_password(playerid, params[])
  174. {
  175. if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  176. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
  177. else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
  178. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must be logged-in to do that! Use /login [password] to login.");
  179. else
  180. {
  181. new tmp[30],
  182. tmp2[30],
  183. index;
  184. tmp = strtok(params, index);
  185. if(!strlen(tmp))
  186.  
  187. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
  188.  
  189. tmp2 = strtok(params, index);
  190. if(!strlen(tmp2))
  191. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
  192. new oldpassword = num_hash(tmp), newpassword = num_hash(tmp2);
  193. if(gPlayerInfo[playerid][PLAYER_PASS] == oldpassword)
  194. {
  195. if(oldpassword == newpassword)
  196. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Your old password can not be the same as your new password.");
  197. /*else if(strlen(tmp2) < gSettings[PASS_MIN] || strlen(tmp2) > gSettings[PASS_MAX])
  198. {
  199. new string[100]; format(string, sizeof(string), "ERROR: Your new password must be between %d and %d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
  200. return SendClientMessage(playerid, COLOUR_ORANGE, string);
  201. }*/
  202. gPlayerInfo[playerid][PLAYER_PASS] = newpassword;
  203. new string[128]; format(string, sizeof(string), "You have successfully changed your password from \'%s\' to \'%s\'.", tmp, tmp2);
  204. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  205. }
  206. else
  207. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
  208. }
  209. }
Advertisement
Add Comment
Please, Sign In to add comment