26.04.2018, 15:48
Hello I've creating a command for Police TEAM! But I want a help In the command everything worked and OnlyCops can use it but there a problem!! I want Only Who joined a COPS/FBI/SWAT/ARMY/CIA Can read the message who! how
After some cop type /cm [MESSAGE] Everyone can read it! I want put it only cops can read the message how?
PHP Code:
CMD:cm(playerid, params[])
{
if(!PoliceTeam(GetPlayerSkin(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "{FF0000}Error: {FFFFFF}Only Law Enforcement may use this command.");
{
new string[128];
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "[SYNTEX]: /CM [Text]");
new pskin = GetPlayerSkin(playerid);
if(pskin == 165 || pskin == 166 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288)
{
if(pskin == 285)
{
format(string, sizeof(string), "{00FFFF}[S.W.A.T]%s: {1E90FF}%s", RPN(playerid), params);
SendPlayerTeamMessage(playerid, BLUE, string);
}
if(pskin == 287)
{
format(string, sizeof(string), "{8B008B}[ARMY]%s: {1E90FF}%s", RPN(playerid), params);
SendPlayerTeamMessage(playerid, BLUE, string);
}
if(pskin == 165 || pskin == 166)
{
format(string, sizeof(string), "{FFFFFF}[C.I.A]%s: {1E90FF}%s", RPN(playerid), params);
SendPlayerTeamMessage(playerid, BLUE, string);
}
if(pskin == 280 || pskin == 281 || pskin == 282 || pskin == 283 || pskin == 284 || pskin == 300 || pskin == 301 || pskin == 302 || pskin == 307 || pskin == 309)
{
format(string, sizeof(string), "{1E90FF}[Police]%s: {1E90FF}%s", RPN(playerid), params);
SendPlayerTeamMessage(playerid, BLUE, string);
}
SetPlayerChatBubble(playerid,params,COLOR_TEAMCHAT,20.0,5000);
}
else
{
SendClientMessage(playerid, RED, "{FF0000}[ERROR]: {FFFFFF}Only police can use this command.");
}
}
return 1;
}
Stocks
PHP Code:
stock SendPlayerTeamMessage(playerid,color, string[])
{
foreach(new i : Player)
{
if(gTeam[i] == gTeam[playerid]) //Here i used gteam(You can use PlayerInfo[playerid][Faction/Gang/Fam]
{
SendClientMessage(i, color, string);
}
}
return 1;
}
stock RPN(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
if(name[i] == '_') name[i] = ' ';
}
return name;
}