how to make "playername (1):"
#1

hey,

i need help in my server,

when a player says a messege it comes up as "john: hello"

but i want to make it so it shows the player id aswell for example "john (1): hello"

any help?
Reply
#2

here

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

@ ^'s code

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[255];
    GetPlayerName(playerid,string,sizeof(string));
    format(string,sizeof(string),"%s (%d): %s",string,playerid,text[0]);
    SendClientMessageToAll(-1, string);
    return 0;
}
*fixed, it had an odd bracket.
Reply
#4

@ ^'s code

pawn Код:
public OnPlayerText( playerid, text[] )
{
    new string[ 128 ];
    format( string ,sizeof( string ),"%s ( %d ) : %s",GetPlayerNameEx( playerid ) ,playerid ,text );
    SendClientMessageToAll( -1 , string ); // GetPlayerColor ??
    return 0;
}

stock GetPlayerNameEx( playerid )
{
     new pName[ 25 ];
     GetPlayerName( playerid, pName, 25 );
     return pName;
}
*fixed, it had an odd string length.
Reply
#5

thanks it works :P
Reply
#6

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
@ ^'s code

pawn Код:
public OnPlayerText( playerid, text[] )
{
    new string[ 128 ];
    format( string ,sizeof( string ),"%s ( %d ) : %s",GetPlayerNameEx( playerid ) ,playerid ,text );
    SendClientMessageToAll( -1 , string ); // GetPlayerColor ??
    return 0;
}

stock GetPlayerNameEx( playerid )
{
     new pName[ 25 ];
     GetPlayerName( playerid, pName, 25 );
     return pName;
}
*fixed, it had an odd string length.
ahh I didn't even look at that, i just took out the bracket and the return 1 :P
Reply
#7

pawn Код:
stock ReturnPlayerName(playerid)
{
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    return pname;
}

public OnPlayerText(playerid, text[])
{
    new string[128];
    format(string, sizeof(string), "%s (%d): {FFFFFF}%s", ReturnPlayerName(playerid), playerid, text);
    SendClientMessageToAll(GetPlayerColor(playerid), string);
    return 0;
}
Reply
#8

You might want to use SendPlayerMessageToAll instead, so you do not have to fetch the name.
Reply
#9

theirs a porblem with :-

stock ReturnPlayerName(playerid)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
return pname;
}

public OnPlayerText(playerid, text[])
{
new string[128];
format(string, sizeof(string), "%s (%d): {FFFFFF}%s", ReturnPlayerName(playerid), playerid, text);
SendClientMessageToAll(GetPlayerColor(playerid), string);
return 0;
}


when you talk your text is black for all players, i want random colour
Reply
#10

Thats because of the "{FFFFFF}", remove that, and it will be normal
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)