16.08.2013, 15:47
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
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);
//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;
}
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
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;
}
CMD:r(playerid,params[])
{
new teamstring[129];
format(teamstring, sizeof teamstring, "[Team %d]:%s", gTeam[playerid],params);
SendTeamMessage(gTeam[playerid], 0x00FF00AA, teamstring);
return 1;
}
stock SendTeamMessage(team, color, message[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(gTeam[i] == team)
{
SendClientMessage(i, color, message);
}
}
}
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;
}
stock SendTeamMessage(team, color, message[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(gTeam[i] == team)
{
SendClientMessage(i, color, message);
}
}
}
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;
}
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;
}
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);
}
}
}
}