03.02.2014, 14:13
I want to make, when player in OnPlayerText type text which contains forbbiden word or some IP adress to send message only to admins, but not to show the text. How can I do it? Thank you.
public OnPlayerText(playerid, text[]) { if(strfind(text, "fucker", true) != -1) { SendClientMessage(playerid, 0xFF0000AA, "Forbidden Word."); return 0; } if(strfind(text, "bitch", true) != -1) { SendClientMessage(playerid, 0xFF0000AA, "Forbidden Word."); return 0; } return 1; }
I want to make, when player in OnPlayerText type text which contains forbbiden word or some IP adress to send message only to admins, but not to show the text. How can I do it? Thank you.
|
//A function called "DetectAdv" which will detect if an IP is found on the str.
stock DetectAdv(stradv[])
{
new temp_Count;
for(new i; stradv[i] != 0; ++i) {
if(('0' <= stradv[i] <= '9') || stradv[i] == '.' || stradv[i] == ':') {
if((stradv[i] == '.') && (stradv[i + 1] != '.') && ('0' <= stradv[i - 1] <= '9')) {
++temp_Count;
}
continue;
}
}
return (temp_Count > 2);
}
//An array called "badwords" which contains a list of badwords.
new badwords[][] =
{
{"fuck"},
{"bitch"},
{"asshole"}}; //You can add more, the last word doesn't need to have a , .
public OnPlayerText(playerid, text[])
{
new
bool:Found = false;
for(new i; i< sizeof(badwords); i++) //Looping around the array which contains badwords.
{
//If the chat contains any words specified on the array, it will detect.
if(strfind(text, badwords[i], true) != -1) Found = true;
}
if(DetectAdv(text)) Found = true; //Or if an IP is pasted, it will detect.
if(Found == true) //If detected!
{
new
string[128],
Lname[MAX_PLAYER_NAME];
//Getting the player's name to show it to admins.
GetPlayerName(playerid, Lname, sizeof(Lname));
//Formatting the text to show it to admin with player's name and ID!
format(string, sizeof(string), "%s(ID:%d) : %s", Lname, playerid, text);
for(new i; i< GetMaxPlayers(); i++) //Looping through all players.
{
if(!IsPlayerConnected(i)) continue; //If not connected, it will skip.
if(!IsPlayerAdmin(i)) continue; //The same goes here too.
SendClientMessage(i, -1, string); //Sends to online RCON admins.
}
return !SendClientMessage(playerid, 0xFF0000FF, "Warning! You're not allowed to use forbidden chat!");
}
return 1;
}
pawn Код:
|
new badwords[][] = { {"fuck"}, {"bitch"}, {"asshole"} {"f u c k"}}; //You can add more, the last word doesn't need to have a , .