Skip to content

Instantly share code, notes, and snippets.

@earlwlkr
Created January 19, 2015 14:31
Show Gist options
  • Save earlwlkr/c525a736719826b99d36 to your computer and use it in GitHub Desktop.
Save earlwlkr/c525a736719826b99d36 to your computer and use it in GitHub Desktop.
#include <a_samp>
new words_blacklist[][24] = {
// Ghi nhung chu bi cam vao day.
"ditmeserver", "blabla"
};
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Words blacklist loaded");
print("--------------------------------------\n");
return 1;
}
// Functions
// Kiem tra chuoi tu string_index cua string co khop voi chuoi tu sub_index cua sub.
stock check_from_index(string[], sub[], string_index, sub_index)
{
if (sub_index >= strlen (sub))
return 1;
if (string[string_index] == sub[sub_index] || string[string_index] == sub[sub_index] + 32
|| string[string_index] == sub[sub_index] - 32)
return check_from_index(string, sub, ++string_index, ++sub_index);
return 0;
}
stock contains(string[], sub[])
{
for (new i = 0; i != strlen (string); i++)
{
if (check_from_index(string, sub, i, 0))
return 1;
}
return 0;
}
// Tra ve 1 neu chua nhung chu bi cam.
stock ContainsBlacklistedWord(text[])
{
for (new i = 0; i != sizeof (words_blacklist); i++)
{
if (contains(text, words_blacklist[i]))
return 1;
}
return 0;
}
public OnPlayerText(playerid, text[])
{
// Kiem tra, neu co chua nhung chu bi cam thi kick.
if (ContainsBlacklistedWord(text))
Kick(playerid);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (ContainsBlacklistedWord(cmdtext))
Kick(playerid);
return 0;
}
public OnRconCommand(cmd[])
{
if (ContainsBlacklistedWord(cmd))
printf("- Contains blacklisted word(s).");
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment