Problem with teamchat!
#1

'Sup y'all?

Well, I've created a small teamchat, but I just noticed that it doesn't do what I want, lol! For example, if I'm requesting the teamchat to appear with the sign '!', it shows the message just for the team, that's right! But, everything is written in yellow, and I don't want this! I want the team displayed which is chatting with his own color, the player with his team-color and the output-text in white, just like in a normal chat! For example, if I'm in the Grove Street team now:

[Grove] PLAYERNAME: %s (text)

"[Grove]" would be in the team-color, the playername also in his team-color, and the output-text in white! This is what I currently got:

pawn Код:
new string[256];
        new playername[MAX_PLAYER_NAME];
        if(text[0] == '!' && text[1] != 0)
        {
            GetPlayerName(playerid,playername,MAX_PLAYER_NAME);
            format(string,128,"[Team-Chat] %s: %s", playername,text[1] );
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i) && gTeam[playerid] == gTeam[i])
                    SendClientMessage(i,COLOR_YELLOW,string);
            }
            return 0;
     }
Reply
#2

(not tested) Try this out:

pawn Код:
new string[256];
        new playername[MAX_PLAYER_NAME];
        if(text[0] == '!' && text[1] != 0)
        {
            GetPlayerName(playerid,playername,MAX_PLAYER_NAME);
            format(string,128,"[Team-Chat] %s: {FFFFFF}%s", playername,text[1] ); // added ' {FFFFFF} ' - white
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i) && gTeam[playerid] == gTeam[i])
                    SendClientMessage(i,GetPlayerColor(playerid),string); // added GetPlayerColor(playerid)
            }
            return 0;
     }
Reply
#3

Why you use 256 as string :facepalm:
Reply
#4

No, I want instead of "Teamchat" that there's written the player's team, like "[Grove]" or something...
Reply
#5

PHP код:
if(gTeam[playerid] == YOUR_TEAM && PlayerInfo[playerid][pRank] == 1// pRank OR pTeam
        
{
            if(
gTeam[playerid] == YOUR_TEAM)
              {
                
format(stringsizeof(string), "[GROUP-CHAT]%s Says:,"PlayerName[playerid], text);
                
SendTeamMessage(YOUR_TEAMCOLOR_BLUEstring);
            } 

// #define YOUR_TEAM 2
// #define YOUR_TEAM 0x0259EAAA
// #define YOURTEAM_COLOR 0x0259EAAA

PHP код:
   else if(gTeam[playerid] == YOUR_TEAM)
    {
        if(
PlayerInfo[playerid][pRank] == 1)
         {
            
SetPlayerColor(playeridYOURTEAM_COLOR);
        }
        else
        {
             
SetPlayerColor(playeridTEAMCOLOR_NORMAL);
        }
    } 
Maybe u can something use like this ?:P


// by the way pTeam , pRank

enum pInfo
{
pRank,
pTeam
}

I could make mistakes :P
Reply
#6

Erm no, you confused me! This isn't the way I want!

I dunno how else to explain it, I want the team, the name with the teamcolor, and the output!
Reply
#7

PHP код:
CMD:r(playeridparams[])
    {
        new 
idx,tmp[32];
        new 
string[256];
        
tmp strtok(paramsidx);
        new 
length strlen(params);
        while ((
idx length) && (params[idx] <= ' '))
        {
            
idx++;
        }
        new 
offset idx;
        new 
text[64];
        while ((    
idx length) && ((idx offset) < (sizeof(text) - 1)))
        {
            
text[idx offset] = params[idx];
            
idx++;
        }
        
text[idx offset] = EOS;
        if(!
strlen(text))
        {
            
SendClientMessage(playeridCOLOR_GREY"USAGE: /radio [text]");
            return 
1;
        }
        if(
gTeam[playerid] == TEAM_GROVE && PlayerInfo[playerid][pTeam] == 1// this will see if he is in a Team
        
{
            if(
gTeam[playerid] == TEAM_GROVE// so he is Grove
              
{
                
format(stringsizeof(string), "[TEAM-CHAT]%s Says : "PlayerName[playerid], text); // will send the message
                
SendTeamMessage(TEAM_GROVECOLOR_BLUEstring); // will give the team message in the color BLUE
            
}
        }
        else
        {
            
SendClientMessage(playeridCOLOR_RED,"You are not a part of the Grove team!.");
        }
        return 
1;
    } 
Something like this
Reply
#8

Here another huge pice of code

pawn Код:
enum {
    GROVE,
    BALLA,
    VAGOS,
    AZTECAS,
    POLICE,
    RIFAS,
    LOCO,
    DEALERS
}
pawn Код:
#define INVALID_TEAM (-1)
pawn Код:
stock const tData[][] = {
    {0x00AA00FF, "Groove"},
    {0x800080FF, "Ballas"},
    {0xFFFF00FF, "Vagos"}
    //....
};
pawn Код:
stock gTeam[MAX_PLAYERS] = {INVALID_TEAM, ...};
pawn Код:
//OnPlayerText
    if(text[0] == '!') {
        new
            string[180],
            team = gTeam[playerid],
            color = tData[team][0]
        ;
        GetPlayerName(playerid, string, MAX_PLAYER_NAME);
        format(string, sizeof string, "[%s] %s:{FFFFFF} %s", tData[team][1], string, text[1]);

        for(new i; i != MAX_PLAYERS; ++i) {
            // due to the fact that all disconnected players got an invalid team (-1)
            // we can skip the IsPlayerConnected check
            if(gTeam[i] == team) {
                SendClientMessage(i, color, string);
            }
        }
        return false;
     }
pawn Код:
//OnPlayerDisconnect
    gTeam[playerid] = INVALID_TEAM;
Reply
#9

Yeah, Thanks nero
Reply
#10

Hey Nero!

Thanks, but I already have the following enum:

pawn Код:
enum
{
    GROVE,
    BALLA,
    VAGOS,
    AZTECAS,
    POLICE,
    //RIFAS,
    LOCO,
    DEALERS
}
And I can't change it's name, since everything would be fucked up then! How shall I use it?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)