[FilterScript] [FS]Language detector
#1

Hey.
This is a simple code i thought of (if anybody else has made something similar, i'm sorry) for admins who are tired of people who refuse to speak english.
Please give credit.

Version 1:
http://pastebin.com/f41c0f09b
Code:
// This script was made by [RTA]Dave_Alter AKA jonrb
// please give credit if you use this
#define RED 0xFF0000EE
#include <a_samp>
public OnPlayerText(playerid, text[])
{
if
(
strfind(text, "я", false) != -1 ||	strfind(text, "ю", false) != -1 ||	strfind(text, "э", false) != -1 ||
strfind(text, "ь", false) != -1 ||	strfind(text, "щ", false) != -1 ||	strfind(text, "ы", false) != -1 ||
strfind(text, "ъ", false) != -1 ||	strfind(text, "ш", false) != -1 ||	strfind(text, "ц", false) != -1 ||
strfind(text, "х", false) != -1 ||	strfind(text, "ф", false) != -1 ||	strfind(text, "у", false) != -1 ||
strfind(text, "т", false) != -1 ||	strfind(text, "с", false) != -1 ||	strfind(text, "р", false) != -1 ||
strfind(text, "п", false) != -1 ||	strfind(text, "о", false) != -1 ||	strfind(text, "н", false) != -1 ||
strfind(text, "м", false) != -1 ||	strfind(text, "л", false) != -1 ||	strfind(text, "к", false) != -1 ||
strfind(text, "й", false) != -1 ||	strfind(text, "и", false) != -1 ||	strfind(text, "з", false) != -1 ||
strfind(text, "ж", false) != -1 ||	strfind(text, "е", false) != -1 ||	strfind(text, "д", false) != -1 ||
strfind(text, "г", false) != -1 ||	strfind(text, "в", false) != -1 ||	strfind(text, "б", false) != -1 ||
strfind(text, "а", false) != -1 //here there is space for more symbols
)
{
SendClientMessage(playerid, RED, "Please speak english in the main chat.");
return 0;
}
else
{
return 1;
}
}
Version 2:
http://pastebin.com/f7ce7bba9
Code:
// This script was made by [RTA]Dave_Alter AKA jonrb
// please give credit if you use this
#define RED 0xFF0000EE
#include <a_samp>
new LangWarn[MAX_PLAYERS];
new IsMuted[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
  IsMuted[playerid] = 0;
  return 1;
}

public OnPlayerText(playerid, text[])
{
  if (IsMuted[playerid] == 1)
	{
	SendClientMessage(playerid, RED, "[RTA]AdminBot: You are muted. Stop trying to talk.");
	return 0;
	}
	else
  if
  (
  strfind(text, "я", false) != -1 ||	strfind(text, "ю", false) != -1 ||	strfind(text, "э", false) != -1 ||
  strfind(text, "ь", false) != -1 ||	strfind(text, "щ", false) != -1 ||	strfind(text, "ы", false) != -1 ||
  strfind(text, "ъ", false) != -1 ||	strfind(text, "ш", false) != -1 ||	strfind(text, "ц", false) != -1 ||
  strfind(text, "х", false) != -1 ||	strfind(text, "ф", false) != -1 ||	strfind(text, "у", false) != -1 ||
  strfind(text, "т", false) != -1 ||	strfind(text, "с", false) != -1 ||	strfind(text, "р", false) != -1 ||
  strfind(text, "п", false) != -1 ||	strfind(text, "о", false) != -1 ||	strfind(text, "н", false) != -1 ||
  strfind(text, "м", false) != -1 ||	strfind(text, "л", false) != -1 ||	strfind(text, "к", false) != -1 ||
  strfind(text, "й", false) != -1 ||	strfind(text, "и", false) != -1 ||	strfind(text, "з", false) != -1 ||
  strfind(text, "ж", false) != -1 ||	strfind(text, "е", false) != -1 ||	strfind(text, "д", false) != -1 ||
  strfind(text, "г", false) != -1 ||	strfind(text, "в", false) != -1 ||	strfind(text, "б", false) != -1 ||
  strfind(text, "а", false) != -1 //here there is space for more symbols
  )
  {
   	LangWarn[playerid] += 1;
		new str[256];
		if (LangWarn[playerid] != 4)
		{
		format(str, sizeof(str), "[RTA]AdminBot: Speak English in the main chat please! You have %i chances left!", 4-LangWarn[playerid] );
SendClientMessage(playerid, RED, str);
}
else
{
new string[256], name[256];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "** Player %s has been muted. (Reason: 'Refusing to speak english.')", name);
SendClientMessage(playerid, RED, string);
IsMuted[playerid] = 1;
}
return 0;
}
else
{
return 1;
}
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/unmuteall"))
{
for(new player;player<MAX_PLAYERS;player++)
{
IsMuted[playerid] = 0;
SendClientMessage(playerid, RED, "You have been un-muted!");
}
}
return 1;
}
PS. is this in the right place?
Reply
#2

hmmm this place is ok i guess
u could post it better in UZsefull Snippet Thread but dw^^
well
for ur firstone i guess
its good
^^
nice
its a bit simple but ok
Reply
#3

well i posted it somewhere else as well but some guy told me to put it here instead
Reply
#4

Good work!Also,nice idea...You can block with this,loads of some kind of crashes..

Ecko
Reply
#5

It is an issue and probably will not work well as I see all characters mostly the same.. It's a problem..


Also,
pawn Code:
if (strcmp(cmdtext, "/unmuteall") == 1)
wtf?
Reply
#6

Quote:
Originally Posted by jonrb
Hey.
This is a simple code i thought of (if anybody else has made something similar, i'm sorry) for admins who are tired of people who refuse to speak english.
Please give credit.

Version 1:
http://pastebin.com/f41c0f09b
Code:
// This script was made by [RTA]Dave_Alter AKA jonrb
// please give credit if you use this
#define RED 0xFF0000EE
#include <a_samp>
public OnPlayerText(playerid, text[])
{
if
(
strfind(text, "я", false) != -1 ||	strfind(text, "ю", false) != -1 ||	strfind(text, "э", false) != -1 ||
strfind(text, "ь", false) != -1 ||	strfind(text, "щ", false) != -1 ||	strfind(text, "ы", false) != -1 ||
strfind(text, "ъ", false) != -1 ||	strfind(text, "ш", false) != -1 ||	strfind(text, "ц", false) != -1 ||
strfind(text, "х", false) != -1 ||	strfind(text, "ф", false) != -1 ||	strfind(text, "у", false) != -1 ||
strfind(text, "т", false) != -1 ||	strfind(text, "с", false) != -1 ||	strfind(text, "р", false) != -1 ||
strfind(text, "п", false) != -1 ||	strfind(text, "о", false) != -1 ||	strfind(text, "н", false) != -1 ||
strfind(text, "м", false) != -1 ||	strfind(text, "л", false) != -1 ||	strfind(text, "к", false) != -1 ||
strfind(text, "й", false) != -1 ||	strfind(text, "и", false) != -1 ||	strfind(text, "з", false) != -1 ||
strfind(text, "ж", false) != -1 ||	strfind(text, "е", false) != -1 ||	strfind(text, "д", false) != -1 ||
strfind(text, "г", false) != -1 ||	strfind(text, "в", false) != -1 ||	strfind(text, "б", false) != -1 ||
strfind(text, "а", false) != -1 //here there is space for more symbols
)
{
SendClientMessage(playerid, RED, "Please speak english in the main chat.");
return 0;
}
else
{
return 1;
}
}
Version 2:
http://pastebin.com/f7ce7bba9
Code:
// This script was made by [RTA]Dave_Alter AKA jonrb
// please give credit if you use this
#define RED 0xFF0000EE
#include <a_samp>
new LangWarn[MAX_PLAYERS];
new IsMuted[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
  IsMuted[playerid] = 0;
  return 1;
}

public OnPlayerText(playerid, text[])
{
  if (IsMuted[playerid] == 1)
	{
	SendClientMessage(playerid, RED, "[RTA]AdminBot: You are muted. Stop trying to talk.");
	return 0;
	}
	else
  if
  (
  strfind(text, "я", false) != -1 ||	strfind(text, "ю", false) != -1 ||	strfind(text, "э", false) != -1 ||
  strfind(text, "ь", false) != -1 ||	strfind(text, "щ", false) != -1 ||	strfind(text, "ы", false) != -1 ||
  strfind(text, "ъ", false) != -1 ||	strfind(text, "ш", false) != -1 ||	strfind(text, "ц", false) != -1 ||
  strfind(text, "х", false) != -1 ||	strfind(text, "ф", false) != -1 ||	strfind(text, "у", false) != -1 ||
  strfind(text, "т", false) != -1 ||	strfind(text, "с", false) != -1 ||	strfind(text, "р", false) != -1 ||
  strfind(text, "п", false) != -1 ||	strfind(text, "о", false) != -1 ||	strfind(text, "н", false) != -1 ||
  strfind(text, "м", false) != -1 ||	strfind(text, "л", false) != -1 ||	strfind(text, "к", false) != -1 ||
  strfind(text, "й", false) != -1 ||	strfind(text, "и", false) != -1 ||	strfind(text, "з", false) != -1 ||
  strfind(text, "ж", false) != -1 ||	strfind(text, "е", false) != -1 ||	strfind(text, "д", false) != -1 ||
  strfind(text, "г", false) != -1 ||	strfind(text, "в", false) != -1 ||	strfind(text, "б", false) != -1 ||
  strfind(text, "а", false) != -1 //here there is space for more symbols
  )
  {
   	LangWarn[playerid] += 1;
		new str[256];
		if (LangWarn[playerid] != 4)
		{
		format(str, sizeof(str), "[RTA]AdminBot: Speak English in the main chat please! You have %i chances left!", 4-LangWarn[playerid] );
SendClientMessage(playerid, RED, str);
}
else
{
new string[256], name[256];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "** Player %s has been muted. (Reason: 'Refusing to speak english.')", name);
SendClientMessage(playerid, RED, string);
IsMuted[playerid] = 1;
}
return 0;
}
else
{
return 1;
}
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/unmuteall") == 1)
{
for(new player;player<MAX_PLAYERS;player++)
{
IsMuted[playerid] = 0;
SendClientMessage(playerid, RED, "You have been un-muted!");
}
}
return 1;
}
PS. is this in the right place?
Very Helpful for deferent languadge players!
Reply
#7

Nice script, but the person speaking the different language may not know english so how will they understand that they need to speak english?
Reply
#8

Quote:
Originally Posted by .::: [E
Ecko :::. ]
You can block with this,loads of some kind of crashes..
I don't understand what you mean.

Quote:
Originally Posted by [B
Vortex ]
Nice script, but the person speaking the different language may not know english so how will they understand that they need to speak english?
Yes, i thought of that too.
you could put
Code:
SendClientMessage(playerid, RED, "Please speak english in the main chat.");
SendClientMessage(playerid, RED, "Bitte sprechen Sie Englisch im Chat.");
SendClientMessage(playerid, RED, "S'il vous plaоt parler anglais dans le chat.");
SendClientMessage(playerid, RED, "Vжr venlig at tale engelsk i chatten.");
SendClientMessage(playerid, RED, "Si prega di parlare l'inglese in chat.");
SendClientMessage(playerid, RED, "Gelieve Engels spreken in de chat.");
//these are rough translations
Or perhaps combine it with an IP "country detector" that tells the player to speak english in whatever the main languages of his country are.
Reply
#9

Needs a little work, you wouldn't mind if I expand your idea, would you?
Reply
#10

This is a good script causes scripts to not function properly when someone uses that type of text, It breaks the public.
Reply
#11

Shit. Nice work man. Why didn't anybody think of this before.
Reply
#12

Does it do forbid all languages(such as 中文-chinese)?
I doubt it.
If yes, it's a great job/
Reply
#13

You could use like this:
Code:
new i=0;
while(text[i] != EOS)
{
  if((!('A' <= text[i] <= 'Z')) && (!('a' <= text[i] <= 'z')) && (!('0' <= text[i] <= '9')))
  {
      //...msg...
     return 0;
  }
}
This indeed will be slower because it loops thru whole string, but you can't filter milons and milons different special letters in thousands and thousands different languages
btw. strfind loops thru string anyway...
Reply
#14

Quote:
Originally Posted by JoeBullet
You could use like this:
Code:
code
This indeed will be slower because it loops thru whole string, but you can't filter milons and milons different special letters in thousands and thousands different languages
btw. strfind loops thru string anyway...
So using a question mark, exclamation mark etc counts as foreign language now?

I would use...

Code:
public OnPlayerText(playerid, text[])
{
  new i;
  while(text[i])
  {
    if(191 <= text[i] <= 255)
    {
      SendClientMessage(playerid, 0xFF0000EE, "Please speak english in the main chat.");
      return 0;
    }
    i++;
  }
  return 1;
}
Chances are it misses out some symbols, but thats better than nothing.
Reply
#15

Quote:
Originally Posted by paytas
Quote:
Originally Posted by Abernethy
Shit. Nice work man. Why didn't anybody think of this before.
your ignorant. 0rb did that like 1 year ago, using google translate language detection... much better than this shit.
Stop being an asswad, and be respectful. The creator probably didn't know that.

Nice work anyways.
Reply
#16

Goodjob mate, maybe take away some of the ideas/tips people are providing and release a new version sometime.
Reply
#17

Quote:
Originally Posted by kc
...
Yeah i know i missed some chars but i think everyone can get a point, ok?
And point is that when there is lot of something that must be forbidden, better solution that you define what you want allow.. that's is more logic and faster anyway...
Reply
#18

I think (correct me if i'm wrong) that the loops suggested before would also disallow punctuation...
@[K4L]Jake yes, as long as you keep the credits
Reply
#19

if i say "hola, estoy hablando en otro idioma", the fs wont kick me because i didnґt use any of those letters
Reply
#20

Yeah but from what i've experienced most people use accents...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)