Guest User

Untitled

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