Text before the player name
#1

Hello, is there any way to add some text before the player name in main chat? I mean

[textgoeshere] Playername (playerid): player message

I tried to some ways, Not working tho.
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[])
{
    new textv2[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(textv2, sizeof (textv2), "%s (%s) (%d)", text, name, playerid);
    SendPlayerMessageToAll(playerid, textv2);
    return 0;
}
EDIT: Oops, that won't really work.... I'm not sure if it is possible to add text before playername...

EDIT 2: ReVo_ is right, try what he said.
Reply
#3

Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
pawn Код:
public OnPlayerText(playerid, text[])
{
    new textv2[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(textv2, sizeof (textv2), "%s (%s) (%d)", text, name, playerid);
    SendPlayerMessageToAll(playerid, textv2);
    return 0;
}
Great, I will check it.

Edit: Oh
Reply
#4

Yes, in 2 ways:

Set player name
or
Use SendclientMessage

Ok
(SetPlayername)
Код:
new old_name [24], new_txt [128];
GetPlayerName (playerid, old_name, 24);
format (new_txt, 128, "[TEXT]_%s", old_name);
SetPlayerName (playerid, new_txt);
format (new_txt, 128, "(%d) %s", playerid, text);
SendPlayerMessageToAll (playerid, new_txt);
SetPlayerName (playerid, old_name);
return 0;
Or

Код:
new name [24], txt [128];
format (txt, 128, "[TEXT] { USE EMBED COLORS TO SET PLAYER COLOR }%s{FFFFFF} (%d): %s", name, playerid, text);
SendClientMessageToAll(-1, txt);
return 0;
Reply
#5

pawn Код:
public OnPlayerText(playerid, text[])
{
    new message[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(message, sizeof (message), "[Text here] %s (%d):{FFFFFF} %s",name, playerid, text);
    SendClientMessageToAll([Color here], message);
    return 0;
}
Works only if you want to add a static text.
Reply
#6

You can do something like this:

pawn Код:
// On top of your script
new PlayerTag[MAX_PLAYERS][24];

// Player uses this command to set his tag.
CMD:settag(playerid, params[])
{
    new string[64], tag[24];
    if(sscanf(params, "s[24]", tag)) return SendClientMessage(playerid, -1, "Usage: /settag [text]");
    format(PlayerTag[playerid], 24, tag);
    format(string, sizeof(string), "You have changed your tag to %s.", tag);
    SendClientMessage(playerid, -1, string);
    return 1;
}

public OnPlayerText(playerid, text[])
{
    new playername[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, playername, sizeof(playername));
    format(string, sizeof(string), "[%s] %s: %s", PlayerTag[playerid], playername, text);
    SendClientMessageToAll(-1, string);
    return 0;
}
Reply
#7

Thanks everyone, I will try these things

Edit: Thank you Revo, It's working (Y)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)