SA-MP Forums Archive
[Help] Team Chats - 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] Team Chats (/showthread.php?tid=154293)



[Help] Team Chats - Albanian1980 - 13.06.2010

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!


Re: [Help] Team Chats - LTomi - 13.06.2010

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.


Re: [Help] Team Chats - TheInnocentOne - 13.06.2010

http://pastebin.com/YzaZcFPy

Or the first example, mine may not work lol


Re: [Help] Team Chats - Albanian1980 - 13.06.2010

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


Re: [Help] Team Chats - TheInnocentOne - 13.06.2010

You aren't setting their teams.


Re: [Help] Team Chats - Albanian1980 - 13.06.2010

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);
          }
        }
     }
   }
}
}



Re: [Help] Team Chats - TheInnocentOne - 13.06.2010

That code goes under the OnPlayerCommandText callback


Re: [Help] Team Chats - Albanian1980 - 13.06.2010

I did place it under there.


Re: [Help] Team Chats - Albanian1980 - 13.06.2010

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