TEAM RADIO COMMAND
#1

HI ALL i hope you all fine , i'm trying to find a team radio chat like ( /r [text]) i want the command in strcmd i try many time to find it but nothing help me so i hope you plz help me and thanks
Reply
#2

Код:
CMD:r(playerid,params[]) {
#pragma unused params
if(isnull(params)) return SendClientMessage(playerid, -1, "USAGE: /r [text] to talk in team radio");
new Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, sizeof(Name));
new string[128], adminstr[128];
format(string, sizeof(string), "[R][%i]%s: %s ,over.",playerid, Name, params[0]);
printf("%s", string);
format(adminstr, sizeof(adminstr),">> [R]%s: %s ,over.",GetName(playerid),params[0]);
MessageToAdmins(grey, adminstr);
PS: It's not made by me and you need ZCMD!
Hope this helped u
Reply
#3

well thx dude but this in zcmd i want it in strcmd
Reply
#4

use dcmd
pawn Код:
//add this line on top of your script
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

//Publics:

forward SendAdminMessage(color, string[]);
public SendAdminMessage(color, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            //if(PlayerInfo[i][pAdmin] >= 7)//Admin level defining by Y_INI
            if(IsPlayerAdmin[i]) //defined for RCON admins
            {
                SendClientMessage(i, COLOR_YELLOW, string);
            }
        }
    }
}
public OnPlayerCommandText(playerid, cmdtext[])
{

    dcmd(r,1,cmdtext);
return 1;
}
//command:
dcmd_r(playerid,params[])
{
    new string[128];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    if(!strlen(params))
    {
        SendClientMessage(playerid,COLOR_ERROR,"[USAGE] /ac (Message)");
        return 1;
    }
    format(string,sizeof(string),"Admin %s(%d): %s",pname,playerid,params);
    SendAdminMessage(COLOR_YELLOW,string);
    return 1;
}
SEARCH BEFORE POSTING
Reply
#5

thanks dude but i want it for my team i already have admin chat and i want the radio cmd in /radio or /r thx anyway
Reply
#6

pawn Код:
forward SendTeamMessage(color, string[]);
public SendTeamMessage(color, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(gTeam[playerid] == TEAM)
            {
                SendClientMessage(i, COLOR_YELLOW, string);
            }
        }
    }
}

//and instead of SendAdminMessage in command, SendTeamMessage, use the mind God gave you
Reply
#7

well there is some errors and i wish is there cmd simple more than that plz if you can that well help me more in another thinks
Reply
#8

pawn Код:
dcmd_r(playerid,params[])
{
    new string[128];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    if(!strlen(params))
    {
        SendClientMessage(playerid,-1,"[USAGE] /r (Message)");
        return 1;
    }
for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(gTeam[playerid] == TEAM_GANG)
            {
                  format(string,sizeof(string),"GANG Member%s(%d): %s",pname,playerid,params);
                  SendClientMessage(i,-1, string);
            }
        }
    }
    return 1;
}
Reply
#9

pawn Код:
CMD:r(playerid,params[])
{
new teamstring[129];
format(teamstring, sizeof teamstring, "[Team %d]:%s", gTeam[playerid],params);
SendTeamMessage(gTeam[playerid], 0x00FF00AA, teamstring);
return 1;
}
top of your script/gamemode:

pawn Код:
stock SendTeamMessage(team, color, message[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
          if(gTeam[i] == team)
          {
               SendClientMessage(i, color, message);
          }
    }
}
using zcmd

strcmp:

pawn Код:
if (strcmp("/team", cmdtext, true, 10) == 0)
{
     new idx;
     if(!strlen(strtok(cmdtext, idx)))
     {
           SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /team [text]");
           return 1;
     }
     else
     {
           new teamstring[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid, pName, sizeof(pName));
           format(teamstring, 128, "(T): %s: %s", pName, idx);
           SendTeamMessage(gTeam[playerid], 0x00FF00AA, teamstring);
           return 1;
      }
      return true;
}
top of your script/gamemode:

pawn Код:
stock SendTeamMessage(team, color, message[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
          if(gTeam[i] == team)
          {
               SendClientMessage(i, color, message);
          }
    }
}
strok:

pawn Код:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
put it at the top
Reply
#10

This is my system... It may be able to be simplified, but it works for me....
Also, This is for 2 teams... My server has only 2 teams..


pawn Код:
if (strcmp("/r", cmdtext, true, 10) == 0)
{
    if(GetPlayerTeam(playerid) == 2)
    {
    new pname[MAX_PLAYER_NAME];
    new string[126];
    GetPlayerName(playerid,pname,sizeof(pname));
    format(string,sizeof(string),"[TEAM2-Radio] %s: %s",pname,params);
    SendTeam2Message(0xFF0000FF,string);
    }
    else if(GetPlayerTeam(playerid) == 1)
    {
    new pname[MAX_PLAYER_NAME];
    new string[126];
    GetPlayerName(playerid,pname,sizeof(pname));
    format(string,sizeof(string),"[TEAM2-Radio] %s: %s",pname,params);
    SendTeam1Message(0x0000FFFF,string);
    }
    return 1;
}
pawn Код:
forward SendTeam1Message(color, string[]);
public SendTeam1Message(color, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerTeam(i) == 1)
            {
                SendClientMessage(i, 0x0000FFFF, string);
            }
        }
    }
}
forward SendTeam2Message(color, string[]);
public SendTeam2Message(color, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerTeam(i) == 2)
            {
                SendClientMessage(i, 0xFF0000FF, string);
            }
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)