Guest User

Untitled

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