FOOC Command (Rep+)
#1

PHP код:
CMD:fooc(playerid,params[])
{
    new 
string[128],message;
     if(
sscanf(params,"s",message)) return SCM(playerid,COLOR_GRAY,"Syntax: /fooc [Message]");
    for(new 
0MAX_PLAYERSi++)
    {
        if(
PlayerInfo[playerid][pGroup] == || PlayerInfo[playerid][pRank] == 1)
        {
            
format(string,sizeof(string),"[Recruit] %s: %s",GetName(playerid),message);
            
SCM(i,COLOR_OOC,string);
        }
        else if(
PlayerInfo[playerid][pGroup] == || PlayerInfo[playerid][pRank] == 2)
        {
            
format(string,sizeof(string),"[Officer] %s: %s",GetName(playerid),message);
            
SCM(i,COLOR_OOC,string);
        }
        else if(
PlayerInfo[playerid][pGroup] == || PlayerInfo[playerid][pRank] == 3)
        {
            
format(string,sizeof(string),"[Senior Officer] %s: %s",GetName(playerid),message);
            
SCM(i,COLOR_OOC,string);
        }
        else if(
PlayerInfo[playerid][pGroup] == || PlayerInfo[playerid][pRank] == 4)
        {
            
format(string,sizeof(string),"[Lieutenant] %s: %s",GetName(playerid),message);
            
SCM(i,COLOR_OOC,string);
        }
        else if(
PlayerInfo[playerid][pGroup] == || PlayerInfo[playerid][pRank] == 5)
        {
            
format(string,sizeof(string),"[Captain] %s: %s",GetName(playerid),message);
            
SCM(i,COLOR_OOC,string);
        }
        else if(
PlayerInfo[playerid][pGroup] == || PlayerInfo[playerid][pRank] == 6)
        {
            
format(string,sizeof(string),"[Colonel] %s: %s",GetName(playerid),message);
            
SCM(i,COLOR_OOC,string);
        }
    }
    return 
1;

Problem is whenever I go ingame and do /fooc Test it says [Recruit] Josh_Clark: test But it should say [Colonel] Josh_Clark: Test because i'm rank 6.. can anyone help?
Reply
#2

|| means "or"

replace all || into && which means "and"
PHP код:
CMD:fooc(playerid,params[]) 

    new 
string[128],message
     if(
sscanf(params,"s",message)) return SCM(playerid,COLOR_GRAY,"Syntax: /fooc [Message]"); 
    for(new 
0MAX_PLAYERSi++) 
    { 
        if(
PlayerInfo[playerid][pGroup] == && PlayerInfo[playerid][pRank] == 1
        { 
            
format(string,sizeof(string),"[Recruit] %s: %s",GetName(playerid),message); 
            
SCM(i,COLOR_OOC,string); 
        } 
        else if(
PlayerInfo[playerid][pGroup] == && PlayerInfo[playerid][pRank] == 2
        { 
            
format(string,sizeof(string),"[Officer] %s: %s",GetName(playerid),message); 
            
SCM(i,COLOR_OOC,string); 
        } 
        else if(
PlayerInfo[playerid][pGroup] == && PlayerInfo[playerid][pRank] == 3
        { 
            
format(string,sizeof(string),"[Senior Officer] %s: %s",GetName(playerid),message); 
            
SCM(i,COLOR_OOC,string); 
        } 
        else if(
PlayerInfo[playerid][pGroup] == && PlayerInfo[playerid][pRank] == 4
        { 
            
format(string,sizeof(string),"[Lieutenant] %s: %s",GetName(playerid),message); 
            
SCM(i,COLOR_OOC,string); 
        } 
        else if(
PlayerInfo[playerid][pGroup] == && PlayerInfo[playerid][pRank] == 5
        { 
            
format(string,sizeof(string),"[Captain] %s: %s",GetName(playerid),message); 
            
SCM(i,COLOR_OOC,string); 
        } 
        else if(
PlayerInfo[playerid][pGroup] == && PlayerInfo[playerid][pRank] == 6
        { 
            
format(string,sizeof(string),"[Colonel] %s: %s",GetName(playerid),message); 
            
SCM(i,COLOR_OOC,string); 
        } 
    } 
    return 
1

Reply
#3

No need to use sscanf:

pawn Код:
CMD:fooc(playerid,params[])
{
    new string[ 128 ];
    if( isnull ( params ) ) return SCM( playerid, COLOR_GRAY,"Syntax: /fooc [Message]" );
    for ( new i = 0; i < MAX_PLAYERS; i++ )
    {
        if(PlayerInfo[playerid][pGroup] == 1 && PlayerInfo[playerid][pRank] == 1)
        {
            format(string,sizeof(string),"[Recruit] %s: %s",GetName(playerid),params);
            SCM(i,COLOR_OOC,string);
        }
        else if(PlayerInfo[playerid][pGroup] == 1 && PlayerInfo[playerid][pRank] == 2)
        {
            format(string,sizeof(string),"[Officer] %s: %s",GetName(playerid),params);
            SCM(i,COLOR_OOC,string);
        }
        else if(PlayerInfo[playerid][pGroup] == 1 && PlayerInfo[playerid][pRank] == 3)
        {
            format(string,sizeof(string),"[Senior Officer] %s: %s",GetName(playerid),params);
            SCM(i,COLOR_OOC,string);
        }
        else if(PlayerInfo[playerid][pGroup] == 1 && PlayerInfo[playerid][pRank] == 4)
        {
            format(string,sizeof(string),"[Lieutenant] %s: %s",GetName(playerid),params);
            SCM(i,COLOR_OOC,string);
        }
        else if(PlayerInfo[playerid][pGroup] == 1 && PlayerInfo[playerid][pRank] == 5)
        {
            format(string,sizeof(string),"[Captain] %s: %s",GetName(playerid),params);
            SCM(i,COLOR_OOC,string);
        }
        else if(PlayerInfo[playerid][pGroup] == 1 && PlayerInfo[playerid][pRank] == 6)
        {
            format(string,sizeof(string),"[Colonel] %s: %s",GetName(playerid),params);
            SCM(i,COLOR_OOC,string);
        }
    }
    return 1;
}
EDIT: user above was faster.
Reply
#4

Thanks for the help guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)