team chat - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: team chat (
/showthread.php?tid=149590)
team chat -
shoru93 - 22.05.2010
public OnPlayerText(playerid, text[])
{
if(PlayerIsMuted[playerid] == 1)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You are muted and cannot talk.");
return false;
}
if(text[0] == '@')
{
new string[256], pName[24];
if(PlayerInfo[playerid][AdminLevel] < 1)
{
GetPlayerName(playerid,pName,sizeof(pName));
format(string, sizeof(string), "Admin Chat - %s: %s", pName, text[1]);
SendModMsg(COLOR_YELLOW, string);
}
return 0;
}
if(text[0] == '!')
{
new string[128];
GetPlayerName(playerid, string, sizeof(string));
format(string, sizeof(string), "[Team] %s: %s", string, text[1]);
printf("%s", string);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(i, GetPlayerColor(playerid), string);
}
return 0;
}
return 1;
}
Why I can see other team text?
Re: team chat -
dice7 - 22.05.2010
pawn Код:
if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(i, GetPlayerColor(playerid), string);
Re: team chat -
Joe_ - 22.05.2010
Try and use pawn tags next time please
pawn Код:
public OnPlayerText(playerid, text[])
{
new pName[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, pName, sizeof(pName));
if(PlayerIsMuted[playerid] == 1)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You are muted and cannot talk.");
return 0;
}
if(text[0] == '@')
{
if(PlayerInfo[playerid][AdminLevel] >= 1)
{
format(string, sizeof(string), "Admin Chat - %s: %s", pName, text[1]);
SendModMsg(COLOR_YELLOW, string);
return 1;
}
return 0;
}
if(text[0] == '!')
{
format(string, sizeof(string), "[Team] %s: %s", pName, text[1]);
printf("%s", string);
for(new i=0,b=GetMaxPlayers();i<b;i++)
{
if(gTeam[i] == gTeam[playerid]) SendClientMessage(i, GetPlayerColor(playerid), string);
}
return 1;
}
return 1;
}
It SHOULD work, not tested
I also cleaned up your code.
Instead of two times making a varible, I made it only once, I also shortened the array 'string' to 128 cells instead of 256 (Not needed!!)