SA-MP Forums Archive
how to make "playername (1):" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: how to make "playername (1):" (/showthread.php?tid=262774)



how to make "playername (1):" - [EDT]AmanSingh123 - 19.06.2011

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?


Re: how to make "playername (1):" - Unknown_Killer - 19.06.2011

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



Re: how to make "playername (1):" - PrawkC - 19.06.2011

@ ^'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.


Re: how to make "playername (1):" - Cameltoe - 19.06.2011

@ ^'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.


Re: how to make "playername (1):" - [EDT]AmanSingh123 - 19.06.2011

thanks it works :P


Re: how to make "playername (1):" - PrawkC - 19.06.2011

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


Re: how to make "playername (1):" - BigETI - 19.06.2011

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



Re: how to make "playername (1):" - Vince - 19.06.2011

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


Re: how to make "playername (1):" - [EDT]AmanSingh123 - 19.06.2011

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


Re: how to make "playername (1):" - Wesley221 - 19.06.2011

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