SA-MP Forums Archive
[HELP] show id in chat - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] show id in chat (/showthread.php?tid=261525)



[HELP] show id in chat - [ITS]StatickShock - 13.06.2011

Hi all you tell me how do you put the id in chat




Re: [HELP] show id in chat - ColdIce - 13.06.2011

It's no doubt that I will be corrected. But what the heck

pawn Код:
for(new i = 1; i < MAX_CHAT_LINES-1; i++)
    Chat[i] = Chat[i+1];
    new ChatSTR[128];
    GetPlayerName(playerid,ChatSTR,sizeof(ChatSTR));
    format(ChatSTR,128,"[CHAT]%s: %s",ChatSTR, text[0]);
    Chat[MAX_CHAT_LINES-1] = ChatSTR;
    return 1;
}



Re: [HELP] show id in chat - PrawkC - 13.06.2011

Quote:
Originally Posted by ColdIce
Посмотреть сообщение
It's no doubt that I will be corrected. But what the heck

pawn Код:
for(new i = 1; i < MAX_CHAT_LINES-1; i++)
    Chat[i] = Chat[i+1];
    new ChatSTR[128];
    GetPlayerName(playerid,ChatSTR,sizeof(ChatSTR));
    format(ChatSTR,128,"[CHAT]%s: %s",ChatSTR, text[0]);
    Chat[MAX_CHAT_LINES-1] = ChatSTR;
    return 1;
}
What is this? i dont even...

pawn Код:
public OnPlayerText(playerid, text[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new string[128];
            new temp[48];
            GetPlayerName(playerid, temp, sizeof(temp));
            format(string, sizeof(string), "%s (%i) says:{FFFFFF} %s", temp, playerid, text);
            SendClientMessage(i, 0xFFFF00AA, string);
        }
    }
    return 0;
}



Re: [HELP] show id in chat - ColdIce - 13.06.2011

pawn Код:
public OnPlayerText(playerid,text[])
{

    new textstring[128];
    format(textstring, sizeof(textstring), "[%i] %s", playerid, text);
    SendPlayerMessageToAll(playerid, textstring);
    return 0;
}
Or this


Re: [HELP] show id in chat - Laronic - 13.06.2011

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128], name[24];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s: {FFFFFF}(%d) %s", name, playerid, text);
    SendClientMessageToAll(GetPlayerColor(playerid), string);
    return 0;
}



Re: [HELP] show id in chat - randomkid88 - 14.06.2011

Quote:
Originally Posted by PrawkC
Посмотреть сообщение
What is this? i dont even...

pawn Код:
public OnPlayerText(playerid, text[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new string[128];
            new temp[48];
            GetPlayerName(playerid, temp, sizeof(temp));
            format(string, sizeof(string), "%s (%i) says:{FFFFFF} %s", temp, playerid, text);
            SendClientMessage(i, 0xFFFF00AA, string);
        }
    }
    return 0;
}
A shorter and more efficient version would be CyberGhost's.
There is no need to:
a) declare 2 strings and format them for once for every connected player.
b) Use a loop for a function that has an alternative for All Players (SendClientMessageToAll)
c) Use IsPlayerConnected. You can assume that they have to be connected to text, and SendClientMessageToAll already includes this in its internal workings.

Just some tips.


Re: [HELP] show id in chat - Tee - 14.06.2011

If I may add to that, using ColdIce's last post would send the message in the color of the player.

Example:

1 ColdIce.

Tee: Hello, how are you?

2. CyberGhosts

Tee: Hello, how are you?

Look good it's there ^


Re: [HELP] show id in chat - [ITS]StatickShock - 14.06.2011

thanks all


Re: [HELP] show id in chat - [ITS]StatickShock - 14.06.2011

solved