Team chat prob.. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Team chat prob.. (
/showthread.php?tid=450528)
Team chat prob.. -
Steezy_ - 13.07.2013
I did this.. but team chat doesn't work at all, im in team but it says that im not in team.. could someone help me? E_E
Код:
public OnPlayerText(playerid, text[])
{
if(text[0] == '!')
{
if(GetPlayerTeam(playerid) == 255)
{
SendClientMessage(playerid, TEST_COLOUR, "You have to be in a clan to use clan chat");
}
else
{
new string[256];
GetPlayerName(playerid, string, sizeof(string));
format(string, sizeof(string), "[Clan chat]: %s: %s", string, text[1]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(i, GetPlayerColor(playerid), string);
}
}
return 0;
}
return 1;
}
Re: Team chat prob.. -
Rohlik - 13.07.2013
Hi,
pawn Код:
if(text[0] == '!')
{
new name[24], string[256];
GetPlayerName(playerid, name, 24);
format(string, sizeof(string), "[Team Chat]%s: %s", name, text[1]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(team[i] == team[playerid])
SendClientMessage(i, GetPlayerColor(playerid), string);
}
}
return 0;
}
Customize it how you want
And I think that the problem is in the "string" .. You use the string name and string to text ..
Re: Team chat prob.. -
Steezy_ - 13.07.2013
Oh.. kkai, thanks.. but how can I make that if player's team = NO_TEAM that he recives a sendclientmessage with an error..?
Re: Team chat prob.. -
Rohlik - 13.07.2013
pawn Код:
if(GetPlayerTeam(playerid) == 0)
{
SendClientMessage(playerid,-1,"[ ERROR ]You must choose Team !");
return 1;
}
if(text[0] == '!')
{
new name[24], string[256];
GetPlayerName(playerid, name, 24);
format(string, sizeof(string), "[Team Chat]%s: %s", name, text[1]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(team[i] == team[playerid])
SendClientMessage(i, GetPlayerColor(playerid), string);
}
}
return 0;
}
and.. You must change OnPlayerText return 1 to return 0 !!
Re: Team chat prob.. -
Steezy_ - 13.07.2013
Kkaaaaai, thank ya very much..
Re: Team chat prob.. -
Rohlik - 13.07.2013
I think xD