sscanf problem
#1

pawn Код:
dcmd_setcmdlevel(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= CheckLevel("setcmdlevel"))
    {
        new cmdname[30],str[128],lvl;
        if(sscanf(params,"s[30]i",cmdname,lvl))
        {
            SendClientMessage(playerid, red, "USAGE: /setcmdlevel [command] [level]");
            return 1;
        }
        else if(CommandExist(cmdname))
        {
            for(new i;i<217;i++)
            {
                if(YHash(cmdname, false)==Cmds[i][Unique])
                {
                    Cmds[i][Level]=lvl;
                }
            }
            format(str,sizeof(str),"The required level from %s is set to %i",cmdname,lvl);
            SendClientMessage(playerid,blue,str);
            return 1;
        }
        else
        {
            format(str,sizeof(str),"Command %s is not found",cmdname);
            SendClientMessage(playerid,blue,str);
            return 1;
        }
    } else LevelError(playerid,"setcmdlevel");
    return 1;
}
when i follow the right syntax it says unknown command. but when i dont follow the syntax it says the error speciefied in the sendclientmessage. help please? it acts not the way it must act
Reply
#2

Try this:

pawn Код:
dcmd_setcmdlevel(playerid, params[]
{
    if(PlayerInfo[playerid][Level] >= CheckLevel("setcmdlevel"))
    {
        new cmdname[30], str[128], lvl;
        if(sscanf(params, "s[30]i", cmdname, lvl)) return SendClientMessage(playerid, red, "USAGE: / setcmdlevel [command] [level]");
       
        if(CommandExist(cmdname))
        {
            for(new i;i<217;i++)
            {
                if(YHash(cmdname, false)==Cmds[i][Unique])
                {
                    Cmds[i][Level]=lvl;
                }
            }
            format(str,sizeof(str),"The required level from %s is set to %i",cmdname,lvl);
            SendClientMessage(playerid,blue,str);
        } else {
            format(str,sizeof(str),"Command %s is not found",cmdname);
            SendClientMessage(playerid,blue,str);
            return 1;
        }
    } else return LevelError(playerid,"setcmdlevel");
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)