Problem with teamchat! -
Twisted_Insane - 31.03.2012
'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;
}
Re: Problem with teamchat! -
vyper - 31.03.2012
(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;
}
Re: Problem with teamchat! -
sjvt - 31.03.2012
Why you use 256 as string :facepalm:
Re: Problem with teamchat! -
Twisted_Insane - 31.03.2012
No, I want instead of "Teamchat" that there's written the player's team, like "[Grove]" or something...
Re: Problem with teamchat! -
Randyy - 31.03.2012
PHP код:
if(gTeam[playerid] == YOUR_TEAM && PlayerInfo[playerid][pRank] == 1) // pRank OR pTeam
{
if(gTeam[playerid] == YOUR_TEAM)
{
format(string, sizeof(string), "[GROUP-CHAT]%s Says:,", PlayerName[playerid], text);
SendTeamMessage(YOUR_TEAM, COLOR_BLUE, string);
}
// #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(playerid, YOURTEAM_COLOR);
}
else
{
SetPlayerColor(playerid, TEAMCOLOR_NORMAL);
}
}
Maybe u can something use like this ?:P
// by the way pTeam , pRank
enum pInfo
{
pRank,
pTeam
}
I could make mistakes :P
Re: Problem with teamchat! -
Twisted_Insane - 31.03.2012
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!
Re: Problem with teamchat! -
Randyy - 31.03.2012
PHP код:
CMD:r(playerid, params[])
{
new idx,tmp[32];
new string[256];
tmp = strtok(params, idx);
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(playerid, COLOR_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(string, sizeof(string), "[TEAM-CHAT]%s Says : ", PlayerName[playerid], text); // will send the message
SendTeamMessage(TEAM_GROVE, COLOR_BLUE, string); // will give the team message in the color BLUE
}
}
else
{
SendClientMessage(playerid, COLOR_RED,"You are not a part of the Grove team!.");
}
return 1;
}
Something like this
AW: Problem with teamchat! -
Nero_3D - 31.03.2012
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;
Re: Problem with teamchat! -
Randyy - 31.03.2012
Yeah, Thanks nero
Re: Problem with teamchat! -
Twisted_Insane - 31.03.2012
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?