Player Message Color[+REP] -
Hemeei - 16.08.2015
Hello guys
How i can make like this ?
Hemeei :
Hello
James :
Hi
Not This (Default)
Hemeei : Hello
James : Hi
Re: Player Message Color -
Hemeei - 16.08.2015
bump
Re: Player Message Color -
Evocator - 16.08.2015
Name{FFFFFF}: nice cod rww screenshot
Re: Player Message Color -
SpikY_ - 16.08.2015
Give more details, what is your problem?
Re: Player Message Color -
Roberto80 - 16.08.2015
Under OnPlayerText
Add this
Код:
mew str[100],name[24];
GetPlayerName(playerid,name,24);
format(str,100,"%s(%i):{D5D5D5}%s",name,playerid,text)(
SendClientMessageToAll(color here,str);
Enjoy
And learn about hex colors
Re: Player Message Color[+REP] -
LetsOWN[PL] - 16.08.2015
Quote:
Originally Posted by Hemeei
Hello guys
How i can make like this ?
Hemeei : Hello
James : Hi
Not This (Default)
Hemeei : Hello
James : Hi
|
Do something like this:
pawn Код:
#define Max_Client_Message_Len 128
public OnPlayerText(playerid, text[])
{
new String [ Max_Client_Message_Len + MAX_PLAYER_NAME + 16];
if( strlen(text) > Max_Client_Message_Len )
return 0;
new PlayerName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, PlayerName, MAX_PLAYER_NAME );
format( String, sizeof( String ), "{RRGGBB}%s (%d): {RRGGBB}%s", PlayerName, playerid, text );
for( new i = 0; i < MAX_PLAYERS; i++ )
SendClientMessage( i, 0x0, String );
return false;
}
Greetings.
Re: Player Message Color[+REP] -
Hemeei - 16.08.2015
Quote:
Originally Posted by LetsOWN[PL]
Do something like this:
pawn Код:
#define Max_Client_Message_Len 128 public OnPlayerText(playerid, text[]) { new String [ Max_Client_Message_Len + MAX_PLAYER_NAME + 16]; if( strlen(text) > Max_Client_Message_Len ) return 0; new PlayerName[ MAX_PLAYER_NAME ]; GetPlayerName( playerid, PlayerName, MAX_PLAYER_NAME ); format( String, sizeof( String ), "{RRGGBB}%s (%d): {RRGGBB}%s", PlayerName, playerid, text ); for( new i = 0; i < MAX_PLAYERS; i++ ) SendClientMessage( playerid, 0x0, String ); return false; }
Greetings.
|
the problem is its spamming (gonna change color later)
PHP код:
//==============================================================================
#define Max_Client_Message_Len 128
public OnPlayerText(playerid, text[])
{
new String [ Max_Client_Message_Len + MAX_PLAYER_NAME + 16];
if( strlen(text) > Max_Client_Message_Len )
return 0;
new PlayerName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, PlayerName, MAX_PLAYER_NAME );
format( String, sizeof( String ), "{RRGGBB}%s (%d): {RRGGBB}%s", PlayerName, playerid, text );
for( new i = 0; i < MAX_PLAYERS; i++ )
SendClientMessage( playerid, 0x0, String );
if(text[0] == '.' && PlayerInfo[playerid][Level] >= 1) {
new string[128]; GetPlayerName(playerid,string,sizeof(string));
format(string,sizeof(string),"A.Chat: %s: %s",string,text[1]);
MessageToAdmins(0xFD01FDAA,string);
return 0;
}
return 1;
}
if i put return false; in
PHP код:
for( new i = 0; i < MAX_PLAYERS; i++ )
SendClientMessage( playerid, 0x0, String );
return false;
there's an error
Quote:
warning 225: unreachable code
|
Re: Player Message Color -
Hemeei - 16.08.2015
bump
Re: Player Message Color[+REP] -
LetsOWN[PL] - 16.08.2015
Quote:
Originally Posted by Hemeei
the problem is its spamming (gonna change color later)
PHP код:
//==============================================================================
#define Max_Client_Message_Len 128
public OnPlayerText(playerid, text[])
{
new String [ Max_Client_Message_Len + MAX_PLAYER_NAME + 16];
if( strlen(text) > Max_Client_Message_Len )
return 0;
new PlayerName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, PlayerName, MAX_PLAYER_NAME );
format( String, sizeof( String ), "{RRGGBB}%s (%d): {RRGGBB}%s", PlayerName, playerid, text );
for( new i = 0; i < MAX_PLAYERS; i++ )
SendClientMessage( i, 0x0, String );
if(text[0] == '.' && PlayerInfo[playerid][Level] >= 1) {
new string[128]; GetPlayerName(playerid,string,sizeof(string));
format(string,sizeof(string),"A.Chat: %s: %s",string,text[1]);
MessageToAdmins(0xFD01FDAA,string);
return 0;
}
return 1;
}
if i put return false; in
PHP код:
for( new i = 0; i < MAX_PLAYERS; i++ )
SendClientMessage( playerid, 0x0, String );
return false;
there's an error
|
Firstly:
pawn Код:
format(string,sizeof(string),"A.Chat: %s: %s",string,text[1]);
MessageToAdmins(0xFD01FDAA,string);
return 0;
}
return 1; // <<<<<<<<<<<<<<<
It MUST be either return false; or return 0; (which is, obviously, the same), because You have to prevent the server to display sent message for players (because it has been already show for everyone with this one:
pawn Код:
for( new i = 0; i < MAX_PLAYERS; i++ )
SendClientMessage( i, 0x0, String );
By the way, You should be aware, that if You return 0; this entire callback, so it would look like:
pawn Код:
public OnPlayerText(playerid, text[])
{
return 0;
}
it will prevent sent message from displaying (helpful knowledge, if You want to mute someone, et cetera.
Quote:
if i put return false; in
PHP код:
for( new i = 0; i < MAX_PLAYERS; i++ )
SendClientMessage( i, 0x0, String );
return false;
there's an error
|
Yes, because You have some code already below return false; statement, and compiler knows, that it will never be executed, if it is put that way. That's where the warning comes from.
To fix this, You should always handle exceptions first, because admin chat (or something like this) is exception, whereas
pawn Код:
for( new i = 0; i < MAX_PLAYERS; i++ )
SendClientMessage( playerid, 0x0, String );
is a reqular case.
So, to make things working, Your code should look like this:
pawn Код:
//==============================================================================
#define Max_Client_Message_Len 128
public OnPlayerText(playerid, text[])
{
new String [ Max_Client_Message_Len + MAX_PLAYER_NAME + 16];
if( strlen(text) > Max_Client_Message_Len ) // Check for valid length
return 0;
new PlayerName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, PlayerName, MAX_PLAYER_NAME );
if(text[0] == '.' && PlayerInfo[playerid][Level] >= 1) { // Is first character '.' and the second part of the statement is true
// if yes, then:
new string[128]; GetPlayerName(playerid,string,sizeof(string));
format(string,sizeof(string),"A.Chat: %s: %s",string,text[1]);
MessageToAdmins(0xFD01FDAA,string);
return 0; // Don't go any further
}
format( String, sizeof( String ), "{RRGGBB}%s (%d): {RRGGBB}%s", PlayerName, playerid, text );
for( new i = 0; i < MAX_PLAYERS; i++ )
SendClientMessage( i, 0x0, String );
return 0; // prevent double messages
}
Sorry about my English.. Kinda overdosed with "golden drink"
Greetings
@ Edit
Quote:
Originally Posted by Ralfie
Код:
for( new i = 0; i < MAX_PLAYERS; i++ )
SendClientMessage( playerid, 0x0, String );
lol...
Код:
SendClientMessageToAll(-1, String);
|
Mr. Einstein, it's the same ._.
Re: Player Message Color[+REP] -
Evocator - 16.08.2015
Quote:
Originally Posted by LetsOWN[PL]
Mr. Einstein, it's the same ._.
|
How is looping through all the players and sending the same message to the same player the same as sending a message to everyone?
But still thanks for calling me Einstein, Century Gothic "hore".