SA-MP Forums Archive
Send Message to Only Certain Teams - 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: Send Message to Only Certain Teams (/showthread.php?tid=123946)



Send Message to Only Certain Teams - sidhu123 - 28.01.2010

Hello. I'm working on my gamemode and I've run into a slight problem.

I'm trying to script a /911 command. I want the command to be useable by only gangs, not by any public service players.
I've gotten started on it, but I don't really know how to script it. Here's what I have so far:

http://pastebin.com/mf23f608

I'm having trouble with the message being sent to the public service players.
Can someone please help me fix this?


Thanks.


Re: Send Message to Only Certain Teams - PotH3Ad - 28.01.2010

Try this (I'm not sure if it works):

pawn Код:
if(!strcmp(cmdtext, "/911", true, 4)) // 4 is the length of /911
    {
      if(!gTeam[playerid] == TEAM_TRIAD || !gTeam[playerid] == TEAM_VAGOS || !gTeam[playerid] == TEAM_GROVE || !gTeam[playerid] == TEAM_BALLA || !gTeam[playerid] == TEAM_BIKER || !gTeam[playerid] == TEAM_TRUCKER) return SendClientMessage(playerid, 0xFF0000FF, "You cannot use this cmd.");
        {
          if(!cmdtext[4]) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /911 [State Situation]");
          new string[128];
          new name[16];
          GetPlayerName(playerid, name, sizeof(name));
          format(string, 128, "%s %s", name, cmdtext[4]);
          for (new i=0; i<MAX_PLAYERS; i++)
          {
              if(gTeam[i] == TEAM_LSPD || gTeam[i] == TEAM_SFPD || gTeam[i] == TEAM_LVPD || gTeam[i] == TEAM_AREA69 || gTeam[i] == TEAM_GIRLCOP)
                {
                    SendClientMessage(i, COLOR_ORANGE, string);
                    break;
                }
            }
        }
    }



Re: Send Message to Only Certain Teams - kmzr - 28.01.2010

Got this from TouchX
pawn Код:
stock SendMessageToTeam(team,color,mess[])
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(gTeam[i] == team)
{
SendClientMessage(i,color,mess);
}
}
}
}
pawn Код:
SendMessageToTeam(TEAM_NAME,COLOR_LIGHTBLUE,string);



Re: Send Message to Only Certain Teams - StrickenKid - 28.01.2010

This will work:

Код:
	if(!strcmp(cmdtext, "/911", true, 4))
	{
	  if(gTeam[playerid] == TEAM_TRIAD || gTeam[playerid] == TEAM_VAGOS || gTeam[playerid] == TEAM_GROVE || gTeam[playerid] == TEAM_BALLA || gTeam[playerid] == TEAM_BIKER || gTeam[playerid] == TEAM_TRUCKER)
	  {
		  if(!cmdtext[5])
				return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /911 [State Situation]");
		  new string[128];
		  new name[16];
		  GetPlayerName(playerid, name, sizeof(name));
		  format(string, 128, "%s %s", name, cmdtext[5]);
		  for(new i = 0; i < MAX_PLAYERS; i++)
		  {
			  if(gTeam[i] == TEAM_LSPD || gTeam[i] == TEAM_SFPD || gTeam[i] == TEAM_LVPD || gTeam[i] == TEAM_AREA69 || gTeam[i] == TEAM_GIRLCOP)
				{
					SendClientMessage(i, COLOR_ORANGE, string);
				}
			}
		}
		else
		{
		  return SendClientMessage(playerid, 0xFF0000FF, "You cannot use this command.");
		}
	}



Re: Send Message to Only Certain Teams - sidhu123 - 28.01.2010

Quote:
Originally Posted by StrickenKid
This will work:

Код:
	if(!strcmp(cmdtext, "/911", true, 4))
	{
	  if(gTeam[playerid] == TEAM_TRIAD || gTeam[playerid] == TEAM_VAGOS || gTeam[playerid] == TEAM_GROVE || gTeam[playerid] == TEAM_BALLA || gTeam[playerid] == TEAM_BIKER || gTeam[playerid] == TEAM_TRUCKER)
	  {
		  if(!cmdtext[5])
				return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /911 [State Situation]");
		  new string[128];
		  new name[16];
		  GetPlayerName(playerid, name, sizeof(name));
		  format(string, 128, "%s %s", name, cmdtext[5]);
		  for(new i = 0; i < MAX_PLAYERS; i++)
		  {
			  if(gTeam[i] == TEAM_LSPD || gTeam[i] == TEAM_SFPD || gTeam[i] == TEAM_LVPD || gTeam[i] == TEAM_AREA69 || gTeam[i] == TEAM_GIRLCOP)
				{
					SendClientMessage(i, COLOR_ORANGE, string);
				}
			}
		}
		else
		{
		  return SendClientMessage(playerid, 0xFF0000FF, "You cannot use this command.");
		}
	}
Thanks dude!
I`ll give it a shot and let you know how it goes


Re: Send Message to Only Certain Teams - Torran - 28.01.2010

It worked for him btw


Re: Send Message to Only Certain Teams - sidhu123 - 28.01.2010

Quote:
Originally Posted by Torran
It worked for him btw
Haha thanks Torran!

Yes, it worked! Thank youuuu