Advertisement
denniser8

Admin System Simple!

Sep 28th, 2013
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.87 KB | None | 0 0
  1. //
  2. // Simple Admin Command by Dion keep the credits
  3. //
  4. #include <a_samp>
  5. #include <zcmd>
  6. #include <foreach>
  7. #include <sscanf2>
  8.  
  9. #define FILTERSCRIPT
  10. // Colors
  11. #define COLOR_WHITE 0xFFFFFFFF
  12. #define COLOR_FADE1 0xE6E6E6E6
  13. #define COLOR_PM1 0xA65FC7FF
  14. #define COLOR_PM2 0xD35FC7FF
  15. #define COLOR_FADE2 0xC8C8C8C8
  16. #define COLOR_FADE3 0xAAAAAAAA
  17. #define COLOR_FADE4 0x8C8C8C8C
  18. #define COLOR_FADE5 0x6E6E6E6E
  19. #define TEAM_GROVE_COLOR 0x00AA00FF
  20. #define COLOR_OOC 0xE0FFFFFF
  21. #define COLOR_GREY 0xAFAFAFFF
  22. #define COLOR_LIGHTGREEN 0xADFF2FFF
  23. #define COLOR_LIGHTRED 0xFF6347FF
  24. #define COLOR_ALLDEPT 0xFF8282AA
  25. #define COLOR_DARKRED 0xAA3333FF
  26. #define COLOR_RED 0xFF0606FF
  27. #define TCOLOR_YELLOW 0xFFFF0000
  28. #define COLOR_TWPINK 0xE75480AA
  29. #define TEAM_HIT_COLOR 0xFFFFFF00
  30. #define COLOR_DBLUE 0x2641FEAA
  31. #define TEAM_CYAN_COLOR 0xFF8282AA
  32. #define COLOR_LIGHTBLUE 0x33CCFFFF
  33. #define COLOR_GREEN 0x33AA33FF
  34. #define COLOR_INDIGO 0x4B00B000
  35. #define COLOR_PINK 0xFF66FF00
  36. #define COLOR_BLACK 0x00000000
  37. #define COLOR_YELLOW 0xFFFF00FF
  38. #define COLOR_PURPLE 0xC2A2DAFF
  39. #define COLOR_ORANGE 0xFF9900FF
  40. #define COLOR_REPORT 0xFFFF91FF
  41. #define COLOR_RADIO 0x8D8DFFFF
  42. #define COLOR_DEPTRADIO 0xFFD700FF
  43. #define COLOR_BLUE 0x2641FEFF
  44. #define COLOR_MEDIC 0xFF8282FF
  45. #define COLOR_NEWBIE 0x7DAEFFFF
  46. #define COLOR_LIME 0x00FF00FF
  47. #define COLOR_NEWS 0x049C7100
  48. #define COLOR_CYAN 0x01FCFFFF
  49. #define COLOR_VIP 0xC93CCEFF
  50.  
  51. //Max
  52. #define MAX_CUSTOM_VEHICLES 200
  53.  
  54. public OnFilterScriptInit()
  55. {
  56. print("\n--------------------------------------");
  57. print(" Dions Admin System! ");
  58. print("--------------------------------------\n");
  59. return 1;
  60. }
  61.  
  62. public OnFilterScriptExit()
  63. {
  64. print("\n----------------------------------");
  65. print(" Dion Admin System! ");
  66. print("----------------------------------\n");
  67. return 1;
  68. }
  69.  
  70. public OnPlayerConnect(playerid)
  71. {
  72. new string[128];
  73. format(string,sizeof(string), "Welcome %s. This server run's Dion's admin system", RPN(playerid));
  74. {
  75. SendClientMessage(playerid, COLOR_BLUE, string);
  76. }
  77. format(string,sizeof(string), "If you hack or cheat, admins will ban you.", RPN(playerid));
  78. {
  79. SendClientMessage(playerid, COLOR_RED, string);
  80. }
  81. return 1;
  82. }
  83.  
  84. CMD:ahelp(playerid, params[])
  85. {
  86. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  87. SendClientMessage(playerid, COLOR_GREEN, "_____________________________________________________");
  88. SendClientMessage(playerid, COLOR_YELLOW, "Admin: {FFFFFF}/sethp /sethpall /setarmor /setarmorall /healnear /freezenear /unfreezenear");
  89. SendClientMessage(playerid, COLOR_YELLOW, "Admin: {FFFFFF}/healall /ann /veh /freeze /unfreeze /ban /kick");
  90. return 1;
  91. }
  92.  
  93. CMD:sethpall(playerid, params[])
  94. {
  95. new amount, string[128];
  96. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  97. if(sscanf(params, "i", amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sethpall [amount]");
  98. foreach(Player, i)
  99. {
  100. if(IsPlayerLoggedIn(i))
  101. {
  102. SetPlayerHealth(i, amount);
  103. }
  104. }
  105. SendClientMessage(playerid, COLOR_WHITE, "Everyone's HP Successfully set.");
  106. format(string, sizeof(string), "AdmCmd: %s has set everyone's HP to .", RPN(playerid), amount);
  107. SendClientMessageToAll(COLOR_LIGHTRED, string);
  108. return 1;
  109. }
  110. CMD:healnear(playerid, params[])
  111. {
  112. new string[128];
  113. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  114. foreach(Player, i)
  115. {
  116. if(IsPlayerNearPlayer(playerid, i, 10))
  117. {
  118. SetPlayerHealth(i, 100);
  119. }
  120. }
  121. format(string, sizeof(string), "AdmCmd: %s has healed everyone near.", RPN(playerid));
  122. SendClientMessageToAll(COLOR_LIGHTRED, string);
  123. return 1;
  124. }
  125. CMD:freezenear(playerid, params[])
  126. {
  127. new string[128];
  128. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  129. foreach(Player, i)
  130. {
  131. if(IsPlayerNearPlayer(playerid, i, 10))
  132. {
  133. if(!IsPlayerAdmin(playerid))
  134. TogglePlayerControllable(i, 0);
  135. }
  136. }
  137. format(string, sizeof(string), "AdmCmd: %s has froze everyone near.", RPN(playerid));
  138. SendClientMessageToAll(COLOR_LIGHTRED, string);
  139. return 1;
  140. }
  141. CMD:unfreezenear(playerid, params[])
  142. {
  143. new string[128];
  144. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  145. foreach(Player, i)
  146. {
  147. if(IsPlayerNearPlayer(playerid, i, 10))
  148. {
  149. TogglePlayerControllable(i, 1);
  150. }
  151. }
  152. format(string, sizeof(string), "AdmCmd: %s has froze everyone near.", RPN(playerid));
  153. SendClientMessageToAll(COLOR_LIGHTRED, string);
  154. return 1;
  155. }
  156. CMD:healall(playerid, params[])
  157. {
  158. new amount, string[128];
  159. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  160. foreach(Player, i)
  161. {
  162. if(IsPlayerLoggedIn(i))
  163. {
  164. SetPlayerHealth(i, 100);
  165. SetPlayerArmour(i, 100);
  166. }
  167. }
  168. format(string, sizeof(string), "AdmCmd: %s has healed the HP & Armor for everyone.", RPN(playerid), amount);
  169. SendClientMessageToAll(COLOR_LIGHTRED, string);
  170. return 1;
  171. }
  172.  
  173. CMD:setarmorall(playerid, params[])
  174. {
  175. new amount, string[128];
  176. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  177. if(sscanf(params, "i", amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setarmorall [amount]");
  178. foreach(Player, i)
  179. {
  180. if(IsPlayerLoggedIn(i))
  181. {
  182. SetPlayerArmour(i, amount);
  183. }
  184. }
  185. format(string, sizeof(string), "AdmCmd: %s has set everybody's armor to %d.", RPN(playerid), amount);
  186. SendClientMessageToAll(COLOR_LIGHTRED, string);
  187. return 1;
  188. }
  189.  
  190. CMD:sethp(playerid, params[])
  191. {
  192. new playerb, amount, string[128];
  193. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  194. if(sscanf(params, "ui", playerb, amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sethp [playerid] [amount]");
  195. SetPlayerHealth(playerb, amount);
  196. format(string, sizeof(string), " Administrator %s has set your health to %d", RPN(playerid), amount);
  197. SendClientMessage(playerb, COLOR_WHITE, string);
  198. format(string, sizeof(string), "AdmWarn: %s has set %s's health to %d.", RPN(playerid), RPN(playerb), amount);
  199. SendClientMessageToAll(COLOR_LIGHTRED, string);
  200. return 1;
  201. }
  202.  
  203. CMD:setarmor(playerid, params[])
  204. {
  205. new playerb, amount, string[128];
  206. if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  207. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  208. if(sscanf(params, "ui", playerb, amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setarmor [playerid] [amount]");
  209. SetPlayerArmour(playerb, amount);
  210. format(string, sizeof(string), " Administrator %s has set your armor to %d", RPN(playerid), amount);
  211. SendClientMessage(playerb, COLOR_WHITE, string);
  212. format(string, sizeof(string), "AdmWarn: %s has set %s's armor to %d.", RPN(playerid), RPN(playerb), amount);
  213. SendClientMessageToAll(COLOR_LIGHTRED, string);
  214. return 1;
  215. }
  216.  
  217. CMD:ann(playerid, params[])
  218. {
  219. new string[128];
  220. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  221. if(sscanf(params, "s[128]", string)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cnn [text]");
  222. format(string, sizeof(string), "%s", string);
  223. GameTextForAll(string, 10000, 5);
  224. return 1;
  225. }
  226.  
  227. CMD:unfreeze(playerid, params[])
  228. {
  229. new string[128], playerb;
  230. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  231. if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unfreeze [playerid]");
  232. TogglePlayerControllable(playerb, 1);
  233. format(string, sizeof(string), " You have unfreezed %s.", RPN(playerb));
  234. SendClientMessage(playerid, COLOR_WHITE, string);
  235. format(string, sizeof(string), " Administrator %s has unfreezed you.", RPN(playerid));
  236. SendClientMessage(playerb, COLOR_WHITE, string);
  237. return 1;
  238. }
  239.  
  240. CMD:freeze(playerid, params[])
  241. {
  242. new string[128], playerb;
  243. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  244. if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /freeze [playerid]");
  245. TogglePlayerControllable(playerb, 0);
  246. format(string, sizeof(string), " You have freezed %s.", RPN(playerb));
  247. SendClientMessage(playerid, COLOR_WHITE, string);
  248. format(string, sizeof(string), " Administrator %s has freezed you.", RPN(playerid));
  249. SendClientMessage(playerb, COLOR_WHITE, string);
  250. return 1;
  251. }
  252.  
  253. CMD:veh(playerid, params[])
  254. {
  255. new id, Float:pos[4], col[2];
  256. new cVeh[MAX_CUSTOM_VEHICLES];
  257. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  258. if(!strcmp(params, "destroy"))
  259. {
  260. if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You must be inside a vehicle to destroy it.");
  261. for(new i=0; i<MAX_CUSTOM_VEHICLES; i++)
  262. {
  263. if(GetPlayerVehicleID(playerid) == cVeh[i])
  264. {
  265. //format(string, sizeof(string), "AdmWarn: %s has destroyed a vehicle model %d.", RPN(playerid), GetVehicleModel(i));
  266. //SendAdminMessage(COLOR_DARKRED, 1, string);
  267. DestroyVehicle(cVeh[i]);
  268. i = MAX_CUSTOM_VEHICLES;
  269. return 1;
  270. }
  271. }
  272. SendClientMessage(playerid, COLOR_GREY, "You can't destroy this vehicle.");
  273. return 1;
  274. }
  275. if(sscanf(params, "iii", id, col[0], col[1])) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /veh [vehicleid/destroy] [color1] [color2]");
  276. if(id < 400 || id > 611) return SendClientMessage(playerid, COLOR_GREY, "Vehicles are between 400 and 611.");
  277. GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  278. GetPlayerFacingAngle(playerid, pos[3]);
  279. for(new i=0; i<MAX_CUSTOM_VEHICLES; i++)
  280. {
  281. if(!cVeh[i])
  282. {
  283. cVeh[i] = CreateVehicle(id, pos[0], pos[1], pos[2], pos[3], col[0], col[1], 1200);
  284. i = MAX_CUSTOM_VEHICLES;
  285. }
  286. }
  287. new string[128];
  288. format(string, sizeof(string), "AdmWarn: %s has spawned a vehicle model %d.", RPN(playerid), id);
  289. SendClientMessageToAll(COLOR_LIGHTRED, string);
  290. return 1;
  291. }
  292.  
  293. CMD:kick(playerid, params[])
  294. {
  295. new playerb, string[128];
  296. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  297. if(sscanf(params, "us[128]", playerb, params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [playerid] [reason]");
  298. if(!IsPlayerConnected(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
  299. if(IsPlayerNPC(playerb)) return SendClientMessage(playerid, COLOR_GREY, "You can't kick NPCs out of the server.");
  300. if(IsPlayerAdmin(playerb)) return SendClientMessage(playerid, COLOR_GREY, "You can't kick an admin");
  301. format(string, sizeof(string), "AdmCmd: %s has been kicked by %s, reason: %s", RPN(playerb), RPN(playerid), params);
  302. SendClientMessageToAll(COLOR_LIGHTRED, string);
  303. Kick(playerb);
  304. return 1;
  305. }
  306.  
  307. CMD:ban(playerid, params[])
  308. {
  309. new playerb, string[128];
  310. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  311. if(sscanf(params, "us[128]", playerb, params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");
  312. if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
  313. if(!IsPlayerAdmin(playerb)) return SendClientMessage(playerid, COLOR_GREY, "You can't ban an admin silly!");
  314. format(string, sizeof(string), "AdmCmd: %s has been banned by %s, reason: %s", RPN(playerb), RPN(playerid), params);
  315. SendClientMessageToAll(COLOR_LIGHTRED, string);
  316. // BanList
  317. Ban(playerb);
  318. return 1;
  319. }
  320.  
  321. //Stocks
  322. stock RPN(playerid)
  323. {
  324. new name[MAX_PLAYER_NAME];
  325. GetPlayerName(playerid,name,sizeof(name));
  326. for(new i = 0; i < MAX_PLAYER_NAME; i++)
  327. {
  328. if(name[i] == '_') name[i] = ' ';
  329. }
  330. return name;
  331. }
  332.  
  333. stock IsPlayerNearPlayer(playerid, targetid, Float:radius)
  334. {
  335. new Float:x, Float:y, Float:z;
  336. GetPlayerPos(targetid, x, y, z);
  337. if(IsPlayerInRangeOfPoint(playerid, radius ,x, y, z))
  338. {
  339. return 1;
  340. }
  341. return 0;
  342. }
  343.  
  344.  
  345. stock IsPlayerLoggedIn(playerid)
  346. {
  347. if(IsPlayerConnected(playerid))
  348. {
  349. {
  350. return 1;
  351. }
  352. }
  353. return 0;
  354. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement