Team chat [FINALLY WORKED] THANK YOU!
#1

I have no idea if this will work, I found it at forum, my I think it will only send a message on the players chat. not to THE ALL TEAM :S

pawn Код:
if(strcmp(cmd,"/pr",true)==0)
    {
        if (gTeam[playerid] == TEAM_COPS)
            {
                if ((strlen(cmdtext) >= 1)&&(strlen(cmdtext) <= 3))
                    {
                        GetPlayerName(playerid,name,sizeof(name));
                        format(string,sizeof(string),"Police Radio(%s):%s",name,cmdtext[128]);
                        SendCopMessage(0xFFFFFF, string);
                    }
                   
                    else return SendClientMessage(playerid, 0xFFFF00AA, "-> You mean: /pr [Message]");
                    }
                   
                    else return SendClientMessage(playerid, 0xFFFF00AA, "-> You are not a Police Officer");
                    }
pawn Код:
SendCopMessage(color, text[]) {
  for(new i = 0; i < MAX_PLAYERS; i ++) {
  if(IsPlayerConnected(i)) {
  if (gTeam[i] == TEAM_COPS) {
      SendClientMessage(i, color, text);
      }
    }
  }
}
Reply
#2

it will send a message to whoever is connected and is a cop.
Reply
#3

Thank you. So it's now working?
Reply
#4

try it out..
Reply
#5

No, it doesn't work :/
Reply
#6

pawn Код:
if((strlen(cmdtext) >= 1)&&(strlen(cmdtext) <= 3))
{
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"Police Radio(%s):%s",name,cmdtext[128]);
    SendCopMessage(0xFFFFFF, string);
}                  
else return SendClientMessage(playerid, 0xFFFF00AA, "-> You mean: /pr [Message]");
If the message is between 1 and 3 characters in length, display it, otherwise tell them they got it wrong.. Surely it should be the other way round? And also when you format the cmdtext, you'll send a message like:

Quote:

Police Radio(Bob):/pr Hello!

Reply
#7

But, can you tell me the correct way?
Reply
#8

Please I beg youuuu! I really need this to keep with my script!
Reply
#9

try this:
pawn Код:
if(strcmp(cmd,"/pr",true)==0)
{
    if (gTeam[playerid] == TEAM_COPS)
    {
        if ((strlen(cmdtext) > 4)&&(strlen(cmdtext) <= 50))
        {
            new message[50];
            new name[MAX_PLAYERS];
            strmid(message,cmdtext,4,strlen(cmdtext)-4);
            GetPlayerName(playerid,name,sizeof(name));
            format(string,sizeof(string),"Police Radio(%s):%s",name,message);
            SendCopMessage(0xFFFFFF, string);
            return 1;
        }
        else return SendClientMessage(playerid, 0xFFFF00AA, "-> You mean: /pr [Message]");
    }
    else return SendClientMessage(playerid, 0xFFFF00AA, "-> You are not a Police Officer");
}
Reply
#10

A definite improvement, i'd have probably used strdel to save making a new string but there's little in it...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)