Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define COMMAND_BLOCKED_MSG "This command has been blocked, you cannot use it."
- #define COMMAND_BLOCKED_COLOR 0xFF0000FF
- #define MAX_COMMAND_BLOCKED 25
- new BlockedCommand[MAX_COMMAND_BLOCKED][25];
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new bool:CMD_BLOCKED = false;
- for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
- {
- if(BlockedCommand[i][0] == '\0') continue;
- if(cmdtext[0] == '/')
- {
- if(!strcmp(BlockedCommand[i], cmdtext[1], true)) CMD_BLOCKED = true;
- }
- else if(!strcmp(BlockedCommand[i], cmdtext, true)) CMD_BLOCKED = true;
- else continue;
- }
- if(CMD_BLOCKED) return SendClientMessage(playerid, COMMAND_BLOCKED_COLOR, COMMAND_BLOCKED_MSG);
- new split = strfind(cmdtext, " ", true), command[60];
- if(split != -1)
- {
- strmid(command, cmdtext, 0, split);
- strdel(cmdtext, 0, split + 1);
- }
- else format(command, sizeof(command), "%s", cmdtext);
- if(!strcmp(command, "/blockcommand", true) || !strcmp(command, "/blockcmd", true))
- {
- if(!IsPlayerAdmin(playerid)) return 0;
- if(split == -1) return SendClientMessage(playerid, -1, "USAGE: /blockcommand [command]");
- if(cmdtext[0] == '/') strdel(cmdtext, 0, 1);
- new slotfree = -1;
- for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
- {
- if(BlockedCommand[i][0] == '\0') slotfree = i;
- else if(!strcmp(BlockedCommand[i], cmdtext, true)) return SendClientMessage(playerid, -1, "This command is already blocked. Use '/unblockcommand [command]' to unblock it.");
- if(slotfree != -1) continue;
- }
- if(slotfree == -1) return SendClientMessage(playerid, -1, "You have reached the maximum limit of blocked commands. Please unblock some before proceeding.");
- format(BlockedCommand[slotfree], 25, "%s", cmdtext);
- SendClientMessage(playerid, -1, "SUCCESS: Command Blocked successfully.");
- return 1;
- }
- if(!strcmp(command, "/unblockcommand", true) || !strcmp(command, "/unblockcmd", true))
- {
- if(!IsPlayerAdmin(playerid)) return 0;
- if(split == -1) return SendClientMessage(playerid, -1, "USAGE: /unblockcommand [command]");
- if(cmdtext[0] == '/') strdel(cmdtext, 0, 1);
- new slotfree = -1;
- for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
- {
- if(!strcmp(BlockedCommand[i], cmdtext, true) && BlockedCommand[i][0] != '\0')
- {
- slotfree = i;
- break;
- }
- }
- if(slotfree == -1) return SendClientMessage(playerid, -1, "This command is not blocked. Use '/blockcommand [command]' to block it.");
- strdel(BlockedCommand[slotfree], 0, strlen(BlockedCommand[slotfree]));
- SendClientMessage(playerid, -1, "SUCCESS: Command Unblocked successfully.");
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement