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: OnPlayerText (
/showthread.php?tid=522125)
OnPlayerText -
Ts3 - 26.06.2014
Hello, I wonder how to put so kind when talking in chat:
• [ID] Nick text
until now I could not always .. when I put looks like this:
Nick: [ID] Nick: text
That is wrong, does anyone know by the way I asked first?
Re: OnPlayerText -
Rittik - 26.06.2014
pawn Код:
public OnPlayerText(playerid, text[])
{
new Text[144],name[64];
GetPlayerName(playerid,name,sizeof(name));
format(Text, sizeof (Text), "[%d] %s: %s", playerid,name, text);
SendClientMessageToAll(-1, Text);
return 0; // this should be return 0;
}
Respuesta: OnPlayerText -
SickAttack - 26.06.2014
Quote:
Originally Posted by Rittik
pawn Код:
public OnPlayerText(playerid, text[]) { new Text[144],name[64]; format(Text, sizeof (Text), "[%d] %s: %s", playerid,name, text); SendPlayerMessageToAll(playerid, Text); return 0; // this should be return 0; }
|
^ You forgot to get the name of the player.
pawn Код:
GetPlayerName(playerid, name, sizeof(name));
And why are you using 64 cells for the name? "name[64];"
pawn Код:
public OnPlayerText(playerid, text[])
{
new string[144], name[MAX_PLAYER_NAME + 1], playercolor = GetPlayerColor(playerid);
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "[%d] %s: %s", playerid, name, text);
SendClientMessageToAll(playercolor, string);
return 0;
}
Re: OnPlayerText -
Rittik - 26.06.2014
@Sick: I was editing at the moment for GetPlayerName.
Re: OnPlayerText -
AdHaM612 - 26.06.2014
Your problem is "return 1;"
It must be "return 0;" so the original text won't be shown
Re: OnPlayerText -
Ts3 - 26.06.2014
Sick Attack works but all the text was black, everything was black on the line .. D:
Re: OnPlayerText -
Konstantinos - 26.06.2014
Quote:
Originally Posted by Ts3
Sick Attack works but all the text was black, everything was black on the line .. D:
|
GetPlayerColor returns 0 (which is colour black) if it hasn't set the player's colour before.
@SickAttack: He had used SendPlayerMessageToAll which sends the name with the player's colour itself.
Re: OnPlayerText -
Ts3 - 26.06.2014
But not only the color and the text of the player is also getting black .. would like to stay just the id and nick black white text, and after that would see how to set the color of the player .. If I'm wrong ententend, sorry I'm new at this .. '-'