Advertisement
ThresholdSAMP

[Filterscript] Command Blocker v1.2

Mar 29th, 2015
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define LIST_COMMAND true
  4. #define LIST_USE_DIALOG false
  5.  
  6. #define COMMAND_BLOCKED_MSG "This command has been blocked, you cannot use it."
  7. #define COMMAND_BLOCKED_COLOR 0xFF0000FF
  8. #define MAX_COMMAND_BLOCKED 25
  9.  
  10. new BlockedCommand[MAX_COMMAND_BLOCKED][25];
  11.  
  12. public OnPlayerCommandText(playerid, cmdtext[])
  13. {
  14. new bool:CMD_BLOCKED = false;
  15. for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
  16. {
  17. if(BlockedCommand[i][0] == '\0') continue;
  18. if(cmdtext[0] == '/')
  19. {
  20. if(!strcmp(BlockedCommand[i], cmdtext[1], true)) CMD_BLOCKED = true;
  21. }
  22. else if(!strcmp(BlockedCommand[i], cmdtext, true)) CMD_BLOCKED = true;
  23. else continue;
  24. }
  25. if(CMD_BLOCKED) return SendClientMessage(playerid, COMMAND_BLOCKED_COLOR, COMMAND_BLOCKED_MSG);
  26.  
  27. #if LIST_COMMAND == true
  28. if(!strcmp(cmdtext, "/blocklist", true))
  29. {
  30. if(!IsPlayerAdmin(playerid)) return 0;
  31. #if LIST_USE_DIALOG == true
  32. new fstr[600], str[30];
  33. for(new i = 0; i < sizeof(BlockedComand); i++)
  34. {
  35. if(BlockedCommand[i][0] == '\0') continue;
  36. format(str, sizeof(str), "/%s\n", BlockedCommand[i]);
  37. strcat(fstr, str);
  38. }
  39. ShowPlayerDialog(playerid, 14653, DIALOG_STYLE_MSGBOX, "Blocked Commands", fstr, "Okay", "");
  40. #else
  41. new str[30];
  42. SendClientMessage(playerid, 0xFF0000FF, "Blocked Commands:");
  43. for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
  44. {
  45. if(BlockedCommand[i][0] == '\0') continue;
  46. format(str, sizeof(str), "/%s", BlockedCommand[i]);
  47. SendClientMessage(playerid, -1, str);
  48. }
  49. #endif
  50. return 1;
  51. }
  52. #endif
  53.  
  54. new split = strfind(cmdtext, " ", true), command[60];
  55. if(split != -1)
  56. {
  57. strmid(command, cmdtext, 0, split);
  58. strdel(cmdtext, 0, split + 1);
  59. }
  60. else format(command, sizeof(command), "%s", cmdtext);
  61.  
  62. if(!strcmp(command, "/blockcommand", true) || !strcmp(command, "/blockcmd", true))
  63. {
  64. if(!IsPlayerAdmin(playerid)) return 0;
  65. if(split == -1) return SendClientMessage(playerid, -1, "USAGE: /blockcommand [command]");
  66. if(cmdtext[0] == '/') strdel(cmdtext, 0, 1);
  67. new slotfree = -1;
  68. for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
  69. {
  70. if(BlockedCommand[i][0] == '\0') slotfree = i;
  71. else if(!strcmp(BlockedCommand[i], cmdtext, true)) return SendClientMessage(playerid, -1, "This command is already blocked. Use '/unblockcommand [command]' to unblock it.");
  72. if(slotfree != -1) continue;
  73. }
  74. if(slotfree == -1) return SendClientMessage(playerid, -1, "You have reached the maximum limit of blocked commands. Please unblock some before proceeding.");
  75. format(BlockedCommand[slotfree], 25, "%s", cmdtext);
  76. SendClientMessage(playerid, -1, "SUCCESS: Command Blocked successfully.");
  77. return 1;
  78. }
  79.  
  80. if(!strcmp(command, "/unblockcommand", true) || !strcmp(command, "/unblockcmd", true))
  81. {
  82. if(!IsPlayerAdmin(playerid)) return 0;
  83. if(split == -1) return SendClientMessage(playerid, -1, "USAGE: /unblockcommand [command]");
  84. if(cmdtext[0] == '/') strdel(cmdtext, 0, 1);
  85. new slotfree = -1;
  86. for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
  87. {
  88. if(!strcmp(BlockedCommand[i], cmdtext, true) && BlockedCommand[i][0] != '\0')
  89. {
  90. slotfree = i;
  91. break;
  92. }
  93. }
  94. if(slotfree == -1) return SendClientMessage(playerid, -1, "This command is not blocked. Use '/blockcommand [command]' to block it.");
  95. strdel(BlockedCommand[slotfree], 0, strlen(BlockedCommand[slotfree]));
  96. SendClientMessage(playerid, -1, "SUCCESS: Command Unblocked successfully.");
  97. return 1;
  98. }
  99. return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement