CaptainB

Block Command

Sep 7th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. /* Includes */
  4. #include <a_samp>
  5. #include <sscanf2>
  6. #include <Dini>
  7. #include <zcmd>
  8.  
  9. #define COLOR_YELLOW 0xFFFF00FF
  10.  
  11. public OnFilterScriptInit()
  12. {
  13. return 1;
  14. }
  15.  
  16. public OnFilterScriptExit()
  17. {
  18. return 1;
  19. }
  20.  
  21. public OnPlayerCommandReceived(playerid, cmdtext[])
  22. {
  23. if(cmdtext[0] == '/') strdel(cmdtext, 0, 1);
  24. if(strfind(cmdtext, " ") != -1)
  25. {
  26. strdel(cmdtext, strfind(cmdtext, " "), strlen(cmdtext));
  27. }
  28. if(dini_Isset("Commands/cmds.ini", cmdtext))
  29. {
  30. SendClientMessage(playerid, COLOR_YELLOW, "[BR BLOCK] Unknown Command.");
  31. return 0;
  32. }
  33. return 1;
  34. }
  35.  
  36. CMD:blockcmd(playerid, params[])
  37. {
  38. new cmd[200];
  39. if(sscanf(params, "s[200]", cmd)) return SendClientMessage(playerid, -1, "USAGE: /blockcmd [Command]");
  40. if(cmd[0] == '/') strdel(cmd, 0, 1);
  41. if(dini_Isset("Commands/cmds.ini", cmd)) return SendClientMessage(playerid, COLOR_YELLOW, "Error: Command Already Blocked!");
  42. dini_Set("Commands/cmds.ini", cmd, "Blocked");
  43. new string[256];
  44. format(string, sizeof(string), "%s has been blocked", cmd);
  45. SendClientMessage(playerid, COLOR_YELLOW, string);
  46. return 1;
  47. }
  48.  
  49. CMD:unblockcmd(playerid, params[])
  50. {
  51. new cmd[200];
  52. if(sscanf(params, "s[200]", cmd)) return SendClientMessage(playerid, -1, "USAGE: /unblockcmd [Command]");
  53. if(cmd[0] == '/') strdel(cmd, 0, 1);
  54. if(!dini_Isset("Commands/cmds.ini", cmd)) return SendClientMessage(playerid, COLOR_YELLOW, "Error: Command isn't Blocked!");
  55. dini_Unset("Commands/cmds.ini", cmd);
  56. new string[256];
  57. format(string, sizeof(string), "%s has been unblocked", cmd);
  58. SendClientMessage(playerid, COLOR_YELLOW, string);
  59. return 1;
  60. }
  61.  
  62. CMD:blockedcmds(playerid, params[])
  63. {
  64. new strings[128], File: file = fopen("BlockedCmds/cmds.ini", io_read), blockedcmds=1;
  65. SendClientMessage(playerid, COLOR_YELLOW, "[Blocked Commands Of This Server]:");
  66. while(fread(file, strings))
  67. {
  68. format(strings, sizeof(strings), "%d) %s", blockedcmds, strings);
  69. SendClientMessage(playerid, COLOR_YELLOW, strings);
  70. blockedcmds ++;
  71. }
  72. fclose(file);
  73. return 1;
  74. }
Add Comment
Please, Sign In to add comment