Playerid in a chatbox?
#1

How do I make playerid show when player sends a message?
I was trying to make it like this:

pawn Код:
public OnPlayerText(playerid, text[])
{
    new output[256];
    format(output, sizeof(output), "[%d] %s", playerid, text);
    SendClientMessageToAll(COLOR_WHITE, output);
    return 0;
}
It only shows playerid and a message. But it has to be: Player name [player id] message
Like: AivaMan [0]: hello world.
Any other ideas?
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[])
{
  new string[128];
  GetPlayerName(playerid, string, sizeof string);
  format(string, sizeof string, "%s [%d]: %s", string, playerid, text);
  SendClientMessageToAll(COLOR_WHITE, string);
  return 0;
}
Reply
#3

pawn Код:
public OnPlayerText(playerid, text[])
{
    new output[256];
    format(output, sizeof(output), "[%d] %s", playerid, text);
    SendPlayerMessageToAll(playerid,output);
    return 0;
}
Reply
#4

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
pawn Код:
public OnPlayerText(playerid, text[])
{
  new string[128];
  GetPlayerName(playerid, string, sizeof string);
  format(string, sizeof string, "%s [%d]: %s", string, playerid, text);
  SendClientMessageToAll(COLOR_WHITE, string);
  return 0;
}
Damn it, forgot the player name.
Reply
#5

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
pawn Код:
new output[256];
After reading ******'s "Never use 256 Arrays" I learnt that the player can only type 128 as max.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)