Playerid -
Blackazur - 04.12.2012
How to make that when a People type what and he send it in the chat, that the ID is too screened? Like "Blackazur (0): test".
Re: Playerid -
Elysian` - 04.12.2012
pawn Код:
public OnPlayerText(playerid, text[])
{
new string[128];
format(string, sizeof(string), "%s(%d): %s" GetName(playerid), playerid, text);
SendClientMessageToAll(-1, string);
return 0;
}
Add this stock anywhere in your script.
Код:
stock GetName(playerid)
{
new
name[24];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
AW: Playerid -
Blackazur - 04.12.2012
error 001: expected token: "-string end-", but found "-identifier-"
warning 215: expression has no effect
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
On this line:
Quote:
format(string, sizeof(string), "%s(%d): %s" GetName(playerid), playerid, text);
|
Re: Playerid -
Bakr - 04.12.2012
You are missing a comma after the format of the string.
AW: Playerid -
Blackazur - 04.12.2012
Worked, thx. But all Names are now in White, how can i change that to my Colors on my Script?
Re: Playerid -
[Ro]DuReX - 04.12.2012
Remove the "stock GetName(playerid)" and "public OnPlayerText(playerid,text[])" and put this callback:
pawn Код:
public OnPlayerText(playerid,text[])
{
new string[256];
format(string, sizeof(string), "{FFFF00}(%i):{FFFFFF} %s",playerid, text);
SendPlayerMessageToAll(playerid,string);
return 0;
}
Re: Playerid -
Bakr - 04.12.2012
You forgot to include the name in the format string and to pass it.
Re: Playerid -
Sting. - 04.12.2012
DuRex code work fine. What do you mean Bakr? I tried it and my name was like:
RTR: (0): I love SA-MP!
What's the problem with the code?
Re: Playerid -
[Ro]DuReX - 04.12.2012
Quote:
Originally Posted by Bakr
You forgot to include the name in the format string and to pass it.
|
SendPlayerMessageToAll is different. You don't need to put the name in the string.
More informations here:
https://sampwiki.blast.hk/wiki/SendPlayerMessageToAll
Quote:
Originally Posted by RTR12
DuRex code work fine. What do you mean Bakr? I tried it and my name was like: RTR: (0): I love SA-MP!
What's the problem with the code?
|
Remove the points in the string. It should show like this
RTR: (0) I love SA-MP!
Re: Playerid -
RajatPawar - 06.12.2012
Quote:
Originally Posted by Windows32
pawn Код:
public OnPlayerText(playerid, text[]) { new string[128]; format(string, sizeof(string), "%s(%d): %s" GetName(playerid), playerid, text); SendClientMessageToAll(-1, string); return 0; }
Add this stock anywhere in your script.
Код:
stock GetName(playerid)
{
new
name[24];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
|
Why are you unnecessarily creating a stock? Just GetPlayerName with a pname var of MAX_PLAYER_NAME size is enough..