OnPlayerText usage?
#1

Well, I want to know more about OnPlayerText
Would someone tell me about it?

How can I get player's text.. like amm
Example :

Код:
	new insult[MAX_PLAYERS];
		GetPlayerText(playerid, insult, sizeof(insult));
Something like that?
Please, I would like to know about it, and how can I get player's text.
Reply
#2

What do you mean by 'get their text'?

It's not currently possible to get the text that the player is typing in chat.

OnPlayerText is called when a player enters text without a /. You can find more information about OnPlayerText on the wiki. It has documentation for every function and callback and can be very useful for beginners.
Reply
#3

Well, I just wonder how can I make '****' for example, when player sends "fuck" for example.
Reply
#4

You will need to put the code in OnPlayerText. There are already scripts out to do what you want to do, but if you want to know how to do it you need to use strfind, and use the value it returns to determine the position of the word, and use strdel to remove the word, and then use strins to enter the stars.

If you need any further help let me know, i'll explain more and maybe give you an example code. However, I recommend you take a look at the scripts that already exist. I believe Sandra made one.
Reply
#5

Quote:
Originally Posted by Ben7544
Посмотреть сообщение
Well, I just wonder how can I make '****' for example, when player sends "fuck" for example.
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128], Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    if(strcmp(text, "fuck", true) == 0) { format(string, sizeof(string), "%s(%d): ****", Name, playerid); SendClientMessageToAll(color, string); }
    return 1;
}
Reply
#6

Skylar, if someone says 'fuck you' it's not going to censor it - is it?
Reply
#7

Quote:
Originally Posted by MP2
Посмотреть сообщение
Skylar, if someone says 'fuck you' it's not going to censor it - is it?
Not at all, nope. You'd have to use your method of strfind; This is just a very crude, and simple example.

Quote:

This forum requires that you wait 120 seconds between posts. Please try again in 32 seconds.

FFFFFUUUU- it's back.

EDIT:

pawn Код:
if(strfind(text, "fuck")) { strins(text, "****", 0, 128); }
Something like this, perhaps? Never have used strins, and I just checked the wiki - Perhaps this would work, probably not, but thought i'd put in my two cents.
Reply
#8

Well, I haven't noticed what you've done, but I done this :


Код:
new fuck[1][] =
{
	"fuck"
			};
Код:
for(new f; f < sizeof(fuck); f++){
	new string[256];
		if(strfind(text, fuck[f], true) != -1)
		{
		    new name[MAX_PLAYER_NAME]; new string[128];
			GetPlayerName(playerid, name, sizeof(name));
			format(string,sizeof(string), "%s: I'm gay", name);
			SendClientMessageToAll(GetPlayerColor(playerid), string);
			}
		}
And I got those three errors :

PHP код:
C:\Documents and Settings\gidon\щемзп дтбегд\ъйчйд згщд\pawno\new.pwn(97) : warning 217loose indentation
C
:\Documents and Settings\gidon\щемзп дтбегд\ъйчйд згщд\pawno\new.pwn(99) : warning 219local variable "string" shadows a variable at a preceding level
C
:\Documents and Settings\gidon\щемзп дтбегд\ъйчйд згщд\pawno\new.pwn(96) : warning 204symbol is assigned a value that is never used"string" 
Reply
#9

You got two 'new string;' 's
Reply
#10

Quote:
Originally Posted by Ben7544
Посмотреть сообщение
Well, I haven't noticed what you've done, but I done this :


Код:
new fuck[1][] =
{
	"fuck"
			};
Код:
for(new f; f < sizeof(fuck); f++){
	new string[256];
		if(strfind(text, fuck[f], true) != -1)
		{
		    new name[MAX_PLAYER_NAME]; new string[128];
			GetPlayerName(playerid, name, sizeof(name));
			format(string,sizeof(string), "%s: I'm gay", name);
			SendClientMessageToAll(GetPlayerColor(playerid), string);
			}
		}
And I got those three errors :

PHP код:
C:\Documents and Settings\gidon\щемзп дтбегд\ъйчйд згщд\pawno\new.pwn(97) : warning 217loose indentation
C
:\Documents and Settings\gidon\щемзп дтбегд\ъйчйд згщд\pawno\new.pwn(99) : warning 219local variable "string" shadows a variable at a preceding level
C
:\Documents and Settings\gidon\щемзп дтбегд\ъйчйд згщд\pawno\new.pwn(96) : warning 204symbol is assigned a value that is never used"string" 
Those errors roughly translate to: Stop being homophobic.

He wants it so when someone says 'fuck you' it'll turn into '**** you' - not remove the whole message.

strfind returns the position of the first character in the string that is found, it's basically the number of letters before the word you're searching for. So you can strfind 'fuck' then strdel the characters strfind to strfind+4 - that'll remove fuck. Then strins at the strfind position four *'s. Simples.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)