Team Chat using gteam
#1

Hiya guys.. In game I have team chat setup so that when you do this..

#Hey guys, come to Grove street!

It displays like this if you are on grove

[Team Chat]Tyrone: Hey guys, come to Grove street!

---

This is all well and good, but for some reason ALL the players can see this chat lol and it's no good!

---

Here is my code..



public OnPlayerText(playerid,text[])
{
if(text[0] == '#')
{
new string[128]; GetPlayerName(playerid, string, sizeof(string));
format(string, sizeof(string), "[Team Radio] %s: %s", string, text[1]);
printf("%s", string);

for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && GetPlayerTeam(i) == GetPlayerTeam(playerid)) SendClientMessage(i, GetPlayerColor(playerid), string);
}
return 0;
}

return 1;
}



Any ideas? +Rep for anyone helping out
Reply
#2

can you give your both gTeam please? i have to do it in other way
Try This
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '#')
    {
        new string[128]; GetPlayerName(playerid, string, sizeof(string));
        format(string, sizeof string, "[Team Radio] %s: %s", string, text[1]);
        printf("%s", string);

        for(new i = 0; i < MAX_PLAYERS; i ++)
        {
            if(IsPlayerConnected(i) && GetPlayerTeam(i) == GetPlayerTeam(playerid)) SendClientMessage(i, GetPlayerColor(playerid), string);
        }
        return 0;
    }
    return 0;
}
Reply
#3

Try this:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '#')
    {
        new string[128]; GetPlayerName(playerid, string, sizeof(string));
        format(string, sizeof string, "[Team Radio] %s: %s", string, text[1]);
        printf("%s", string);

        for(new i = 0; i < MAX_PLAYERS; i ++)
        {
            if(IsPlayerConnected(i) && GetPlayerTeam(i) == GetPlayerTeam(playerid)) SendClientMessage(i, GetPlayerColor(playerid), string);
        }
        return (0);
    }
    return (0);
}
Reply
#4

Quote:
Originally Posted by Roach_
Посмотреть сообщение
Try this:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '#')
    {
        new string[128]; GetPlayerName(playerid, string, sizeof(string));
        format(string, sizeof string, "[Team Radio] %s: %s", string, text[1]);
        printf("%s", string);

        for(new i = 0; i < MAX_PLAYERS; i ++)
        {
            if(IsPlayerConnected(i) && GetPlayerTeam(i) == GetPlayerTeam(playerid)) SendClientMessage(i, GetPlayerColor(playerid), string);
        }
        return (0);
    }
    return (0);
}
What have you changed from my code? Just the return 0? Cos I noticed there is no ()'s on the string in line 6 now.

EDIT: That didn't work.. It broke chat lol..
Reply
#5

No one else got any feedback on this at all?
Reply
#6

PHP код:
public OnPlayerText(playeridtext[])
{
/*=========================================================================================================
                                    Team Chat
==========================================================================================================*/
if(text[0] == '#')
    {
        new 
string[128]; GetPlayerName(playerid,string,sizeof(string));
        
format(string,sizeof(string),"|Team Chat| %s: %s",string,text[1]);
        
MessageToTeam(0xDC686BAA,string);
        }
        return 
0;
    }
//=======================================================================================================//
stock MessageToTeam(color,const string[])
{
    for(new 
0MAX_PLAYERSi++)//Loop through all the players.
    
{
    if(
IsPlayerConnected(i) == 1)//Just if the player is connected.
    
if(GetPlayerTeam(i))//Gets the player team
    
SendClientMessage(icolorstring);//Sends the message to the team.
    
}
    return 
1;

Reply
#7

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
PHP код:
public OnPlayerText(playeridtext[])
{
/*=========================================================================================================
                                    Team Chat
==========================================================================================================*/
if(text[0] == '#')
    {
        new 
string[128]; GetPlayerName(playerid,string,sizeof(string));
        
format(string,sizeof(string),"|Team Chat| %s: %s",string,text[1]);
        
MessageToTeam(0xDC686BAA,string);
        }
        return 
0;
    }
//=======================================================================================================//
stock MessageToTeam(color,const string[])
{
    for(new 
0MAX_PLAYERSi++)//Loop through all the players.
    
{
    if(
IsPlayerConnected(i) == 1)//Just if the player is connected.
    
if(GetPlayerTeam(i))//Gets the player team
    
SendClientMessage(icolorstring);//Sends the message to the team.
    
}
    return 
1;

Hey thanks dude I'm gonna try this out now! Looks very neat & tidy =]
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)