Problem with my command
#3

Quote:
Originally Posted by Lynn
Посмотреть сообщение
pawn Код:
CMD:giverank(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new targetid, level;
        if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, -1, "/giverank [playerid/partofname] [level]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not currently online!");
          if(!(-1 < level < 20 )) return SendClientMessage(playerid, -1, "The max level is 16!");
        new faclevel[20], astr[128], sendername[MAX_PLAYER_NAME];
        if(PlayerInfo[playerid][pAdmin] == 99999 || PlayerFacInfo[playerid][Fac] == 15)
        {
            switch(level)
            {
                case 0:
                {
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(astr, sizeof(astr), "You have been demoted by Admin %s", sendername);
                    SendClientMessage(targetid, -1, astr);
                    GetPlayerName(targetid, sendername, sizeof(sendername));
                    format(astr, sizeof(astr), "You have demoted %s of their Admin rank.", sendername);
                    SendClientMessage(playerid, -1, astr);
                    PlayerFacInfo[targetid][Fac] = level;
                    return 1;
                }
                case 1: faclevel = "Cadet In Training";
                case 2: faclevel = "Cadet";
                case 3: faclevel = "Officer";
                case 4: faclevel = "Corporal";
                case 5: faclevel = "Sergeant";
                case 6: faclevel = "Sergeant Grade Two";
                case 7: faclevel = "Lieutenant";
                case 8: faclevel = "Inspector";
                case 9: faclevel = "Captain";
                case 10: faclevel = "Major";
                case 11: faclevel = "Major Grade Two";
                case 12: faclevel = "Commander";
                case 13: faclevel = "Commissioner";
                case 14: faclevel = "Chief Inspector";
                case 15: faclevel = "Deputy Chief";
                case 16: faclevel = "Chief";
                default: return SendClientMessage(playerid, -1, "You have entered an invalid level. (0 - 16)");
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(astr, sizeof(astr), "You have been made into a %s by Admin %s!", faclevel, sendername);
            SendClientMessage(targetid, -1, astr);
            GetPlayerName(targetid, sendername, sizeof(sendername));
            format(astr, sizeof(astr), "You have made %s into a %s!", sendername, faclevel);
            SendClientMessage(playerid, -1, astr);
            PlayerFacInfo[targetid][Fac] = level;
            PlayerFacInfo[targetid][FacType] = 1;
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "You do not meet the level requirement for using this command!");
    }
    return 1;
}
Thanks, much appreciated. What was wrong with my original code? I couldn't find what you changed and I would like to know what you did in order to prevent issues in the future.
Reply


Messages In This Thread
Problem with my command - by K9IsGodly - 14.05.2014, 16:56
Re: Problem with my command - by Lynn - 14.05.2014, 17:24
Re: Problem with my command - by K9IsGodly - 14.05.2014, 17:33
Re: Problem with my command - by Lynn - 14.05.2014, 17:39

Forum Jump:


Users browsing this thread: 1 Guest(s)