SA-MP Forums Archive
Blocking language at OnPlayerText - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Blocking language at OnPlayerText (/showthread.php?tid=216704)



Blocking language at OnPlayerText - yanir3 - 26.01.2011

Someone knows how to block some language on OnPlayerText?
So someone will not talk Spanish on chat.


Re: Blocking language at OnPlayerText - Retardedwolf - 26.01.2011

Return 0 to prevent it from appearing in chat.


Re: Blocking language at OnPlayerText - PeteShag - 26.01.2011

You can't really block a whole language but you can block characters.


Re: Blocking language at OnPlayerText - Grim_ - 26.01.2011

You would need to actually check the text that is passed to OnPlayerText and see if it contains Spanish words or symbols. If it does, you can return 0, as Retardedwolf said, to prevent the text from being sent.

Unless you want to write an array of all the Spanish words, then just check for a few common ones or Spanish symbols (for example, n with tilt symbol). Besides that, I cannot think of another way of preventing it. It may have gotten past me here at 2AM, however.


Re: Blocking language at OnPlayerText - yanir3 - 26.01.2011

Look what I tried to do :
if(text[45] == "§") return SendClientMessage(playerid,WHITE,"You can't use this language");
§ is only for example

Now I tried to type something and it just writes the text to all of the server(Global), It's a RP server..


Re: Blocking language at OnPlayerText - Grim_ - 26.01.2011

pawn Код:
if( text[ 45 ] == '§' )
{
   SendClientMessage( playerid, WHITE, "You can't use this language" );
   return 0;
}
- You need to use single quotes in order to check for a single symbol.
- You need to return 0 to prevent the text.


Re: Blocking language at OnPlayerText - yanir3 - 26.01.2011

Its still fucking up my OnPlayerText :[


Re: Blocking language at OnPlayerText - Grim_ - 26.01.2011

The problem is most likely that you are checking the 45th character in the text passed to OnPlayerText. Are you trying to see if the text is just simply in there? If so:
pawn Код:
if( strfind( text, "§", true ) != -1 )
{
   SendClientMessage( playerid, WHITE, "You can't use this language!" );
   return 0;
}
What exactly are you trying to accomplish? If you provide me with an answer to that question, along with your OnPlayerText callback, I may be able to assist you further.