SA-MP Forums Archive
How to format 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)
+--- Thread: How to format OnPlayerText (/showthread.php?tid=653134)



How to format OnPlayerText - RichKiez - 27.04.2018

How to format a text entered by the player. For example if the player enters "This is Test" when SendClientMessage it will turn into. "This is Command Test." .And my problem is how to convert "Text" to "Command Test"
Help me, please.


Re: How to format OnPlayerText - Dutheil - 27.04.2018

For texts : https://sampwiki.blast.hk/wiki/OnPlayerText
For commands : https://sampwiki.blast.hk/wiki/OnPlayerCommandText
For Rcon commands : https://sampwiki.blast.hk/wiki/OnRconCommand


Re: How to format OnPlayerText - RichKiez - 27.04.2018

Quote:
Originally Posted by Dutheil
Посмотреть сообщение
No, my opinion is, if the player says something like 'hello, <bad word here> you' change it into 'hi, **** you' WITHOUT removing the entire message


Re: How to format OnPlayerText - Dutheil - 27.04.2018

You need to search the bad words and replace them.
strfind and strreplace


Re: How to format OnPlayerText - RichKiez - 27.04.2018

Quote:
Originally Posted by Dutheil
Посмотреть сообщение
You need to search the bad words and replace them.
strfind and strreplace
Can you give me an example code


Re: How to format OnPlayerText - Zeus666 - 27.04.2018

Quote:
Originally Posted by RichKiez
Посмотреть сообщение
Can you give me an example code
PHP код:
new InvalidWords[][100] =
{
     
"idiot",
     
"stupid",
     
"fuck",
     
"ass",
     
"lick",
     
"suck",
     
"dick",
     
"pussy",
     
"cum",
     
"sperm",
     
"gay"
};
public 
OnPlayerText(playeridtext[])
{
        new 
string[128];
        for(new 
cnt 0cnt sizeof(InvalidWords); cnt++)
        {
        if(
strfind(textInvalidWords[cnt], true) != -1)
            {
                      
Kick(playerid);
                }
        }
        return 
1;




Re: How to format OnPlayerText - RichKiez - 27.04.2018

Quote:
Originally Posted by Zeus666
Посмотреть сообщение
PHP код:
new InvalidWords[][100] =
{
     
"idiot",
     
"stupid",
     
"fuck",
     
"ass",
     
"lick",
     
"suck",
     
"dick",
     
"pussy",
     
"cum",
     
"sperm",
     
"gay"
};
public 
OnPlayerText(playeridtext[])
{
        new 
string[128];
        for(new 
cnt 0cnt sizeof(InvalidWords); cnt++)
        {
        if(
strfind(textInvalidWords[cnt], true) != -1)
            {
                      
Kick(playerid);
                }
        }
        return 
1;

I do not want to kick players out of the server. I just want to reformat the forbidden word into ****.
example:
fuck to ****
ass to ***
pussy to *****

and the length of the * sign corresponds to the forbidden character.

Example:
- I can fuck you
To: I can **** you


Re: How to format OnPlayerText - Dutheil - 27.04.2018

PHP код:
public OnPlayerText(playeridtext[]) {    
    new
        
name[MAX_PLAYER_NAME],
        
str[145];
    
GetPlayerName(playeridnameMAX_PLAYER_NAME);
    
format(strsizeof(str), "%s : %s"nametext);
    if(
strfind(str"fuck"true) != -1) {
        
strreplace(str"fuck""****"true);
    }
    
SendClientMessageToAll(-1str);
    return 
0;




Re: How to format OnPlayerText - RichKiez - 27.04.2018

Quote:
Originally Posted by Dutheil
Посмотреть сообщение
PHP код:
public OnPlayerText(playeridtext[]) {    
    new
        
name[MAX_PLAYER_NAME],
        
str[145];
    
GetPlayerName(playeridnameMAX_PLAYER_NAME);
    
format(strsizeof(str), "%s : %s"nametext);
    if(
strfind(str"fuck"true) != -1) {
        
strreplace(str"fuck""****"true);
    }
    
SendClientMessageToAll(-1str);
    return 
0;

Error: error 017: undefined symbol "strreplace"


Re: How to format OnPlayerText - std - 27.04.2018

Quote:
Originally Posted by RichKiez
Посмотреть сообщение
I do not want to kick players out of the server. I just want to reformat the forbidden word into ****.
example:
fuck to ****
ass to ***
pussy to *****

and the length of the * sign corresponds to the forbidden character.

Example:
- I can fuck you
To: I can **** you
that's because he just found a snippet from the forums and posted it here.