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
|
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(playerid, text[])
{
new string[128];
for(new cnt = 0; cnt < sizeof(InvalidWords); cnt++)
{
if(strfind(text, InvalidWords[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(playerid, text[])
{
new string[128];
for(new cnt = 0; cnt < sizeof(InvalidWords); cnt++)
{
if(strfind(text, InvalidWords[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(playerid, text[]) {
new
name[MAX_PLAYER_NAME],
str[145];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(str, sizeof(str), "%s : %s", name, text);
if(strfind(str, "fuck", true) != -1) {
strreplace(str, "fuck", "****", true);
}
SendClientMessageToAll(-1, str);
return 0;
}
Re: How to format OnPlayerText -
RichKiez - 27.04.2018
Quote:
Originally Posted by Dutheil
PHP код:
public OnPlayerText(playerid, text[]) {
new
name[MAX_PLAYER_NAME],
str[145];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(str, sizeof(str), "%s : %s", name, text);
if(strfind(str, "fuck", true) != -1) {
strreplace(str, "fuck", "****", true);
}
SendClientMessageToAll(-1, str);
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.