Help with Teamchat - 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: Help with Teamchat (
/showthread.php?tid=228582)
Help with Teamchat -
SanAndreasVille - 20.02.2011
Help me here is a bug in this script what ist wrong ? its spam a message evere second -.-
Код:
dcmd_f(playerid,params[])
{
if(k[playerid] == true || k2[playerid] == true)
{
SendClientMessage(playerid,COLOR_YELLOW, "*You are in the DM World!");
return 1;
}
if(k[playerid] == false && k2[playerid] == false)
{
if(params[0] == 0)
{
SendClientMessage(playerid,0xFF8200FF," Team-Chat -> Benutze: /f [Text]");
return 1;
}
if(IsPlayerConnected(playerid))
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid])
{
new s[16],s2[144];
GetPlayerName(playerid,s,sizeof(s));
format(s2,sizeof(s2),"[TEAMCHAT] %s: %s",s,params[0]);
SendClientMessage(i,0x00D7FFFF,s2);
}
}
return 0;
}
}
return 1;
}
Re: Help with Teamchat - rjjj - 20.02.2011
I think that it can solve your problem:
pawn Код:
dcmd_f(playerid,params[])
{
if(k[playerid] == true || k2[playerid] == true)
{
SendClientMessage(playerid,COLOR_YELLOW, "*You are in the DM World!");
return 1;
}
if(k[playerid] == false && k2[playerid] == false)
{
if(params[0] == 0)
{
SendClientMessage(playerid,0xFF8200FF," Team-Chat -> Benutze: /f [Text]");
return 1;
}
if(IsPlayerConnected(playerid))
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid])
{
new s[16],s2[144];
GetPlayerName(playerid,s,sizeof(s));
format(s2,sizeof(s2),"[TEAMCHAT] %s: %s",s,params[0]);
SendClientMessage(i,0x00D7FFFF,s2);
}
}
return true;//Change return 0 for return true :)
}
}
return 1;
}
I hope that i have helped
Re: Help with Teamchat -
SanAndreasVille - 06.03.2011
hmm dont work, its flood the server with. zbs: "/f Hello guys"
Re: Help with Teamchat -
iggy1 - 06.03.2011
A better way to do teamchat (IMO) would be using OnPlayerText something like this,
pawn Код:
public OnPlayerText(playerid, text[])
{
if(text[0] == '#')
{
new
s[MAX_PLAYER_NAME],
team = GetPlayerTeam(playerid);
GetPlayerName(playerid, s, MAX_PLAYER_NAME);
format(text, 128,"[TEAMCHAT] %s: %s", s, text[1]);
for(new i; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i))continue;
if(GetPlayerTeam(i) == team)//if you use a "gTeam" type var use that ie, if(gTeam[i] == gTeam[playerid])
SendClientMessage(i,0x00D7FFFF, text);
}
return 0;
}
return 1;
}
To use team chat just type #hello team. Anything after hash '#' gets send to players on the same team of the sender.