SA-MP Forums Archive
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=508861)



OnplayerText.. - Snoopythekill - 24.04.2014

How can I achieve this format in the chat ?.
pawn Код:
0 SnoopyTheKill: Hello Forum Samp!.   //[ID] [Name] [Text]
I tried as well but does not come out as i want, what someone can help me ?
pawn Код:
public OnPlayerText(playerid, text[])
{
if(IsPlayerConnected(playerid))
{
new chat[ 128 ], Nombre[ 24 ];
GetPlayerName(playerid, Nombre, sizeof(Nombre));

format(chat, sizeof(chat), "{FFFFFF}%d %s: {FFFFFF}%s",playerid,Nombre,text);
SendClientMessageToAll(GetPlayerColor(playerid), chat);
SetPlayerChatBubble(playerid, text, GetPlayerColor(playerid), 30.0, 50000);
return 0;
}
return 1;
}
Someone help me ? Thanks


Re: OnplayerText.. - RajatPawar - 24.04.2014

EDIT: Invalid


Respuesta: Re: OnplayerText.. - Snoopythekill - 24.04.2014

Quote:
Originally Posted by RajatPawar
Посмотреть сообщение
pawn Код:
public OnPlayerText(playerid, text[])
{
    new fText[144],  // Not static!
          fName[MAX_PLAYER_NAME];

    GetPlayerName(playerid, fName, MAX_PLAYER_NAME);
    format(fText, sizeof (fText), "%d %s: %s", playerid, fName, text);
   
    SendClientMessageToAll(-1, fText);
    return 0;
}
There's no point using IPC because a disconnected player can't call that callback.. AFAIK.
That leaves me the entire text of the color that you select the player, i want the player to be their color and the text and the id are white.

It would have to be something like this, only that is the color of the name by the code hmtl
pawn Код:
if(IsPlayerConnected(playerid))
{
new fText[144],fName[MAX_PLAYER_NAME];
GetPlayerName(playerid, fName, MAX_PLAYER_NAME);
format(fText, sizeof (fText), "{FFFFFF}%d %s: {FFFFFF}%s", playerid, fName, text);
SendClientMessageToAll(GetPlayerColor(playerid), fText);
return 0;
}



Re: Respuesta: Re: OnplayerText.. - RajatPawar - 24.04.2014

editing


Respuesta: Re: Respuesta: Re: OnplayerText.. - Snoopythekill - 24.04.2014

Quote:
Originally Posted by RajatPawar
Посмотреть сообщение
Oh, I did not know that!

change the format line to -

pawn Код:
format(fText, sizeof (fText), "{FFFFFF}%d {%x}%s: {FFFFFF}%s", playerid, GetPlayerColor(playerid), fName, text);
The format gives it to me as well:

pawn Код:
0 {FFFFFFFF} snoopythekill: hello forum samp!.
Save Hexadecimal number no codigo html

pawn Код:
{%x} o %x
Leave the keys "{}".

pawn Код:
if(IsPlayerConnected(playerid))
{
new chat[ 128 ], nombre[MAX_PLAYER_NAME];
GetPlayerName(playerid, nombre,sizeof(nombre));
format(chat, sizeof (chat), "%d {%x}%s: %s", playerid, GetPlayerColor(playerid), nombre, text);
SendClientMessageToAll(-1, chat);
return 0;
}



Re: OnplayerText.. - Konstantinos - 24.04.2014

pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        chat[144],
        pname[21];
   
    GetPlayerName(playerid, pname, sizeof (pname));
    format(chat, sizeof (chat), "%d {%06x}%s{FFFFFF}: %s", playerid, GetPlayerColor(playerid) >>> 8, pname, text);
    SendClientMessageToAll(-1, chat);
    return 0;
}
A note: GetPlayerColor will return nothing unless SetPlayerColor has been used!


Respuesta: Re: OnplayerText.. - Snoopythekill - 24.04.2014

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        chat[144],
        pname[21];
   
    GetPlayerName(playerid, pname, sizeof (pname));
    format(chat, sizeof (chat), "%d {%06x}%s{FFFFFF}: %s", playerid, GetPlayerColor(playerid) >>> 8, pname, text);
    SendClientMessageToAll(-1, chat);
    return 0;
}
A note: GetPlayerColor will return nothing unless SetPlayerColor has been used!
Thanks friend, it works! ++;