PDA

View Full Version : Onplayertext


Tanush123
18/05/2013, 04:12 PM
I'm trying to make it shows the playerid in front of their name
public OnPlayerText(playerid, text[])
{
GetPlayerName(playerid,Nam,sizeof(Nam));
if(PlayerData[playerid][Member] == -255)
{
format(query,sizeof(query),"%s[%d]: %s",Nam,playerid,text);
SendClientMessageToAll(-1,query);
}
if(PlayerData[playerid][Member] > 0)
{
format(query,sizeof(query),"%s[%d]:{FFFFFF} %s",Nam,playerid,text);
SendClientMessageToAll(HexToInt(OrgInfo[PlayerData[playerid][Member]][Color]),query);
}

it sends the message 2 times
"%s[%d]: %s"
"%s: %s"

NL-Sultan
18/05/2013, 04:17 PM
You should use 'else' if I'm right, and not twice 'if' on the way how you've done it.

Tanush123
18/05/2013, 04:22 PM
but at the same time there cant be someone with -255 and over 0

Chenko
18/05/2013, 04:27 PM
Return 0 at the end of OnPlayerText

Revo
18/05/2013, 04:27 PM
return 0 at the end so it never sends the original message. Or return 0 whenever your if has sent what it needs to send.

George_Fratelli
18/05/2013, 04:29 PM
public OnPlayerText(playerid, text[])
{
new string[128];
GetPlayerName(playerid, pName, sizeof(pName));
if(PlayerData[playerid][Member] == -255)
{
format(string, sizeof(string), "[%d]%s:%s",playerid, pName, text);
SCMTA(COLOR_WHITE, string);
return 0;
}
else if(PlayerData[playerid][Member] > 0)
{
format(query,sizeof(query),"%s[%d]:{FFFFFF} %s",Nam,playerid,text);
SCMTA(HexToInt(OrgInfo[PlayerData[playerid][Member]][Color]),query);
return 0;
}
return 0;
}


Might work, Not sure though.

Tanush123
18/05/2013, 06:27 PM
thanks