CMD:radio(playerid,params[])
{
new name[MAX_PLAYER_NAME],string[128],rank[128];
if(PlayerInfo[playerid][pFaction] == 1 || PlayerInfo[playerid][pFaction] == 2)
{
if(isnull(params)) return SendClientMessage(playerid,COLOR_GREY,"Syntax: (/r)adio [Text]");
else
{
if(PlayerInfo[playerid][pMute] == 0)
{
rank = GetPlayerFactionRank(playerid);
GetPlayerName(playerid,name,sizeof(name));
for(new i=0; i<=MAX_PLAYERS;i++)
{
if(PlayerInfo[i][pFaction] == 1 || PlayerInfo[i][pFaction] == 2)
{
format(string,sizeof(string),"(Radio) {ffffff}%s{9999ff} {ffffff}%s{9999ff}: %s",rank,name,params);
SendClientMessage(i,0x9999FFFF,string);
}
}
}
else{SendClientMessage(playerid,COLOR_RED,"[Mute]: You are muted and you can't speak !");}
}
}
else{SendClientMessage(playerid,COLOR_GREY,"You aren't authorized to talk on this frequency !");}
return 1;
}
stock GetPlayerFactionRank(playerid)
{
new rank[128];
if(PlayerInfo[playerid][pFaction] == 0){rank = "Civil";}
if(PlayerInfo[playerid][pFaction] == 1)
{
if(PlayerInfo[playerid][pRank] == 1){rank = "Patrol Officer";}
if(PlayerInfo[playerid][pRank] == 2){rank = "Police Officer";}
if(PlayerInfo[playerid][pRank] == 3){rank = "Sergeant";}
if(PlayerInfo[playerid][pRank] == 4){rank = "Lieutant";}
if(PlayerInfo[playerid][pRank] == 5){rank = "Police Captain";}
if(PlayerInfo[playerid][pRank] == 6){rank = "Deputy Inspector";}
if(PlayerInfo[playerid][pRank] == 7){rank = "Colonel";}
if(PlayerInfo[playerid][pRank] == 8){rank = "Commander";}
if(PlayerInfo[playerid][pRank] == 9){rank = "Deputy Chief";}
if(PlayerInfo[playerid][pRank] == 10){rank = "Police Chief";}
}
return rank;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
return 0;
}
Description
Important: Since v0.3 OnPlayerCommandText cannot be used anymore (also ZCMD_NO_CALLBACK option has been removed), but there are two new callbacks instead: pawn Код:
pawn Код:
Note that it's not necessary to add these callbacks to your script if you don't use them. How to make two different commands doing the same thing |
rank = GetPlayerFactionRank(playerid);
CMD:radio(playerid,params[])
{
if(PlayerInfo[playerid][pFaction] != 1 && PlayerInfo[playerid][pFaction] != 2) return SendClientMessage(playerid,COLOR_GREY,"You aren't authorized to talk on this frequency !");
if(isnull(params)) return SendClientMessage(playerid,COLOR_GREY,"Syntax: (/r)adio [Text]");
if(PlayerInfo[playerid][pMute] != 0) return SendClientMessage(playerid,COLOR_RED,"[Mute]: You are muted and you can't speak !");
new name[21],string[128];
GetPlayerName(playerid,name,sizeof(name));
for(new i=0; i<MAX_PLAYERS;i++)
{
if(PlayerInfo[i][pFaction] == 1 || PlayerInfo[i][pFaction] == 2)
{
format(string,sizeof(string),"(Radio) {ffffff}%s{9999ff} {ffffff}%s{9999ff}: %s",GetPlayerFactionRank(playerid),name,params);
SendClientMessage(i,0x9999FFFF,string);
}
}
return 1;
}
stock GetPlayerFactionRank(playerid)
{
new rank[32];
switch (PlayerInfo[playerid][pFaction])
{
case 0: rank = "Civil";
case 1:
{
switch (PlayerInfo[playerid][pRank])
{
case 1: rank = "Patrol Officer";
case 2: rank = "Police Officer";
case 3: rank = "Sergeant";
case 4: rank = "Lieutant";
case 5: rank = "Police Captain";
case 6: rank = "Deputy Inspector";
case 7: rank = "Colonel";
case 8: rank = "Commander";
case 9: rank = "Deputy Chief";
case 10: rank = "Police Chief";
}
}
}
return rank;
}