SA-MP Forums Archive
[FilterScript] [FS]Language detector - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] [FS]Language detector (/showthread.php?tid=93986)

Pages: 1 2


[FS]Language detector - jonrb - 27.08.2009

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?


Re: [FS]Language detector - saiberfun - 27.08.2009

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


Re: [FS]Language detector - jonrb - 27.08.2009

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


Re: [FS]Language detector - .::: Ecko :::. - 27.08.2009

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

Ecko


Re: [FS]Language detector - MenaceX^ - 27.08.2009

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?


Re: [FS]Language detector - SanMarinoRP - 27.08.2009

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!


Re: [FS]Language detector - _Vortex - 27.08.2009

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


Re: [FS]Language detector - jonrb - 28.08.2009

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.


Re: [FS]Language detector - DMSOrg - 29.08.2009

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


Re: [FS]Language detector - FreshKilla - 29.08.2009

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


Re: [FS]Language detector - Abernethy - 30.08.2009

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


Re: [FS]Language detector - yezizhu - 30.08.2009

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


Re: [FS]Language detector - Google63 - 30.08.2009

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...


Re: [FS]Language detector - kc - 30.08.2009

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.


Re: [FS]Language detector - Tannz0rz - 30.08.2009

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.


Re: [FS]Language detector - Infamous - 30.08.2009

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


Re: [FS]Language detector - Google63 - 30.08.2009

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...


Re: [FS]Language detector - jonrb - 12.09.2009

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


Re: [FS]Language detector - agusfn20 - 12.09.2009

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


Re: [FS]Language detector - jonrb - 21.10.2009

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