OnPlayerText (RCON ADMIN)
#1

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
Reply
#2

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

Sorry i Don't Understand :/
Reply
#4

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.
Reply
#5

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
Reply
#6

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;

Reply
#7

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);
Reply
#8

Tnx man
That Worked Perfectly!
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)