Advertisement
ThresholdSAMP

[Filterscript] Command Blocker v1.1

Mar 22nd, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define COMMAND_BLOCKED_MSG "This command has been blocked, you cannot use it."
  4. #define COMMAND_BLOCKED_COLOR 0xFF0000FF
  5. #define MAX_COMMAND_BLOCKED 25
  6.  
  7. new BlockedCommand[MAX_COMMAND_BLOCKED][25];
  8.  
  9. public OnPlayerCommandText(playerid, cmdtext[])
  10. {
  11. new bool:CMD_BLOCKED = false;
  12. for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
  13. {
  14. if(BlockedCommand[i][0] == '\0') continue;
  15. if(cmdtext[0] == '/')
  16. {
  17. if(!strcmp(BlockedCommand[i], cmdtext[1], true)) CMD_BLOCKED = true;
  18. }
  19. else if(!strcmp(BlockedCommand[i], cmdtext, true)) CMD_BLOCKED = true;
  20. else continue;
  21. }
  22. if(CMD_BLOCKED) return SendClientMessage(playerid, COMMAND_BLOCKED_COLOR, COMMAND_BLOCKED_MSG);
  23.  
  24. new split = strfind(cmdtext, " ", true), command[60];
  25. if(split != -1)
  26. {
  27. strmid(command, cmdtext, 0, split);
  28. strdel(cmdtext, 0, split + 1);
  29. }
  30. else format(command, sizeof(command), "%s", cmdtext);
  31.  
  32. if(!strcmp(command, "/blockcommand", true) || !strcmp(command, "/blockcmd", true))
  33. {
  34. if(!IsPlayerAdmin(playerid)) return 0;
  35. if(split == -1) return SendClientMessage(playerid, -1, "USAGE: /blockcommand [command]");
  36. if(cmdtext[0] == '/') strdel(cmdtext, 0, 1);
  37. new slotfree = -1;
  38. for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
  39. {
  40. if(BlockedCommand[i][0] == '\0') slotfree = i;
  41. else if(!strcmp(BlockedCommand[i], cmdtext, true)) return SendClientMessage(playerid, -1, "This command is already blocked. Use '/unblockcommand [command]' to unblock it.");
  42. if(slotfree != -1) continue;
  43. }
  44. if(slotfree == -1) return SendClientMessage(playerid, -1, "You have reached the maximum limit of blocked commands. Please unblock some before proceeding.");
  45. format(BlockedCommand[slotfree], 25, "%s", cmdtext);
  46. SendClientMessage(playerid, -1, "SUCCESS: Command Blocked successfully.");
  47. return 1;
  48. }
  49.  
  50. if(!strcmp(command, "/unblockcommand", true) || !strcmp(command, "/unblockcmd", true))
  51. {
  52. if(!IsPlayerAdmin(playerid)) return 0;
  53. if(split == -1) return SendClientMessage(playerid, -1, "USAGE: /unblockcommand [command]");
  54. if(cmdtext[0] == '/') strdel(cmdtext, 0, 1);
  55. new slotfree = -1;
  56. for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
  57. {
  58. if(!strcmp(BlockedCommand[i], cmdtext, true) && BlockedCommand[i][0] != '\0')
  59. {
  60. slotfree = i;
  61. break;
  62. }
  63. }
  64. if(slotfree == -1) return SendClientMessage(playerid, -1, "This command is not blocked. Use '/blockcommand [command]' to block it.");
  65. strdel(BlockedCommand[slotfree], 0, strlen(BlockedCommand[slotfree]));
  66. SendClientMessage(playerid, -1, "SUCCESS: Command Unblocked successfully.");
  67. return 1;
  68. }
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement