[Help] Team Chats
#1

I have been scripting and trying out many ways to make team chat commands. I use GetPlayerTeam not gTeam and have tried many things. Can someone please help me out and show me a template on how to setup a Team Chat Command. Thanks!
Reply
#2

pawn Код:
if(strcmp("/team", cmdtext, true) == 0)
{
   if(IsPlayerConnected(playerid))
   {
     GetPlayerName(playerid, sendername, sizeof(sendername));
     while ((idx < strlen(cmdtext)) && (cmdtext[idx] <= ' '))
     {
        idx++;
     }
     new offset = idx;
     new result[64];
     while ((idx < strlen(cmdtext)) && ((idx - offset) < (sizeof(result) - 1)))
     {
        result[idx - offset] = cmdtext[idx];
        idx++;
     }
     result[idx - offset] = EOS;
     if(!strlen(result))
     {
        SendClientMessage(playerid, COLOR_WHITE, "Usage: /team [Text]");
     }
     else
     {
        format(string, sizeof(string), "%s: %s", sendername, result);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
          if(GetPlayerTeam(i) == GetPlayerTeam(playerid))
          {
             SendClientMessage(i, COLOR_WHITE, string);
          }
        }
     }
   }
}
}
I haven't tested it but it should work.
Reply
#3

http://pastebin.com/YzaZcFPy

Or the first example, mine may not work lol
Reply
#4

LTomi I put it in get no errors and when I go in game to test it, it doesn't work.
Reply
#5

You aren't setting their teams.
Reply
#6

I am not sure If I placed it in the wrong area:
Код:
if(strcmp("/team", cmdtext, true) == 0)
{
   if(IsPlayerConnected(playerid))
   {
     GetPlayerName(playerid, sendername, sizeof(sendername));
     while ((idx < strlen(cmdtext)) && (cmdtext[idx] <= ' '))
     {
        idx++;
     }
     new offset = idx;
     new result[64];
     while ((idx < strlen(cmdtext)) && ((idx - offset) < (sizeof(result) - 1)))
     {
        result[idx - offset] = cmdtext[idx];
        idx++;
     }
     result[idx - offset] = EOS;
     if(!strlen(result))
     {
        SendClientMessage(playerid, COLOR_WHITE, "Usage: /team [Text]");
     }
     else
     {
        format(string, sizeof(string), "%s: %s", sendername, result);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
          if(GetPlayerTeam(i) == TEAM_COP) // Add Team Here?
          {
             SendClientMessage(i, COLOR_WHITE, string);
          }
        }
     }
   }
}
}
Reply
#7

That code goes under the OnPlayerCommandText callback
Reply
#8

I did place it under there.
Reply
#9

Someone Please help me. This is the only issue I have.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)