Setlevel
#1

Can someone tell me why this wont work? I tried enough on it and can't get it to work.

pawn Код:
dcmd_setlevel(playerid,params[])
{
    new level,id,file[256],n[MAX_PLAYER_NAME], tmp[256], tmp2[256], Index,str[50];
    tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp),level = strval(tmp2);
    GetPlayerName(id,n,MAX_PLAYER_NAME); format(file,sizeof(file),"FAdmin/Users/%s.sav",n);
    if(PlayerInfo[playerid][Level] >= 6 || IsPlayerAdmin(playerid)) {
        if(!strlen(params)) return SendClientMessage(playerid,red,"USAGE: /setlevel <ID> <Level>");
        if(!IsPlayerConnected(id)) {
            if(level > 8 || level < 0) return SendClientMessage(playerid,red,"Invalid Level");
            format(str,sizeof(str),"~b~~h~~h~New ~g~admin level ~w~level (%d)",level);
            GameTextForPlayer(id,str,5000, 3);
            PlayerInfo[id][Level] = level;
            dini_IntSet(file,"Level",level);
        } else return SendERROR(playerid, 3);
    } else return SendERROR(playerid, 1);
    return 1;
}
Thanks in advance.
Reply
#2

Instead of going on the forums and asking for help with probably an extremely minor issue, why don't you just debug it with printfs and see what the final results are?

It'd save everyone else a hell of a lot of time.

Also, I was under the impression that dini was only for saving *.ini files. Correct me if I'm wrong, but shouldn't you be using dudb for that kind of file operation?
Reply
#3

Read my signature, the black text.
Reply
#4

Quote:
Originally Posted by willsuckformoney
Посмотреть сообщение
Read my signature, the black text.
Read your name, and add an 'it' to the name. You're clearly extremely stupid. Congratulations on demonstrating your horrid scripting skills to the forum, btw.
Reply
#5

I say using MySQL is faster and more efficient. (Depending on how well you know it).

This is my SetLevel Command, I'm a little to tired to change it. You can get a simple base off of it.
pawn Код:
CMD:setlevel(playerid, params[])
{
    new
        id,
        level
    ;
    if(PlayerInfo[playerid][Admin] >= 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 `playerinfo` SET `Admin` = %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);
        PlayerInfo[playerid][Admin] = level;
    }
    else SendClientMessage(playerid, RED, "ERROR: You are not a level 5 admin!");
    return 1;
}
With the enum's...I save their stats OnDisconnect, or every 15 seconds with a timer or something.
Reply
#6

Quote:
Originally Posted by willsuckformoney
Посмотреть сообщение
Can someone tell me why this wont work? I tried enough on it and can't get it to work.

pawn Код:
dcmd_setlevel(playerid,params[])
{
    new level,id,file[256],n[MAX_PLAYER_NAME], tmp[256], tmp2[256], Index,str[50];
    tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp),level = strval(tmp2);
    GetPlayerName(id,n,MAX_PLAYER_NAME); format(file,sizeof(file),"FAdmin/Users/%s.sav",n);
    if(PlayerInfo[playerid][Level] >= 6 || IsPlayerAdmin(playerid)) {
        if(!strlen(params)) return SendClientMessage(playerid,red,"USAGE: /setlevel <ID> <Level>");
        if(!IsPlayerConnected(id)) {
            if(level > 8 || level < 0) return SendClientMessage(playerid,red,"Invalid Level");
            format(str,sizeof(str),"~b~~h~~h~New ~g~admin level ~w~level (%d)",level);
            GameTextForPlayer(id,str,5000, 3);
            PlayerInfo[id][Level] = level;
            dini_IntSet(file,"Level",level);
        } else return SendERROR(playerid, 3);
    } else return SendERROR(playerid, 1);
    return 1;
}
Thanks in advance.
Wow if al gore saw your code, he give you a lecture about recycling your variables / reducing your string sizes.

The problem is probably this hehe:

Код:
if(!IsPlayerConnected(id))
Thats checking if they're NOT connected.
Reply
#7

Uhm guys, This is a thread to get help from the first person who posted there problem. Please do not flame. Mature up.
Reply
#8

Quote:
Originally Posted by Kyosaur
Посмотреть сообщение
Wow if al gore saw your code, he give you a lecture about recycling your variables / reducing your string sizes.

The problem is probably this hehe:

Код:
if(!IsPlayerConnected(id))
Thats checking if they're NOT connected.
Thanks, I never though that ! in front of that was a big deal.
Reply
#9

Quote:
Originally Posted by willsuckformoney
Посмотреть сообщение
Thanks, I never though that ! in front of that was a big deal.
So is it working now? Or is there another problem (i dont see one, but never know)?
Reply
#10

Quote:
Originally Posted by willsuckformoney
Посмотреть сообщение
Read my signature, the black text.
Quote:
Originally Posted by Calgon
Посмотреть сообщение
Read your name, and add an 'it' to the name. You're clearly extremely stupid. Congratulations on demonstrating your horrid scripting skills to the forum, btw.
LMFAO LOL
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)