How to have IDs in chat?
#1

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!
Reply
#2

Use playerid in format.. shortest answer ever
Reply
#3

I wanted an example with code not "shortest answer ever"! Pls someone else help me!
Reply
#4

Anyone help me pls
Reply
#5

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;
}
Reply
#6

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

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
Reply
#8

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)
Reply
#9

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!
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)