SendClientMessage

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 20:38, 8 January 2020
Malandrin (Talk | contribs)

← Previous diff
Current revision
Malandrin (Talk | contribs)

Line 1: Line 1:
{{Scripting}} {{Scripting}}
-{{Description| Esta função envia uma mensagem para um jogador específico com a cor escolhida no chat. A linha inteira na caixa de bate-papo terá a cor definida, a menos que a [[Colors_List#Color_embedding|color embedding]] seja usada(0.3c ou superior).}}+{{Description|This function sends a message to a specific player with a chosen color in the chat. The whole line in the chatbox will be in the set color unless [[Colors_List#Color_embedding|color embedding]] is used (0.3c or later).}}
-{{Parameters| playerid, color, const message[]}}+{{Parameters|playerid, color, const message[]}}
-{{Param|playerid|O ID do jogador que receberá a mensagem.}}+{{Param|playerid|The ID of the player to display the message to.}}
-{{Param|color|A cor da mensagem. (0xRRGGBBAA Hex format).}}+{{Param|color|The color of the message (0xRRGGBBAA Hex format).}}
-{{Param|const message[]|A mensagem que será enviada ao jogador. <b>(máximo 144 caracteres)</b>.}}+{{Param|const message[]|The text that will be displayed <b>(max 144 characters)</b>.}}
-{{ReturnsSuccess|O sucesso do envio será relatado quando a mensagem passar 144 caracteres mas a mensagem não será enviada.}}+{{ReturnsSuccess|Success is reported when the string is over 144 characters, but the message won't be sent.|The player is not connected.}}
{{notes2| {{notes2|
-* Se uma mensagem tiver mais de 144 caracteres, ela não será enviada. O truncamento pode ser usado para evitar isso. A exibição de uma mensagem em várias linhas também resolverá esse problema.+* If a message is longer than 144 characters, it will not be sent. Truncation can be used to prevent this. Displaying a message on multiple lines will also solve this issue.
-* Evite usar o sinal de porcentagem (ou especificadores de formato) no texto real da mensagem sem escapá-lo adequadamente (como %%). Caso contrário, resultará em falhas.+* Avoid using the percent sign (or format specifiers) in the actual message text without properly escaping it (like %%). It will result in crashes otherwise.
}} }}
Line 18: Line 18:
{{Example}} {{Example}}
<pawn> <pawn>
-#define COR_VERMELHO 0xFF0000FF+#define COLOR_RED 0xFF0000FF
public OnPlayerConnect(playerid) public OnPlayerConnect(playerid)
{ {
- SendClientMessage(playerid, COR_VERMELHO, "Esse texto tem a cor vermelha!");+ SendClientMessage(playerid, COLOR_RED, "This text is red");
- SendClientMessage(playerid, 0x00FF00FF, "Esse texto tem a cor verde!");+ SendClientMessage(playerid, 0x00FF00FF, "This text is green.");
- SendClientMessage(playerid, -1, "Esse texto tem a cor branca!");+ SendClientMessage(playerid, -1, "This text is white.");
return 1; return 1;
} }
Line 30: Line 30:
{{tips| {{tips|
-*Você pode usar [[Colors_List#Color_embedding|color embedding]] para múltiplas cores na mensagem.+*You can use [[Colors_List#Color_embedding|color embedding]] for multiple colors in the message.
-* Usando '-1' como cor, fará com que a mensagem saia na cor branca (Pelo simples motivo que '-1', quando representado em [[hex|hexadecimal notation]], is 0xFFFFFFFF).+* Using '-1' as the color will make the text white (for the simple reason that -1, when represented in [[hex|hexadecimal notation]], is 0xFFFFFFFF).
}} }}

Current revision



Description:

This function sends a message to a specific player with a chosen color in the chat. The whole line in the chatbox will be in the set color unless color embedding is used (0.3c or later).


Parameters:
(playerid, color, const message[])
playeridThe ID of the player to display the message to.
colorThe color of the message (0xRRGGBBAA Hex format).
const message[]The text that will be displayed (max 144 characters).


Return Values:

  • 1: The function was executed successfully. Success is reported when the string is over 144 characters, but the message won't be sent.
  • 0: The function failed to execute. The player is not connected.


Image:32px-Circle-style-warning.png

Important
Notes

  • If a message is longer than 144 characters, it will not be sent. Truncation can be used to prevent this. Displaying a message on multiple lines will also solve this issue.
  • Avoid using the percent sign (or format specifiers) in the actual message text without properly escaping it (like %%). It will result in crashes otherwise.


Example Usage:

#define COLOR_RED 0xFF0000FF
 
public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid, COLOR_RED, "This text is red");
    SendClientMessage(playerid, 0x00FF00FF, "This text is green.");
    SendClientMessage(playerid, -1, "This text is white.");
    return 1;
}
Tips

Image:Light_bulb_icon.png

  • You can use color embedding for multiple colors in the message.
  • Using '-1' as the color will make the text white (for the simple reason that -1, when represented in hexadecimal notation, is 0xFFFFFFFF).


Related Functions

The following functions may be helpful as they relate to this function in one way or another.

Personal tools
In other languages