SA-MP Forums Archive
Text before the player name - 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: Text before the player name (/showthread.php?tid=444618)



Text before the player name - Lucky™ - 17.06.2013

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.


Re: Text before the player name - SilverKiller - 17.06.2013

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.


Re: Text before the player name - Lucky™ - 17.06.2013

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


Re: Text before the player name - ReVo_ - 17.06.2013

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;



Re: Text before the player name - Dragonsaurus - 17.06.2013

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.


Re: Text before the player name - JJB562 - 17.06.2013

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;
}



Re: Text before the player name - Lucky™ - 17.06.2013

Thanks everyone, I will try these things

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