How to format OnPlayerText
#1

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.
Reply
#2

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
Reply
#3

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
Reply
#4

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

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
Reply
#6

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;

Reply
#7

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
Reply
#8

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;

Reply
#9

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"
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)