MySQL /setlevel problem
#1

Hello.Today I started making my new admin system.And i got problem with /setlevel.This is my second time about scripting MySQL system.So when I type in game /setlevel It`s shows me /setlevel <id> <level>.It`s good.But when I type /setlevel 0 5.It`s shows me again /setlevel <id> <level>.I don`t know in what is problem..anyone can help?

here is code:

pawn Код:
CMD:setlevel(playerid,params[])
{
    new Level,playerid2,Query[500],string[160];
    if(AdminL[playerid] == 5)return SendClientMessage(playerid,0xFFFFFFFF,""COL_RED"[ADMIN]{FFFFFF}You are not allowed to use this command!");
    if(sscanf(params, "ud", playerid2, Level)) return SendClientMessage(playerid,0xFFFFFFFF, "Usage: /setlevel <id> <level>");
    if (Level < 0 || Level > 5) return SendClientMessage(playerid,0xFFFFFFFF, "Admin levels are between 1 - 5");
    format(Query, sizeof(Query), "UPDATE `playerdata` SET `level` = %d  WHERE `user` = '%s'", Level, PlayerName(playerid2));
    mysql_query(Query);
    mysql_free_result();
    format(string, sizeof(string), "You have set {FF00AA}%s(%d){FFFFFF} admin level to %d", PlayerName(playerid2), playerid2, Level);
    SendClientMessage(playerid, 0xFFFFFF, string);
    if(AdminL[playerid] < Level) format(string, sizeof(string), "You have been {CC00FF}promoted{FFFFFF} to level %d admin by admin %s(%d)", Level, PlayerName(playerid), playerid);
    if(AdminL[playerid] > Level) format(string, sizeof(string), "You have been {FF00AA}demoted{FFFFFF} to level %d admin by admin %s(%d)", Level, PlayerName(playerid), playerid);
    SendClientMessage(playerid2, 0xFFFFFF, string);
    AdminL[playerid] = Level;
    return 1;
}
Reply
#2

Anyone can help me?
Reply
#3

This maybe works
pawn Код:
CMD:setlevel(playerid, params[])
{
    new
        id,
        level
    ;
    if(AdminL[playerid] >= 5 || RconAdmin(playerid))
    {
        if(sscanf(params, "ui", id, level))
        {
            return SendClientMessage(playerid, LBLUE, "Usage: /setlevel (playerid) (level)") &&
            SendClientMessage(playerid, GREEN, "Function: Set a person a admin");
        }
        if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED, "ERROR: That is a invalid player ID");
        format(str, sizeof(str), "UPDATE `playerdata` SET `level` = %d WHERE `User` = '%s'", level, pName(id));
        mysql_query(str);
        format(str, sizeof(str), "|- Administrator %s has made %s (%d) admin level %d -|", pName(playerid), pName(id), id, level);
        SendClientMessageToAll(ORANGE, str);
    AdminL[playerid] = Level;
    }
    else SendClientMessage(playerid, RED, "ERROR: You are not a level 5 admin!");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)