OnPlayerText
#1

Hey guys, I'm trying to make it so that if a player is admin they see the global chat as

Name [Player's ID]: Text

If the player is not admin it's displayed as

Name: Text

Here is my code.
PHP код:
public OnPlayerText(playeridtext[])
{
    new 
string[200];
    if(
PlayerInfo[playerid][pAdmin] >= 1)
    {
        
format(stringsizeof(string), "%s {FFFFFF}[%d]: %s"GetName(playerid), playeridtext);
        
ABroadCast(GetPlayerColor(playerid), string1);
    }
    else if(
PlayerInfo[playerid][pAdmin] == 0)
    {
        
format(string,sizeof(string), "%s: %s"GetName(playerid), text);
        
SendClientMessageToAll(GetPlayerColor(playerid), string);
    }
    return 
1;
 } 
Do I need to make a stock that doesn't display the message to admins?
Reply
#2

You're checking if the player that is writing the text IS admin or not, and we're not trying to achieve that (from what I understood). We need to do that for players receiving the message.

Can you show us your ABroadCast function code?
Reply
#3

new GetName[24];
GetPlayerName(playerid, GetName, sizeof(GetName));

maybe?
Reply
#4

Not GetName(), I mean ABroadCast, so we can add what you need based in the function you're already using.
Reply
#5

Код:
public OnPlayerText(playerid, text[]) 
{ 
    new string[200]; 
    if(PlayerInfo[playerid][pAdmin] >= 1) 
    { 
        format(string, sizeof(string), "%s {FFFFFF}[%d]: %s", GetName(playerid), playerid, text); 
        ABroadCast(GetPlayerColor(playerid), string, 1); 
    } 
    else
    { 
        format(string,sizeof(string), "%s: %s", GetName(playerid), text); 
        SendClientMessageToAll(GetPlayerColor(playerid), string); 
    return 0;
	} 
    return 0; 
 }
Reply
#6

Код:
public OnPlayerText(playerid, text[])
{
    new string[145], color = GetPlayerColor(playerid);
    GetPlayerName(playerid, string, 25);
    format(string, sizeof (string), "%s [%d]: {FFFFFF}%s", string, playerid, text);

    for (new i, j = GetPlayerPoolSize(); i <= j; i++)
    {
        if (!IsPlayerConnected(i))
            continue;
        if (PlayerInfo[i][pAdmin] > 0)
        {
            SendClientMessage(i, color, string);
            continue;
        }
        SendPlayerMessageToPlayer(i, playerid, text);
    }
    return 0;
}
Reply
#7

Thank you @Stinged it worked.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)