Guest User

Untitled

a guest
Aug 29th, 2010
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.98 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. #include <dutils>
  4.  
  5. #define FILTERSCRIPT
  6. #if defined FILTERSCRIPT
  7. #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
  8. #define COLOUR_GREEN 0x33AA33AA
  9. #define COLOUR_RED 0xAA3333AA
  10. #define COLOUR_YELLOW 0xFFFF00AA
  11. #define COLOUR_LIGHTBLUE 0x33CCFFAA
  12. #define COLOUR_ORANGE 0xFF9900AA
  13.  
  14. #define PlayerFile "AdminScript/Users/%s.ini"
  15. #define SettingFile "AdminScript/Settings/MainSettings.ini"
  16. #define CommandFile "AdminScript/Settings/Commands.ini"
  17.  
  18. public OnFilterScriptInit()
  19. {
  20. print("\n****************************************");
  21. print("* Admin Filterscript by your name here *");
  22. print("****************************************\n");
  23. return 1;
  24. }
  25.  
  26. #endif
  27.  
  28. enum PLAYER_MAIN {
  29. PLAYER_NAME[MAX_PLAYER_NAME],
  30. PLAYER_IP[16],
  31. PLAYER_REGGED,
  32. PLAYER_PASS,
  33. PLAYER_LOGGED,
  34. PLAYER_LEVEL,
  35. PLAYER_WIRED,
  36. PLAYER_JAILED
  37. }
  38. enum SETTINGS_MAIN {
  39. POCKET_MONEY,
  40. JAIL_COMMANDS,
  41. ANNOUNCE_SECONDS,
  42. PASS_MIN,
  43. PASS_MAX
  44. }
  45.  
  46. new gSettings[SETTINGS_MAIN];
  47.  
  48. enum COMMANDS_MAIN {
  49. AKILL,
  50. ANNOUNCE,
  51. ARMOURALL,
  52. BAN,
  53. CARHP,
  54. EXPLODE,
  55. FLIP,
  56. GOTO,
  57. GETHERE,
  58. GIVEARMOUR,
  59. GIVEHEALTH,
  60. GIVEWEAPON,
  61. GOD,
  62. HEALALL,
  63. IMITATE,
  64. IP,
  65. KICK,
  66. MAXAMMO,
  67. PING,
  68. SETLEVEL,
  69. SETWANTED,
  70. TBAN,
  71. TIME,
  72. WEATHER
  73. }
  74.  
  75. new gCommands[COMMANDS_MAIN];
  76.  
  77. public OnFilterScriptInit()
  78. {
  79. print("\n****************************************");
  80. print("* Admin Filterscript by your name here *");
  81. print("****************************************\n");
  82.  
  83. if(!fexist(SettingFile))
  84. {
  85. dini_Create(SettingFile);
  86. dini_IntSet(SettingFile, "PocketMoney", 3000);
  87. dini_IntSet(SettingFile, "JailCommands", 0);
  88. dini_IntSet(SettingFile, "AnnounceSeconds", 3);
  89. dini_IntSet(SettingFile, "PassMin", 3);
  90. dini_IntSet(SettingFile, "PassMax", 15);
  91. }
  92.  
  93. gSettings[POCKET_MONEY] = dini_Int(SettingFile, "PocketMoney");
  94. gSettings[JAIL_COMMANDS] = dini_Int(SettingFile, "JailCommands");
  95. gSettings[ANNOUNCE_SECONDS] = dini_Int(SettingFile, "AnnounceSeconds");
  96. gSettings[PASS_MIN] = dini_Int(SettingFile, "PassMin");
  97. gSettings[PASS_MAX] = dini_Int(SettingFile, "PassMax");
  98. return 1;
  99. }
  100.  
  101. #endif
  102.  
  103. public OnFilterScriptInit()
  104. {
  105. print("\n****************************************");
  106. print("* Admin Filterscript by your name here *");
  107. print("****************************************\n");
  108.  
  109. if(!fexist(SettingFile))
  110. {
  111. dini_Create(SettingFile);
  112. dini_IntSet(SettingFile, "PocketMoney", 3000);
  113. dini_IntSet(SettingFile, "JailCommands", 0);
  114. dini_IntSet(SettingFile, "AnnounceSeconds", 3);
  115. dini_IntSet(SettingFile, "PassMin", 3);
  116. dini_IntSet(SettingFile, "PassMax", 15);
  117. }
  118.  
  119. gSettings[POCKET_MONEY] = dini_Int(SettingFile, "PocketMoney");
  120. gSettings[JAIL_COMMANDS] = dini_Int(SettingFile, "JailCommands");
  121. gSettings[ANNOUNCE_SECONDS] = dini_Int(SettingFile, "AnnounceSeconds");
  122. gSettings[PASS_MIN] = dini_Int(SettingFile, "PassMin");
  123. gSettings[PASS_MAX] = dini_Int(SettingFile, "PassMax");
  124.  
  125. if(!fexist(CommandFile))
  126. {
  127. dini_Create(CommandFile);
  128. dini_IntSet(CommandFile, "Akill", 6);
  129. dini_IntSet(CommandFile, "Announce", 5);
  130. dini_IntSet(CommandFile, "Armourall", 3);
  131. dini_IntSet(CommandFile, "Ban", 9);
  132. dini_IntSet(CommandFile, "Carhp", 4);
  133. dini_IntSet(CommandFile, "Explode", 5);
  134. dini_IntSet(CommandFile, "Goto", 4);
  135. dini_IntSet(CommandFile, "Gethere", 5);
  136. dini_IntSet(CommandFile, "Givearmour", 6);
  137. dini_IntSet(CommandFile, "Givehealth", 6);
  138. dini_IntSet(CommandFile, "Giveweapon", 7);
  139. dini_IntSet(CommandFile, "God", 10);
  140. dini_IntSet(CommandFile, "Healall", 7);
  141. dini_IntSet(CommandFile, "Imitate", 8);
  142. dini_IntSet(CommandFile, "Ip", 2);
  143. dini_IntSet(CommandFile, "Kick", 7);
  144. dini_IntSet(CommandFile, "Maxammo", 8);
  145. dini_IntSet(CommandFile, "Ping", 1);
  146. dini_IntSet(CommandFile, "Setlevel", 10);
  147. dini_IntSet(CommandFile, "Setwanted", 6);
  148. dini_IntSet(CommandFile, "Tban", 9);
  149. dini_IntSet(CommandFile, "Time", 3);
  150. dini_IntSet(CommandFile, "Weather", 3);
  151. }
  152.  
  153. gCommands[AKILL] = dini_Int(CommandFile, "Akill");
  154. gCommands[ANNOUNCE] = dini_Int(CommandFile, "Announce");
  155. gCommands[ARMOURALL] = dini_Int(CommandFile, "Armourall");
  156. gCommands[BAN] = dini_Int(CommandFile, "Ban");
  157. gCommands[CARHP] = dini_Int(CommandFile, "Carhp");
  158. gCommands[EXPLODE] = dini_Int(CommandFile, "Explode");
  159. gCommands[GOTO] = dini_Int(CommandFile, "Goto");
  160. gCommands[GETHERE] = dini_Int(CommandFile, "Gethere");
  161. gCommands[GIVEARMOUR] = dini_Int(CommandFile, "Givearmour");
  162. gCommands[GIVEHEALTH] = dini_Int(CommandFile, "Givehealth");
  163. gCommands[GIVEWEAPON] = dini_Int(CommandFile, "Giveweapon");
  164. gCommands[GOD] = dini_Int(CommandFile, "God");
  165. gCommands[HEALALL] = dini_Int(CommandFile, "Healall");
  166. gCommands[IMITATE] = dini_Int(CommandFile, "Imitate");
  167. gCommands[IP] = dini_Int(CommandFile, "Ip");
  168. gCommands[KICK] = dini_Int(CommandFile, "Kick");
  169. gCommands[MAXAMMO] = dini_Int(CommandFile, "Maxammo");
  170. gCommands[SETLEVEL] = dini_Int(CommandFile, "Setlevel");
  171. gCommands[SETWANTED] = dini_Int(CommandFile, "Setwanted");
  172. gCommands[TBAN] = dini_Int(CommandFile, "Tban");
  173. gCommands[TIME] = dini_Int(CommandFile, "Time");
  174. gCommands[WEATHER] = dini_Int(CommandFile, "Weather");
  175.  
  176. return 1;
  177. }
  178.  
  179.  
  180. public OnPlayerConnect(playerid)
  181. {
  182. new file[100],Name[MAX_PLAYER_NAME],Ip[16];
  183. GetPlayerName(playerid,Name,sizeof(Name));
  184. GetPlayerIp(playerid,Ip,sizeof(Ip));
  185. format(file,sizeof(file),PlayerFile,Name);
  186.  
  187. if(!dini_Exists(file))
  188. {
  189. dini_Create(file);
  190. dini_Set(file,"Name",Name);
  191. dini_Set(file,"Ip",Ip);
  192. dini_IntSet(file,"Registered",-1);
  193. dini_IntSet(file,"Password",0);
  194. dini_IntSet(file,"Level",0);
  195. dini_IntSet(file,"Wired",0);
  196. dini_IntSet(file,"Jailed",0);
  197. SendClientMessage(playerid,COLOUR_ORANGE,"Your username is not recognized on this server. Please /register to continue.");
  198. }
  199. strcat(gPlayerInfo[playerid][PLAYER_NAME], dini_Get(file,"Name"));
  200. strcat(gPlayerInfo[playerid][PLAYER_IP], dini_Get(file,"Ip"));
  201. gPlayerInfo[playerid][PLAYER_REGGED] = dini_Int(file,"Registered");
  202. gPlayerInfo[playerid][PLAYER_PASS] = dini_Int(file,"Password");
  203. gPlayerInfo[playerid][PLAYER_LEVEL] = dini_Int(file,"Level");
  204. gPlayerInfo[playerid][PLAYER_WIRED] = dini_Int(file,"Wired");
  205. gPlayerInfo[playerid][PLAYER_JAILED] = dini_Int(file,"Jailed");
  206. 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.");
  207. else if(gPlayerInfo[playerid][PLAYER_REGGED] == 1) SendClientMessage(playerid,COLOUR_ORANGE,"You're username is recognised on this server. Please /login to continue.");
  208. gPlayerInfo[playerid][PLAYER_REGGED] = 0;
  209. return 1;
  210. }
  211.  
  212. public OnPlayerDisconnect(playerid, reason)
  213. {
  214. new file[100];
  215. format(file,sizeof(file),PlayerFile,gPlayerInfo[playerid][PLAYER_NAME]);
  216. dini_Set(file,"Name",gPlayerInfo[playerid][PLAYER_NAME]);
  217. dini_Set(file,"Ip",gPlayerInfo[playerid][PLAYER_IP]);
  218. dini_IntSet(file,"Registered",gPlayerInfo[playerid][PLAYER_REGGED]);
  219. dini_IntSet(file,"Password",gPlayerInfo[playerid][PLAYER_PASS]);
  220. dini_IntSet(file,"Level",gPlayerInfo[playerid][PLAYER_LEVEL]);
  221. dini_IntSet(file,"Wired",gPlayerInfo[playerid][PLAYER_WIRED]);
  222. dini_IntSet(file,"Jailed",gPlayerInfo[playerid][PLAYER_JAILED]);
  223. gPlayerInfo[playerid][PLAYER_NAME] = 0;
  224. gPlayerInfo[playerid][PLAYER_IP] = 0;
  225. gPlayerInfo[playerid][PLAYER_REGGED] = 0;
  226. gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
  227. gPlayerInfo[playerid][PLAYER_PASS] = 0;
  228. gPlayerInfo[playerid][PLAYER_LEVEL] = 0;
  229. gPlayerInfo[playerid][PLAYER_WIRED] = 0;
  230. gPlayerInfo[playerid][PLAYER_JAILED] = 0;
  231. return 1;
  232. }
  233.  
  234. public OnPlayerCommandText(playerid, cmdtext[])
  235. {
  236. dcmd(register, 8, cmdtext);
  237. dcmd(login, 5, cmdtext);
  238. dcmd(logout, 6, cmdtext);
  239. dcmd(password, 8, cmdtext);
  240.  
  241. return 0;
  242. }
  243.  
  244. dcmd_register(playerid, params[])
  245. {
  246. if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)
  247. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You have already registered!");
  248. else if(!params[0])
  249. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /register [password]");
  250. else if(strlen(params) < gSettings[PASS_MIN] || strlen(params) > gSettings[PASS_MAX])
  251. {
  252. new string[128];
  253. format(string, sizeof(string), "ERROR: Password must be between %d and $d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
  254. return SendClientMessage(playerid, COLOUR_ORANGE, string);
  255. }
  256. else
  257. {
  258. new password = num_hash(params);
  259. gPlayerInfo[playerid][PLAYER_PASS] = password;
  260. gPlayerInfo[playerid][PLAYER_REGGED] = 1;
  261. gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
  262. GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
  263. new string[128]; format(string, sizeof(string), "You have successfully registered your account with the password \'%s\'. You have been automatically logged in.", params);
  264. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  265. }
  266.  
  267.  
  268. dcmd_login(playerid, params[])
  269. {
  270. if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  271. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
  272. else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 1)
  273. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged-in.");
  274. else if(!params[0])
  275. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /login [password]");
  276. else
  277. {
  278. new password = num_hash(params);
  279. if(gPlayerInfo[playerid][PLAYER_PASS] == password)
  280. {
  281. gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
  282. GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
  283. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged in to your account.");
  284. }
  285. else
  286. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
  287. }
  288. }
  289. dcmd_logout(playerid, params[])
  290. {
  291. #pragma unused params
  292. if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  293. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register.");
  294. else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
  295. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged-out.");
  296. else
  297. {
  298. gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
  299. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged out of your account.");
  300. }
  301. }
  302.  
  303. dcmd_password(playerid, params[])
  304. {
  305. if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  306. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
  307. else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
  308. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must be logged-in to do that! Use /login [password] to login.");
  309. else
  310. {
  311. new tmp[30],
  312. tmp2[30],
  313. index;
  314. tmp = strtok(params, index);
  315. if(!strlen(tmp))
  316. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
  317. tmp2 = strtok(params, index);
  318. if(!strlen(tmp2))
  319. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
  320. new oldpassword = num_hash(tmp), newpassword = num_hash(tmp2);
  321. if(gPlayerInfo[playerid][PLAYER_PASS] == oldpassword)
  322. {
  323. if(oldpassword == newpassword)
  324. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Your old password can not be the same as your new password.");
  325. else if(strlen(tmp2) < gSettings[PASS_MIN] || strlen(tmp2) > gSettings[PASS_MAX])
  326. {
  327. 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]);
  328. return SendClientMessage(playerid, COLOUR_ORANGE, string);
  329. }
  330. gPlayerInfo[playerid][PLAYER_PASS] = newpassword;
  331. new string[128]; format(string, sizeof(string), "You have successfully changed your password from \'%s\' to \'%s\'.", tmp, tmp2);
  332. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  333. }
  334. else
  335. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
  336. }
  337. }
  338.  
  339. dcmd_akill(playerid, params[])
  340. {
  341. if(gPlayerInfo[playerid][PLAYER_LEVEL] < gCommands[AKILL])
  342. {
  343. new string[100];
  344. format(string, sizeof(string), "You must be administrator level %d to use that command!", gCommands[AKILL]);
  345. return SendClientMessage(playerid, COLOUR_ORANGE, string);
  346. }
  347. else if(!strlen(params))
  348. return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /akill [id | name]");
  349. else
  350. {
  351. new id = (isNumeric(params)) ? strval(params) : GetPlayerId(params);
  352. if(IsPlayerConnected(id) && id != playerid)
  353. {
  354. SetPlayerHealth(id, 0.0);
  355. new string[128];
  356. format(string, sizeof(string), "You have been admin-killed by administrator \'%s\'.", gPlayerInfo[playerid][PLAYER_NAME]);
  357. SendClientMessage(id, COLOUR_ORANGE, string);
  358. format(string, sizeof(string), "You have successfully admin-killed player \'%s\'.", gPlayerInfo[id][PLAYER_NAME]);
  359. return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  360. }
  361. else
  362. return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You can not admin-kill yourself or a disconnected player.");
  363. }
  364. }
Advertisement
Add Comment
Please, Sign In to add comment