radio command help -
ZBits - 01.09.2012
Hello
i need help with Radio command
Code here
pawn Код:
dcmd_r(playerid, params[])
{
if(gTeam[playerid] == TEAM_COP)
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [Text]");
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s(%d): Police Radio: %s , Over.",name,playerid, params);
foreach(Player, i)
{
if(gTeam[i] == TEAM_COP) SendClientMessage(i, COLOR_LIGHTBLUE, string);
}
}
else if(gTeam[playerid] == TEAM_MEDIC)
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [Text]");
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s(%d): Medic Radio: %s , Over.", name, playerid, params);
foreach(Player, i)
{
if(gTeam[i] == TEAM_MEDIC) SendClientMessage(i, COLOR_PINK2, string);
}
}
else if(gTeam[playerid] == TEAM_SWAT)
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_SININE, "USAGE: /r [Text]");
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s(%d): SWAT Radio: %s , Over.", name,playerid, params);
foreach(Player, i)
{
if(gTeam[i] == TEAM_SWAT) SendClientMessage(i, COLOR_LIGHTBLUE, string);
}
}
else if(gTeam[playerid] == TEAM_FBI)
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [Text]");
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s(%d): FBI Radio: %s , Over.", name,playerid, params);
foreach(Player, i)
{
if(gTeam[i] == TEAM_FBI) SendClientMessage(i, COLOR_LIGHTBLUE, string);
}
}
else return SendClientMessage(playerid,COLOR_WHITE,"SERVER: Unknown command.");
return 1;
}
the problem is that whenever i do /r text it gives the message but i want that it should in team cop whenever i am Any other team like Aztecas i can use the police radio and when i am in team cop i cant use the radio
Any help is appreciated
Re: radio command help -
ThePhenix - 01.09.2012
Use it:
PHP код:
CMD:r(playerid,params[])
{
#pragma unused params
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [text] to talk in team radio");
new Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, sizeof(Name));
new string[128];
format(string, sizeof(string), "[R][Team Radio] %s: %s", Name, params[0]);
printf("%s", string);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(i, COLOR_GREEN, string);
}
return 1;
}
I made if for you, I hope it helps.
Re: radio command help -
ZBits - 01.09.2012
i want my code to used only by Team cop,Team medic,Team Swat and Team FBI here are the Defines
pawn Код:
#define TEAM_COP 5
#define TEAM_Medic 7
#define TEAM_SWAT 10
#define TEAM_FBI 9
Please HELP!!
Re: radio command help -
Dan. - 01.09.2012
Your indentation sucks, make it better next time so it will be more readable. I fixed it. And also you don't have to make a new string every time, just put new string and new name into the beginning of the script, so you dont have to write it multiple times. Keep your indentation nice also please.
pawn Код:
dcmd_r(playerid, params[])
{
if(gTeam[playerid] == TEAM_COP || gTeam[playerid] == TEAM_MEDIC || gTeam[playerid] == TEAM_SWAT || gTeam[playerid] == TEAM_SWAT)
{
if(gTeam[playerid] == TEAM_COP)
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [Text]");
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s(%d): Police Radio: %s , Over.",name,playerid, params);
foreach(Player, i)
{
if(gTeam[i] == TEAM_COP) SendClientMessage(i, COLOR_LIGHTBLUE, string);
}
}
else if(gTeam[playerid] == TEAM_MEDIC)
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [Text]");
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s(%d): Medic Radio: %s , Over.", name, playerid, params);
foreach(Player, i)
{
if(gTeam[i] == TEAM_MEDIC) SendClientMessage(i, COLOR_PINK2, string);
}
}
else if(gTeam[playerid] == TEAM_SWAT)
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_SININE, "USAGE: /r [Text]");
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s(%d): SWAT Radio: %s , Over.", name,playerid, params);
foreach(Player, i)
{
if(gTeam[i] == TEAM_SWAT) SendClientMessage(i, COLOR_LIGHTBLUE, string);
}
}
else if(gTeam[playerid] == TEAM_FBI)
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [Text]");
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s(%d): FBI Radio: %s , Over.", name,playerid, params);
foreach(Player, i)
{
if(gTeam[i] == TEAM_FBI) SendClientMessage(i, COLOR_LIGHTBLUE, string);
}
}
else return SendClientMessage(playerid,COLOR_WHITE,"SERVER: Unknown command.");
}
return 1;
}