SA-MP Forums Archive
OnPlayerText (RCON ADMIN) - 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)
+--- Thread: OnPlayerText (RCON ADMIN) (/showthread.php?tid=664498)



OnPlayerText (RCON ADMIN) - Mohaowmad - 02.03.2019

Hello
this is my code

Код:
public OnPlayerText(playerid, text[])
{
    if(IsPlayerAdmin(playerid))
    {
     new pName[MAX_PLAYER_NAME], String[128], Prefix[] = "{FF0000}[Admin] ";
        GetPlayerName(playerid, pName, 24);
        format(String, sizeof(String), "%s%s %s", Prefix, pName, text);
        SendClientMessageToAll(-1,String);
        return 1;
    }
    return 1;
}
my problem is when i chat with rcon admin all of my chat color will be red altough my teams are Yellow/Blue/Green
like http://s9.picofile.com/file/8353847126/Untitled.png
i want that Admin Prefix be RED and my name become my colors of my teams


Thanks


Re: OnPlayerText (RCON ADMIN) - polygxn - 02.03.2019

Just put your team color behind the [Admin] prefix inside the variable.


Re: OnPlayerText (RCON ADMIN) - Mohaowmad - 02.03.2019

Sorry i Don't Understand :/


Re: OnPlayerText (RCON ADMIN) - v1k1nG - 02.03.2019

PHP код:
new TeamColor[9];
format(TeamColorsizeof TeamColor"{ff0000}"); // Team color here, I put RED just for example
public OnPlayerText(playeridtext[])
{
    if(
IsPlayerAdmin(playerid))
    {
     new 
pName[MAX_PLAYER_NAME], String[128], Prefix[] = "{FF0000}[Admin] ";
        
GetPlayerName(playeridpName24);
        
format(Stringsizeof(String), "%s%s%s %s"PrefixpNameTeamColortext);
        
SendClientMessageToAll(-1,String);
        return 
1;
    }
    return 
1;

Define a global variable, in this case TeamColor, use it to save team colors for cases like this.


Re: OnPlayerText (RCON ADMIN) - Mohaowmad - 02.03.2019

Thanks m8
i did that

Код HTML:
public OnPlayerText(playerid, text[])
{
    if(IsPlayerAdmin(playerid))
    {
        if(gTeam[playerid] == TEAM_1)
        {
     	new pName[MAX_PLAYER_NAME], String[128], Prefix[] = "{FF0000}[Admin] ";
        GetPlayerName(playerid, pName, 24);
        format(String, sizeof(String), "{FFFF00}%s%s{000000}%s %s", Prefix, TeamColor, pName, text);
        SendClientMessageToAll(-1,String);
        return 0;
        }
        if(gTeam[playerid] == TEAM_2)
        {
     	new pName[MAX_PLAYER_NAME], String[128], Prefix[] = "{FF0000}[Admin] ";
        GetPlayerName(playerid, pName, 24);
        format(String, sizeof(String), "{00FF00}%s%s{000000}%s %s", Prefix, TeamColor, pName, text);
        SendClientMessageToAll(-1,String);
        return 0;
        }
    }
    return 1;
}
is it right ?
Team 1 and Team 2 has Different Colors


Re: OnPlayerText (RCON ADMIN) - v1k1nG - 02.03.2019

Some editings, you don't need the team check

PHP код:
new TeamColor[MAX_TEAMS][9]; // Do you have MAX_TEAMS defined?
public OnGameModeInit(){
format(TeamColor[TEAM_1],9"{ff0000}"); // color 1
format(TeamColor[TEAM_2],9"{ff0000}"); // color 2
return 1;
}
public 
OnPlayerText(playeridtext[])
{
    if(
IsPlayerAdmin(playerid))
    {
     new 
pName[MAX_PLAYER_NAME], String[128], Prefix[] = "{FF0000}[Admin] ";
        
GetPlayerName(playeridpName24);
        
format(Stringsizeof(String), "%s%s%s %s"PrefixpNameTeamColor[gTeam[playerid]], text);
        
SendClientMessageToAll(-1,String);
        return 
1;
    }
    return 
1;




Re: OnPlayerText (RCON ADMIN) - PPC23 - 02.03.2019

If the team color is the same as player's color you can take a look at this:
https://sampwiki.blast.hk/wiki/Color_li...GetPlayerColor

Your code should look like:
Код:
format(String, sizeof(String), "%s{%06x}%s {FFFFFF}%s", Prefix, GetPlayerColor(playerid) >>> 8, pName, text);



Re: OnPlayerText (RCON ADMIN) - Mohaowmad - 02.03.2019

Tnx man
That Worked Perfectly!