Disabling a CMD
#1

Alright I'm trying to disable/enable the command CMD:c but it doesn't work, it sends the broadcast but doesn't disable the CMD.

pawn Код:
new noc = 1;

CMD:noc(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
        if (!noc)
        {
            noc = 1;
            BroadCast(COLOR_LIGHTBLUE, "   Community Advisor channel disabled by an Admin!");
        }
        else
        {
            noc = 0;
            BroadCast(COLOR_LIGHTBLUE, "   Community Advisor channel channel enabled by an Admin!");
        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    }
    return 1;
}
Reply
#2

Wait I'm an idiot..

I forgot to disable it in the actual /c command - sorry for asking, but would I do so?

pawn Код:
CMD:c(playerid, params[])
{
    if((PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pDonateRank] >= 5) && advisorchat[playerid])
    {
        new msg[128];
        if(sscanf(params,"s[128]",msg)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: (/c) [staff chat]");
        new szMessage[128];
        format(szMessage, sizeof(szMessage), ""COL_GREEN"[Staff Chat]"COL_GREEN" %s "COL_WHITE"%s: %s", ARank(playerid), GetPlayerNameEx(playerid), msg);
        SendAdvisorMessage(COLOR_COMBINEDCHAT, szMessage);
        Log("logs/cchat.log", szMessage);
    }
    else SendClientMessageEx(playerid,-1,"ERROR: This command is for staff only!");
    return 1;
}
Reply
#3

Код:
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRP.pwn(49460) : warning 209: function "cmd_c" should return a value
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRP.pwn(49461) : error 010: invalid function or declaration
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRP.pwn(49462) : error 010: invalid function or declaration
pawn Код:
CMD:c(playerid, params[])
{
    if((PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pDonateRank] >= 5) && advisorchat[playerid])
    {
        SendClientMessageEx(playerid, COLOR_RED, "   The Community Advisor channel has been disabled by Razer Gaming Roleplay Staff");
        return 1;
    }
        new msg[128];
        if(sscanf(params,"s[128]",msg)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: (/c) [staff chat]");
        new szMessage[128];
        format(szMessage, sizeof(szMessage), ""COL_GREEN"[Staff Chat]"COL_GREEN" %s "COL_WHITE"%s: %s", ARank(playerid), GetPlayerNameEx(playerid), msg);
        SendAdvisorMessage(COLOR_COMBINEDCHAT, szMessage);
        Log("logs/cchat.log", szMessage);
    }
    else SendClientMessageEx(playerid,-1,"ERROR: This command is for staff only!");
    return 1;
}
Reply
#4

An extra closed bracket above else. Plus else has not an if/else if statement above.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
An extra closed bracket above else. Plus else has not an if/else if statement above.
pawn Код:
CMD:c(playerid, params[])
{
    if((PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pDonateRank] >= 5) && advisorchat[playerid])
    {
        SendClientMessageEx(playerid, COLOR_RED, "   The Community Advisor channel has been disabled by Razer Gaming Roleplay Staff");
        return 1;
    }
        new msg[128];
        if(sscanf(params,"s[128]",msg)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: (/c) [staff chat]");
        new szMessage[128];
        format(szMessage, sizeof(szMessage), ""COL_GREEN"[Staff Chat]"COL_GREEN" %s "COL_WHITE"%s: %s", ARank(playerid), GetPlayerNameEx(playerid), msg);
        SendAdvisorMessage(COLOR_COMBINEDCHAT, szMessage);
        Log("logs/cchat.log", szMessage);
        }
        else SendClientMessageEx(playerid,-1,"ERROR: This command is for staff only!");
    }
    return 1;
}
And I'm getting get the errors.
Reply
#6

By indenting your code, look how it looks like:
pawn Код:
CMD:c(playerid, params[])
{
    if((PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pDonateRank] >= 5) && advisorchat[playerid])
    {
        SendClientMessageEx(playerid, COLOR_RED, "   The Community Advisor channel has been disabled by Razer Gaming Roleplay Staff");
        return 1;
    }
    new msg[128];
    if(sscanf(params,"s[128]",msg)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: (/c) [staff chat]");
    new szMessage[128];
    format(szMessage, sizeof(szMessage), ""COL_GREEN"[Staff Chat]"COL_GREEN" %s "COL_WHITE"%s: %s", ARank(playerid), GetPlayerNameEx(playerid), msg);
    SendAdvisorMessage(COLOR_COMBINEDCHAT, szMessage);
    Log("logs/cchat.log", szMessage);
}
else SendClientMessageEx(playerid,-1,"ERROR: This command is for staff only!");
return 1;
}
The bracket above else is wrong, it should not exist. You also have an else with no effect.

Does this
pawn Код:
if((PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pDonateRank] >= 5) && advisorchat[playerid])
    {
        SendClientMessageEx(playerid, COLOR_RED, "   The Community Advisor channel has been disabled by Razer Gaming Roleplay Staff");
        return 1;
    }
have anything to do with this
pawn Код:
else SendClientMessageEx(playerid,-1,"ERROR: This command is for staff only!");
If not, then it should check if they're staff.
pawn Код:
CMD:c(playerid, params[])
{
    if( /* check if they're staff */ )
    {
        if((PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pDonateRank] >= 5) && advisorchat[playerid])
        {
            SendClientMessageEx(playerid, COLOR_RED, "   The Community Advisor channel has been disabled by Razer Gaming Roleplay Staff");
            return 1;
        }
        new msg[128];
        if(sscanf(params,"s[128]",msg)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: (/c) [staff chat]");
        new szMessage[128];
        format(szMessage, sizeof(szMessage), ""COL_GREEN"[Staff Chat]"COL_GREEN" %s "COL_WHITE"%s: %s", ARank(playerid), GetPlayerNameEx(playerid), msg);
        SendAdvisorMessage(COLOR_COMBINEDCHAT, szMessage);
        Log("logs/cchat.log", szMessage);
    }
    else SendClientMessageEx(playerid,-1,"ERROR: This command is for staff only!");
    return 1;
}
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
By indenting your code, look how it looks like:
pawn Код:
CMD:c(playerid, params[])
{
    if((PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pDonateRank] >= 5) && advisorchat[playerid])
    {
        SendClientMessageEx(playerid, COLOR_RED, "   The Community Advisor channel has been disabled by Razer Gaming Roleplay Staff");
        return 1;
    }
    new msg[128];
    if(sscanf(params,"s[128]",msg)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: (/c) [staff chat]");
    new szMessage[128];
    format(szMessage, sizeof(szMessage), ""COL_GREEN"[Staff Chat]"COL_GREEN" %s "COL_WHITE"%s: %s", ARank(playerid), GetPlayerNameEx(playerid), msg);
    SendAdvisorMessage(COLOR_COMBINEDCHAT, szMessage);
    Log("logs/cchat.log", szMessage);
}
else SendClientMessageEx(playerid,-1,"ERROR: This command is for staff only!");
return 1;
}
The bracket above else is wrong, it should not exist. You also have an else with no effect.

Does this
pawn Код:
if((PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pDonateRank] >= 5) && advisorchat[playerid])
    {
        SendClientMessageEx(playerid, COLOR_RED, "   The Community Advisor channel has been disabled by Razer Gaming Roleplay Staff");
        return 1;
    }
have anything to do with this
pawn Код:
else SendClientMessageEx(playerid,-1,"ERROR: This command is for staff only!");
If not, then it should check if they're staff.
pawn Код:
CMD:c(playerid, params[])
{
    if( /* check if they're staff */ )
    {
        if((PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pDonateRank] >= 5) && advisorchat[playerid])
        {
            SendClientMessageEx(playerid, COLOR_RED, "   The Community Advisor channel has been disabled by Razer Gaming Roleplay Staff");
            return 1;
        }
        new msg[128];
        if(sscanf(params,"s[128]",msg)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: (/c) [staff chat]");
        new szMessage[128];
        format(szMessage, sizeof(szMessage), ""COL_GREEN"[Staff Chat]"COL_GREEN" %s "COL_WHITE"%s: %s", ARank(playerid), GetPlayerNameEx(playerid), msg);
        SendAdvisorMessage(COLOR_COMBINEDCHAT, szMessage);
        Log("logs/cchat.log", szMessage);
    }
    else SendClientMessageEx(playerid,-1,"ERROR: This command is for staff only!");
    return 1;
}
pawn Код:
if( /* check if they're staff */ )
Код:
C:\Documents and Settings\Ashley\Desktop\DSRP1\gamemodes\RZRP.pwn(49446) : error 029: invalid expression, assumed zero
Reply
#8

Replace it with the variable you check if they're admins.
Reply
#9

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Replace it with the variable you check if they're admins.
I've tried doing so, but it still gives me errors.
Reply
#10

Quote:
Originally Posted by James Bob
Посмотреть сообщение
I've tried doing so, but it still gives me errors.
post that line where it gives you error here.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)