Team Chat using gteam -
Phil_Cutcliffe - 29.01.2013
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
Re: Team Chat using gteam - Patrick - 29.01.2013
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;
}
Re: Team Chat using gteam -
Roach_ - 29.01.2013
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);
}
Re: Team Chat using gteam -
Phil_Cutcliffe - 29.01.2013
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..
Re: Team Chat using gteam -
Phil_Cutcliffe - 29.01.2013
No one else got any feedback on this at all?
Re: Team Chat using gteam -
ThePhenix - 29.01.2013
PHP код:
public OnPlayerText(playerid, text[])
{
/*=========================================================================================================
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 i = 0; i < MAX_PLAYERS; i++)//Loop through all the players.
{
if(IsPlayerConnected(i) == 1)//Just if the player is connected.
if(GetPlayerTeam(i))//Gets the player team
SendClientMessage(i, color, string);//Sends the message to the team.
}
return 1;
}
Re: Team Chat using gteam -
Phil_Cutcliffe - 29.01.2013
Quote:
Originally Posted by ThePhenix
PHP код:
public OnPlayerText(playerid, text[])
{
/*=========================================================================================================
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 i = 0; i < MAX_PLAYERS; i++)//Loop through all the players.
{
if(IsPlayerConnected(i) == 1)//Just if the player is connected.
if(GetPlayerTeam(i))//Gets the player team
SendClientMessage(i, color, string);//Sends the message to the team.
}
return 1;
}
|
Hey thanks dude I'm gonna try this out now! Looks very neat & tidy =]