HELP OnPlayerText
#1

Hello ,

I got problem that i can't make the player id before his name I just make it like that:

Code:
public OnPlayerText(playerid,text[])
{
    new str[128];
    format(str, sizeof(str), "[ID:%i]: %s", playerid, text);
    SendPlayerMessageToAll(playerid, str);
	return 0;
}
So its like that:

Example: [ID: 0]: Test

I want to make it

[ID:0] Example: Test

But i failed any idea?

__________________
MY SERVER:
Reply
#2

It failed? You are getting errors? What is the problem?
Reply
#3

You need to get the player name too.
pawn Code:
public OnPlayerText(playerid,text[])
{
    new str[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(str, sizeof(str), "[ID:%i] %s: %s", playerid, pName, text);
    SendPlayerMessageToAll(playerid,str);
    return 0;
}
Reply
#4

nvm.
Reply
#5

Quote:
Originally Posted by Fj0rtizFredde
View Post
You need to get the player name too.
pawn Code:
public OnPlayerText(playerid,text[])
{
    new str[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(str, sizeof(str), "[ID:%i] %s: %s", playerid, pName, text);
    SendPlayerMessageToAll(playerid,str);
    return 0;
}
Also fail Look what it says when i type:

Example: [ID:0] Example: Text
Reply
#6

Try to change:
SendPlayerMessageToAll(playerid,str);
To:
pawn Code:
SendClientMessageToAll(str);
Reply
#7

Quote:
Originally Posted by Fj0rtizFredde
View Post
Try to change:
SendPlayerMessageToAll(playerid,str);
To:
pawn Code:
SendClientMessageToAll(str);
Code:
error 035: argument type mismatch (argument 1)
Reply
#8

I think they are more that 1 OnPlayerText?
_________________
Reply
#9

Oh Im stupid.. I forgot the color parameter. It should look like:
pawn Code:
SendClientMessageToAll(-1,str); //-1 = White you could change it if you want to.
Reply
#10

Awesome its

[ID:0] Example: Text

But they are problem :S its only color white and was before more than color so when player join its give them more than color now its just give white ?
Reply
#11

You can add color for example define:
pawn Code:
#define COL_GREEN          "{6EF83C}"
#define COL_WHITE          "{FFFFFF}"
Then you can use them like this:
pawn Code:
"#COL_GREEN" Green "#COL_WHITE" White
Reply
#12

I know but i want auto colors so not all players have the same color.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)