pawn Code:
#include <a_samp>
#define LIST_COMMAND true
#define LIST_USE_DIALOG false
#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);
#if LIST_COMMAND == true
if(!strcmp(cmdtext, "/blocklist", true))
{
if(!IsPlayerAdmin(playerid)) return 0;
#if LIST_USE_DIALOG == true
new fstr[600], str[30];
for(new i = 0; i < sizeof(BlockedComand); i++)
{
if(BlockedCommand[i][0] == '\0') continue;
format(str, sizeof(str), "/%s\n", BlockedCommand[i]);
strcat(fstr, str);
}
ShowPlayerDialog(playerid, 14653, DIALOG_STYLE_MSGBOX, "Blocked Commands", fstr, "Okay", "");
#else
new str[30];
SendClientMessage(playerid, 0xFF0000FF, "Blocked Commands:");
for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
{
if(BlockedCommand[i][0] == '\0') continue;
format(str, sizeof(str), "/%s", BlockedCommand[i]);
SendClientMessage(playerid, -1, str);
}
#endif
return 1;
}
#endif
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;
}