Something wrong with sscanf
#1

When I don't type anything, other than: "/setsec", it comes up saying: "That person is not an administrator!"
Can somebody see the error?

pawn Код:
COMMAND:setsec(playerid, params[])
    {
        if(PlayerInfo[playerid][pAdminlevel] >= 5 || PlayerInfo[playerid][pHR] >= 2 || PlayerInfo[playerid][pAP] >= 2 || PlayerInfo[playerid][pSecurity] >= 2)
        {
            if(GetPVarInt(playerid, "StaffLogin") == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You must be logged into the staff panel to access administration commands. (/stafflogin)");
            new giveplayerid, task[8], string[128];
            if(sscanf(params, "us[8]", giveplayerid, task))
            {
                SendClientMessage(playerid, COLOR_GREY, "USAGE: /setsec [playerid] [secondary task]");
                SendClientMessage(playerid, COLOR_GRAD6, "Secondary Tasks: FMod, GMod, BA, ST, PR, HR, Sec");
            }
            if(giveplayerid != INVALID_PLAYER_ID)
            {
                if(PlayerInfo[giveplayerid][pAdminlevel] >= 2)
                {
                    if(strcmp(task, "fmod", true) == 0)
                    {
                        if(PlayerInfo[giveplayerid][pFactionModerator] == 0)
                        {
                            PlayerInfo[giveplayerid][pFactionModerator] = 1;
                            SendClientMessage(playerid, COLOR_WHITE, "You have made them a Faction Moderator");
                            SendClientMessage(giveplayerid, COLOR_WHITE, "You have been made a Faction Moderator");
                            format(string, sizeof(string), "%s has given Faction Moderator to %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
                            AdminMessageLog(string, playerid, "Secondary Task");
                        }
                        else
                        {
                            PlayerInfo[giveplayerid][pFactionModerator] = 0;
                            SendClientMessage(playerid, COLOR_GREY, "You have taken their Faction Moderator");
                            SendClientMessage(giveplayerid, COLOR_GREY, "You have had your Faction Moderator taken");
                            format(string, sizeof(string), "%s has taken Faction Moderator from %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
                            AdminMessageLog(string, playerid, "Secondary Task");
                        }
                    }
                    if(strcmp(task, "ba", true) == 0)
                    {
                        if(PlayerInfo[giveplayerid][pBanAppealer] == 0)
                        {
                            PlayerInfo[giveplayerid][pBanAppealer] = 1;
                            SendClientMessage(playerid, COLOR_WHITE, "You have made them a Ban Appealer");
                            SendClientMessage(giveplayerid, COLOR_WHITE, "You have been made a Ban Appealer");
                            format(string, sizeof(string), "%s has given Ban Appealer to %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
                            AdminMessageLog(string, playerid, "Secondary Task");
                        }
                        else
                        {
                            PlayerInfo[giveplayerid][pBanAppealer] = 0;
                            SendClientMessage(playerid, COLOR_GREY, "You have taken their Ban Appealer");
                            SendClientMessage(giveplayerid, COLOR_GREY, "You have had your Ban Appealer taken");
                            format(string, sizeof(string), "%s has taken Ban Appealer from %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
                            AdminMessageLog(string, playerid, "Secondary Task");
                        }
                    }
                    if(strcmp(task, "st", true) == 0)
                    {
                        if(PlayerInfo[giveplayerid][pShopTech] == 0)
                        {
                            PlayerInfo[giveplayerid][pShopTech] = 1;
                            SendClientMessage(playerid, COLOR_WHITE, "You have made them a Shop Tech");
                            SendClientMessage(giveplayerid, COLOR_WHITE, "You have been made a Shop Tech");
                            format(string, sizeof(string), "%s has given Shop Tech to %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
                            AdminMessageLog(string, playerid, "Secondary Task");
                        }
                        else
                        {
                            PlayerInfo[giveplayerid][pShopTech] = 0;
                            SendClientMessage(playerid, COLOR_GREY, "You have taken their Shop Tech");
                            SendClientMessage(giveplayerid, COLOR_GREY, "You have had your Shop Tech taken");
                            format(string, sizeof(string), "%s has taken Shop Tech from %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
                            AdminMessageLog(string, playerid, "Secondary Task");
                        }
                    }
                    if(strcmp(task, "pr", true) == 0)
                    {
                        if(PlayerInfo[giveplayerid][pPR] == 0)
                        {
                            PlayerInfo[giveplayerid][pPR] = 1;
                            SendClientMessage(playerid, COLOR_WHITE, "You have made them a member of Public Relations");
                            SendClientMessage(giveplayerid, COLOR_WHITE, "You have been made a Public Relations");
                            format(string, sizeof(string), "%s has given Public Relations to %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
                            AdminMessageLog(string, playerid, "Secondary Task");
                        }
                        else
                        {
                            PlayerInfo[giveplayerid][pPR] = 0;
                            SendClientMessage(playerid, COLOR_GREY, "You have taken their Public Relations division..");
                            SendClientMessage(giveplayerid, COLOR_GREY, "You have had your Public Relations taken");
                            format(string, sizeof(string), "%s has taken Public Relations from %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
                            AdminMessageLog(string, playerid, "Secondary Task");
                        }
                    }
                    if(strcmp(task, "hr", true) == 0)
                    {
                        if(PlayerInfo[giveplayerid][pBanAppealer] == 0)
                        {
                            PlayerInfo[giveplayerid][pBanAppealer] = 1;
                            SendClientMessage(playerid, COLOR_WHITE, "You have made them a Human Resources division.");
                            SendClientMessage(giveplayerid, COLOR_WHITE, "You have been made a member of Human Resources");
                            format(string, sizeof(string), "%s has given Human Resources to %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
                            AdminMessageLog(string, playerid, "Secondary Task");
                        }
                        else
                        {
                            PlayerInfo[giveplayerid][pBanAppealer] = 0;
                            SendClientMessage(playerid, COLOR_GREY, "You have taken their Human Resources");
                            SendClientMessage(giveplayerid, COLOR_GREY, "You have had your Human Resources taken");
                            format(string, sizeof(string), "%s has taken Human Resources from %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
                            AdminMessageLog(string, playerid, "Secondary Task");
                        }
                    }
                    if(strcmp(task, "sec", true) == 0)
                    {
                        if(PlayerInfo[giveplayerid][pSecurity] == 0)
                        {
                            PlayerInfo[giveplayerid][pSecurity] = 1;
                            SendClientMessage(playerid, COLOR_WHITE, "You have made them a Security");
                            SendClientMessage(giveplayerid, COLOR_WHITE, "You have been made a memeber of the Security division.");
                            format(string, sizeof(string), "%s has given Human Resources to %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
                            AdminMessageLog(string, playerid, "Secondary Task");
                        }
                        else
                        {
                            PlayerInfo[giveplayerid][pBanAppealer] = 0;
                            SendClientMessage(playerid, COLOR_GREY, "You have taken their Security permissions.");
                            SendClientMessage(giveplayerid, COLOR_GREY, "You have had your Security permissions taken");
                            format(string, sizeof(string), "%s has taken Security from %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
                            AdminMessageLog(string, playerid, "Secondary Task");
                        }
                    }
                   
                }
                else return SendClientMessage(playerid, COLOR_LIGHTRED, "That person is not an administrator!");               
            }
            else return SendClientMessage(playerid, COLOR_LIGHTRED, "That person is not connected.");
                       
        }
        SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command.");
        return 1;
    }
Reply
#2

pawn Код:
if(PlayerInfo[giveplayerid][pAdminlevel] >= 2)
So the message "The person is not an administrator" is sent if the player has pAdminLevel less than or equal to 1. Is that correct?
Reply
#3

pawn Код:
if(!sscanf(params, "us[8]", giveplayerid, task))//It was this line, now it should work.
Reply
#4

I dunno, but are you meant to have it so only admin level 2+ can be affected by this command?

I also noticed that you have a nasty habit of not replying on solved threads, and give absolutely no appreciation for anyone's effort. So hopefully you can maybe even give a 'thanks' for the code I'm about to give you...

pawn Код:
COMMAND:setsec(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminlevel] < 5 && PlayerInfo[playerid][pHR] < 2 && PlayerInfo[playerid][pAP] < 2 && PlayerInfo[playerid][pSecurity] < 2) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command.");
    if(!GetPVarInt(playerid, "StaffLogin")) return SendClientMessage(playerid, COLOR_LIGHTRED, "You must be logged into the staff panel to access administration commands. (/stafflogin)");
    new giveplayerid, task[8];
    if(sscanf(params, "us[8]", giveplayerid, task))
    {
        SendClientMessage(playerid, COLOR_GREY, "USAGE: /setsec [playerid] [secondary task]");
        return SendClientMessage(playerid, COLOR_GRAD6, "Secondary Tasks: FMod, GMod, BA, ST, PR, HR, Sec");
    }
    if(giveplayerid == INVALID_PLAYER_ID || !IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "That person is not connected.");
    if(PlayerInfo[giveplayerid][pAdminlevel] < 2) return SendClientMessage(playerid, COLOR_LIGHTRED, "That person is not an administrator!");
    new string[85];
    if(!strcmp(task, "fmod", true))
    {
        if(!PlayerInfo[giveplayerid][pFactionModerator])
        {
            SendClientMessage(playerid, COLOR_WHITE, "You have made them a Faction Moderator");
            SendClientMessage(giveplayerid, COLOR_WHITE, "You have been made a Faction Moderator");
            format(string, sizeof(string), "%s has given Faction Moderator to %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You have taken their Faction Moderator");
            SendClientMessage(giveplayerid, COLOR_GREY, "You have had your Faction Moderator taken");
            format(string, sizeof(string), "%s has taken Faction Moderator from %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
        }
        PlayerInfo[giveplayerid][pFactionModerator] = (PlayerInfo[giveplayerid][pFactionModerator]) ? (0) : (1);
    }
    else if(!strcmp(task, "ba", true))
    {
        if(!PlayerInfo[giveplayerid][pBanAppealer])
        {
            SendClientMessage(playerid, COLOR_WHITE, "You have made them a Ban Appealer");
            SendClientMessage(giveplayerid, COLOR_WHITE, "You have been made a Ban Appealer");
            format(string, sizeof(string), "%s has given Ban Appealer to %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You have taken their Ban Appealer");
            SendClientMessage(giveplayerid, COLOR_GREY, "You have had your Ban Appealer taken");
            format(string, sizeof(string), "%s has taken Ban Appealer from %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
        }
        PlayerInfo[giveplayerid][pBanAppealer] = (PlayerInfo[giveplayerid][pBanAppealer]) ? (0) : (1);
    }
    else if(!strcmp(task, "st", true))
    {
        if(!PlayerInfo[giveplayerid][pShopTech])
        {
            SendClientMessage(playerid, COLOR_WHITE, "You have made them a Shop Tech");
            SendClientMessage(giveplayerid, COLOR_WHITE, "You have been made a Shop Tech");
            format(string, sizeof(string), "%s has given Shop Tech to %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You have taken their Shop Tech");
            SendClientMessage(giveplayerid, COLOR_GREY, "You have had your Shop Tech taken");
            format(string, sizeof(string), "%s has taken Shop Tech from %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
        }
        PlayerInfo[giveplayerid][pShopTech] = (PlayerInfo[giveplayerid][pShopTech]) ? (0) : (1);
    }
    else if(!strcmp(task, "pr", true))
    {
        if(PlayerInfo[giveplayerid][pPR])
        {
            SendClientMessage(playerid, COLOR_WHITE, "You have made them a member of Public Relations");
            SendClientMessage(giveplayerid, COLOR_WHITE, "You have been made a Public Relations");
            format(string, sizeof(string), "%s has given Public Relations to %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You have taken their Public Relations division..");
            SendClientMessage(giveplayerid, COLOR_GREY, "You have had your Public Relations taken");
            format(string, sizeof(string), "%s has taken Public Relations from %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
        }
        PlayerInfo[giveplayerid][pPR] = (PlayerInfo[giveplayerid][pPR]) ? (0) : (1);
    }
    if(!strcmp(task, "hr", true))
    {
        if(PlayerInfo[giveplayerid][pHR])
        {
            SendClientMessage(playerid, COLOR_WHITE, "You have made them a Human Resources division.");
            SendClientMessage(giveplayerid, COLOR_WHITE, "You have been made a member of Human Resources");
            format(string, sizeof(string), "%s has given Human Resources to %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You have taken their Human Resources");
            SendClientMessage(giveplayerid, COLOR_GREY, "You have had your Human Resources taken");
            format(string, sizeof(string), "%s has taken Human Resources from %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
        }
        PlayerInfo[giveplayerid][pHR] = (PlayerInfo[giveplayerid][pHR]) ? (0) : (1);
    }
    if(!strcmp(task, "sec", true))
    {
        if(PlayerInfo[giveplayerid][pSecurity])
        {
            SendClientMessage(playerid, COLOR_WHITE, "You have made them a Security");
            SendClientMessage(giveplayerid, COLOR_WHITE, "You have been made a memeber of the Security division.");
            format(string, sizeof(string), "%s has given Human Resources to %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You have taken their Security permissions.");
            SendClientMessage(giveplayerid, COLOR_GREY, "You have had your Security permissions taken");
            format(string, sizeof(string), "%s has taken Security from %s", GetNameWithSpace(playerid), GetNameWithSpace(giveplayerid));
        }
        PlayerInfo[giveplayerid][pSecurity] = (PlayerInfo[giveplayerid][pSecurity]) ? (0) : (1);
    }
    else return SendClientMessage(playerid, COLOR_GRAD6, "Secondary Tasks: FMod, GMod, BA, ST, PR, HR, Sec");
    AdminMessageLog(string, playerid, "Secondary Task");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)