CM Command
#1

I've creating a cm command for cops! BUT idk why it's dose not shown the mesasge... can you help me? I mean If a player a cop or swat and sending a message to ALL TEAM POLICE they must read it and civilan's players must not read it.. I've do everything but its not work..

PHP код:
CMD:cm(playeridparams[])
{
    if(!
PoliceTeam(GetPlayerSkin(playerid)) && !SWAT(GetPlayerSkin(playerid)) && !Army(GetPlayerSkin(playerid)) && !FBII(GetPlayerSkin(playerid)) && !CIA(GetPlayerSkin(playerid))) return SendClientMessage(playerid0xE74C3CFF"{FF0000}Error: {FFFFFF}Only Law Enforcement may use this command.");
    new 
message[100];
    if(
sscanf(params"s[100]"message)) return SendClientMessage(playeridRED"[USAGE]: /CM [Message]");
    if(
strlen(message) < || strlen(message) > 100) return SendClientMessage(playeridRED"{ff0000}Error: {FFFFFF}Your message can only contain 1-100 characters.");
    {
        if(!
PoliceTeam(GetPlayerSkin(playerid)))
        {
            
format(fstrsizeof(fstr), "[COP RADIO]: OFFICER %s[%d]: %s."GetName(playerid), playeridmessage);
            
CopRadio(COLOR_DODGERBLUEfstr);
        }
        if(!
SWAT(GetPlayerSkin(playerid)))
        {
            
format(fstrsizeof(fstr), "[COP RADIO]: S.W.A.T %s[%d]: %s."GetName(playerid), playeridmessage);
            
CopRadio(COLOR_DODGERBLUEfstr);
        }
        if(!
Army(GetPlayerSkin(playerid)))
        {
            
format(fstrsizeof(fstr), "[COP RADIO]: A.R.M.Y %s[%d]: %s."GetName(playerid), playeridmessage);
            
CopRadio(COLOR_DODGERBLUEfstr);
        }
        if(!
FBII(GetPlayerSkin(playerid)))
        {
            
format(fstrsizeof(fstr), "[COP RADIO]: FBI %s[%d]: %s."GetName(playerid), playeridmessage);
            
CopRadio(COLOR_DODGERBLUEfstr);
        }
        if(!
CIA(GetPlayerSkin(playerid)))
        {
            
format(fstrsizeof(fstr), "[COP RADIO]: C.I.A %s[%d]: %s."GetName(playerid), playeridmessage);
            
CopRadio(COLOR_DODGERBLUEfstr);
        }
    }
    return 
1;

PHP код:
stock CopRadio(color,const string[])
{
    foreach(new 
Player)
    {
        if(
GetPlayerState(i) != PLAYER_STATE_NONE)
        {
            if(!
PoliceTeam(GetPlayerSkin(i)) && !SWAT(GetPlayerSkin(i)) && !Army(GetPlayerSkin(i)) && !FBII(GetPlayerSkin(i)) && !CIA(GetPlayerSkin(i)))
            {
                
SendClientMessage(icolorstring);
            }
        }
    }
    return 
1;

Reply
#2

post functions, PoliceTeam and GetPlayerSkin, i want to see something
Reply
#3

Problem is not from stocks but anyway here you go.

PHP код:
stock PoliceTeam(skinid)
{
    
// includes corrupt cops from singleplayer, SWAT, FBI and Army skin and 0.3.7 cop ones
    
switch(skinid)
    {
        case 
280..281282..283284..288300..301302..306: return 1;
        default: return 
0;
    }
    return 
1;
}
stock Civilian(skinid)
{
    switch(
skinid)
    {
        case 
1..299:return 1;
        default: return 
0;
    }
    return 
1;
}
stock SWAT(skinid)
{
    switch(
skinid)
    {
        case 
285: return 1;
        default: return 
0;
    }
    return 
1;
}
stock CIA(skinid)
{
    switch(
skinid)
    {
        case 
165..166: return 1;
        default: return 
0;
    }
    return 
1;
}
stock FBII(skinid)
{
    switch(
skinid)
    {
        case 
286: return 1;
        default: return 
0;
    }
    return 
1;
}
stock Army(skinid)
{
    switch(
skinid)
    {
        case 
287: return 1;
        default: return 
0;
    }
    return 
1;

Reply
#4

do you want the message to see all the cops and simple players not seeing?
Reply
#5

try now

stock CopRadio(color, const string[])
{
foreach(new i: Player)
{
if(PoliceTeam(GetPlayerSkin(i)) || SWAT(GetPlayerSkin(i)) || Army(GetPlayerSkin(i)) || FBII(GetPlayerSkin(i)) || CIA(GetPlayerSkin(i)))
{
SendClientMessage(i, color, string);
}
}
return 1;
}



and to these functions [ if(!PoliceTeam(GetPlayerSkin(playerid))) ] try to remove " ! "
Reply
#6

Hi It's worked & Thank you but When I using /cm and message they spamming all teams! In the chat.. I just if his skin id280 saying OFFICER %s message not all teams & spam..
Reply
#7

try now

PHP код:

CMD
:cm(playeridparams[]) 

    if(!
PoliceTeam(GetPlayerSkin(playerid)) && !SWAT(GetPlayerSkin(playerid)) && !Army(GetPlayerSkin(playerid)) && !FBII(GetPlayerSkin(playerid)) && !CIA(GetPlayerSkin(playerid))) return SendClientMessage(playerid0xE74C3CFF"{FF0000}Error: {FFFFFF}Only Law Enforcement may use this command."); 
    new 
message[100]; 
    if(
sscanf(params"s[100]"message)) return SendClientMessage(playeridRED"[USAGE]: /CM [Message]"); 
    if(
strlen(message) < || strlen(message) > 100) return SendClientMessage(playeridRED"{ff0000}Error: {FFFFFF}Your message can only contain 1-100 characters.");
    
CopRadio(COLOR_DODGERBLUEmessage); 
    return 
1
}  
stock CopRadio(color, const message[]) 

    foreach(new 
iPlayer
    { 
        new 
string[200];
        if(
PoliceTeam(GetPlayerSkin(i))) 
        { 
            
format(stringsizeof(string), "[COP RADIO]: OFFICER %s[%d]: %s."GetName(i), imessage); 
            
SendClientMessage(icolorstring); 
        } 
        if(
SWAT(GetPlayerSkin(i))) 
        { 
            
format(stringsizeof(string), "[COP RADIO]: S.W.A.T %s[%d]: %s."GetName(i), imessage); 
           
SendClientMessage(icolorstring);
        } 
        if(
Army(GetPlayerSkin(i))) 
        { 
            
format(stringsizeof(string), "[COP RADIO]: A.R.M.Y %s[%d]: %s."GetName(i), imessage); 
           
SendClientMessage(icolorstring);
        } 
        if(
FBII(GetPlayerSkin(i))) 
        { 
            
format(stringsizeof(string), "[COP RADIO]: FBI %s[%d]: %s."GetName(i), imessage); 
            
SendClientMessage(icolorstring);
        } 
        if(
CIA(GetPlayerSkin(i))) 
        { 
            
format(stringsizeof(string), "[COP RADIO]: C.I.A %s[%d]: %s."GetName(i), imessage); 
            
SendClientMessage(icolorstring);
        } 
    } 
    return 
1

it's not tested, I do not know if there's any error.
Reply
#8

There will be so many bugs because It's only on faction on stock because I've doing another ideas for STOCK RADIO.. I'll try change some of your code.. leeme try and I'll back to you.
Reply
#9

Quote:
Originally Posted by Man43
Посмотреть сообщение
There will be so many bugs because It's only on faction on stock because I've doing another ideas for STOCK RADIO.. I'll try change some of your code.. leeme try and I'll back to you.
try first what I gave you, and how I made your order and function and see first if it works.
Reply
#10

I trying to do that BUT Only C.I.A + Officer worked and other bugs with OFFICER They saying

PHP код:
CMD:cm(playeridparams[])
{
    if(!
PoliceTeam(GetPlayerSkin(playerid)) && !SWAT(GetPlayerSkin(playerid)) && !Army(GetPlayerSkin(playerid)) && !FBII(GetPlayerSkin(playerid)) && !CIA(GetPlayerSkin(playerid))) return SendClientMessage(playerid0xE74C3CFF"{FF0000}Error: {FFFFFF}Only Law Enforcement may use this command.");
    new 
message[30];
    if(
sscanf(params"s[30]"message)) return SendClientMessage(playeridRED"[USAGE]: /CM [Message]");
    if(
strlen(message) < || strlen(message) > 30) return SendClientMessage(playeridRED"{ff0000}Error: {FFFFFF}Your message can only contain 1-30 characters.");
    {
        if(
PoliceTeam(GetPlayerSkin(playerid)))
        {
            
format(fstrsizeof(fstr), "[COP RADIO]: OFFICER %s[%d]: %s."GetName(playerid), playeridmessage);
            
CopRadio(COLOR_DODGERBLUEfstr);
        }
        else if(
SWAT(GetPlayerSkin(playerid)))
        {
            
format(fstrsizeof(fstr), "[COP RADIO]: S.W.A.T %s[%d]: %s."GetName(playerid), playeridmessage);
            
CopRadio(COLOR_DODGERBLUEfstr);
        }
        else if(
Army(GetPlayerSkin(playerid)))
        {
            
format(fstrsizeof(fstr), "[COP RADIO]: A.R.M.Y %s[%d]: %s."GetName(playerid), playeridmessage);
            
CopRadio(COLOR_DODGERBLUEfstr);
        }
        else if(
FBII(GetPlayerSkin(playerid)))
        {
            
format(fstrsizeof(fstr), "[COP RADIO]: FBI %s[%d]: %s."GetName(playerid), playeridmessage);
            
CopRadio(COLOR_DODGERBLUEfstr);
        }
        else if(
CIA(GetPlayerSkin(playerid)))
        {
            
format(fstrsizeof(fstr), "[COP RADIO]: C.I.A %s[%d]: %s."GetName(playerid), playeridmessage);
            
CopRadio(COLOR_DODGERBLUEfstr);
        }
    }
    return 
1;

PHP код:
stock CopRadio(color, const string[])
{
foreach(new 
iPlayer)
{
if(
PoliceTeam(GetPlayerSkin(i)) || SWAT(GetPlayerSkin(i)) || Army(GetPlayerSkin(i)) || FBII(GetPlayerSkin(i)) || CIA(GetPlayerSkin(i)))
{
SendClientMessage(icolorstring);
}
}
return 
1;

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)