#define CL(%0) view_as<CommandListener>(BlockCommand), %0
ArrayList g_hArray;
public void OnMapStart()
{
char sBuffer[64];
if(g_hArray != null)
{
int iSize;
if((iSize = g_hArray.Length) > 0)
{
for(int i; i < iSize; i++)
{
g_hArray.GetString(i, sBuffer, sizeof(sBuffer));
RemoveCommandListener(CL(sBuffer));
}
g_hArray.Clear();
}
}
else g_hArray = new ArrayList(ByteCountToCells(sizeof(sBuffer)));
File hFile; BuildPath(Path_SM, sBuffer, sizeof(sBuffer), "configs/block_commands.ini");
if((hFile = OpenFile(sBuffer, "r")) == null) SetFailState("No found file: %s", sBuffer);
while(hFile.ReadLine(sBuffer, sizeof(sBuffer)))
{
TrimString(sBuffer);
if(sBuffer[0] && StrContains(sBuffer, "//") == -1)
{
AddCommandListener(CL(sBuffer));
g_hArray.PushString(sBuffer);
}
}
delete hFile;
}
Action BlockCommand(int iClient)
{
if(CheckClient(iClient, NULL_STRING, false)) return Plugin_Handled;
return Plugin_Continue;
}
public Action OnClientSayCommand(int iClient, const char[] sCommand, const char[] sArgs)
{
if(CheckClient(iClient, sArgs, true)) return Plugin_Handled;
return Plugin_Continue;
}
bool CheckClient(int iClient, const char[] sMessage, bool bChat)
{
if(iClient > 0/* && IsPlayerAlive(iClient)*/ && sMessage[0] == 0 || g_hArray.FindString(sMessage) != -1)
{
if(bChat) PrintToChat(iClient, "Данная команда была запрещена на сервере!");
else PrintToConsole(iClient, "Данная команда была запрещена на сервере!");
return true;
}
return false;
}