How to have IDs in chat? -
fiki574 - 17.05.2011
Hello! So, I want to know how can I have IDs of players when they type the message?
For example:
fiki574_CRO(0): Hi all!
Player1(1): hey
Player5(3): supp
Can someone pls help me?
Any help would be appriciated! Tnx!
P.S. This (0), (1) and (3) are IDs!
Re: How to have IDs in chat? -
robintjeh - 17.05.2011
Use playerid in format.. shortest answer ever
Re: How to have IDs in chat? -
fiki574 - 17.05.2011
I wanted an example with code not "shortest answer ever"! Pls someone else help me!
Re: How to have IDs in chat? -
fiki574 - 17.05.2011
Anyone help me pls
Re: How to have IDs in chat? -
PrawkC - 17.05.2011
public OnPlayerText(playerid, text[])
{
new out[124];
format(out, sizeof(out), "%s (%d) says: %s", getName(playerid), playerid , text);
SendClientMessage(i, COLOR_WHITE, out);
return 0;
}
Re: How to have IDs in chat? -
DeadAhead - 17.05.2011
Why are Responders sometimes surprisingly stupid. How the hell do you know this guy has getName defined...god...remember to add this on the end of your script.
pawn Код:
stock getName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
return name;
}
Re: How to have IDs in chat? -
grand.Theft.Otto - 17.05.2011
Quote:
Originally Posted by PrawkC
public OnPlayerText(playerid, text[])
{
new out[124];
format(out, sizeof(out), "%s (%d) says: %s", getName(playerid), playerid , text);
SendClientMessage(i, COLOR_WHITE, out);
return 0;
}
|
I doubt that code is going to work and looks wrong.
Use this:
pawn Код:
new PlayerName[MAX_PLAYER_NAME]; // new variable to store the players name
GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); // gets the name of PlayerName (the var we created)
format(text, 1024, "%s (%d): {FFFFFF}%s", PlayerName, playerid, text); // formats the output of the message
SendClientMessageToAll(GetPlayerColor(playerid), text); // sends the message to the whole server
Re: How to have IDs in chat? -
PrawkC - 17.05.2011
Quote:
Originally Posted by grand.Theft.Otto
I doubt that code is going to work and looks wrong.
Use this:
pawn Код:
new PlayerName[MAX_PLAYER_NAME]; // new variable to store the players name GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); // gets the name of PlayerName (the var we created) format(text, 1024, "%s (%d): {FFFFFF}%s", PlayerName, playerid, text); // formats the output of the message SendClientMessageToAll(GetPlayerColor(playerid), text); // sends the message to the whole server
|
You're right mine wouldn't work, I'll remember not to post as soon as I get up. (copied out of my default RP chat)
Re: How to have IDs in chat? -
fiki574 - 17.05.2011
Quote:
Originally Posted by grand.Theft.Otto
I doubt that code is going to work and looks wrong.
Use this:
pawn Код:
new PlayerName[MAX_PLAYER_NAME]; // new variable to store the players name GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); // gets the name of PlayerName (the var we created) format(text, 1024, "%s (%d): {FFFFFF}%s", PlayerName, playerid, text); // formats the output of the message SendClientMessageToAll(GetPlayerColor(playerid), text); // sends the message to the whole server
|
Dont works!
When i type message this show up:
fiki574_CRO(0): Hi! ----------> black color
fiki574_CRO: fi ----------> fi? wtf i type hi! and it is in normal random color!
Re: How to have IDs in chat? -
grand.Theft.Otto - 17.05.2011
Quote:
Originally Posted by fiki574_CRO
Dont works!
When i type message this show up:
fiki574_CRO(0): Hi! ----------> black color
fiki574_CRO: fi ----------> fi? wtf i type hi! and it is in normal random color!
|
Hmm, works fine for my server. Not really sure what the problem is, but you might already have a function similar to mine in your gamemode, that could be why it is sending it twice.
EDIT
YES, like randomkid said, add return 0; under it, this will solve it for sure because I have return 0; under mine but I didn't add it to this code. It should work after.
pawn Код:
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(text, 1024, "%s (%d): {FFFFFF}%s", PlayerName, playerid, text);
SendClientMessageToAll(GetPlayerColor(playerid), text);
return 0;
Should be like this.