Need help with mysql again
#1

I can't get my setlevel cmd working. I get the level in game, but it doesn't update in mysql so the level will be back to 0 upon relogging.

Here's the code;
pawn Код:
CMD:setlevel( playerid, params[] )
{
    //if (gPlayerInfo[playerid][pAlevel]<4)
        //return SendClientMessage(playerid,-1,"You need to be level 4 to use this.");
    new id,level;
    if (sscanf(params,"ud",id,level))
        return SendClientMessage(playerid,-1,"USAGE: /setlevel [ID] [Level].");
    if (!IsPlayerConnected(id) || id==INVALID_PLAYER_ID)
        return SendClientMessage(playerid,-1,"Invalid ID!");
    if (level>SERVER_MAX_LEVEL || level<SERVER_MIN_LEVEL)
        return SendClientMessage(playerid,-1,"Level must be between 0 and 4!");
    gPlayerInfo[playerid][pAlevel]=level;
    new query[300];
    format(query, sizeof(query), "UPDATE `users` SET ґalevelґ=ґ%dґ WHERE `id` = %i", level, gPlayerInfo[playerid][pID]);
    mysql_function_query(gHandle, query, false, "query", "", "");
    new string[70];
    String("Adminstrator %s has set your admin level to %d!",gPlayerInfo[playerid][pName],level);
    SendClientMessage(id,-1,string);
    String("You have set %s's level to %d! ",gPlayerInfo[id][pName],level);
    SendClientMessage(id,-1,string);
    return 1;
}
Quote:

[18:37:45] Adminstrator has set your admin level to 4!

[18:37:45] You have set 's level to 4!

[18:37:46] Current admins online:

[18:37:46] | Level: 4 | ID: 0


As you can see, it's not updating. As alevel type in mysql I'm using int(11).

Also, you may have noticed that %s isn't working properly. It doesn't show the name at all.

Need help with these two things thanks!
Reply
#2

EDIT: I spotted some syntax errors on format line, so I fixed it and the level saves properly now!

Last problem remains with the string. So the player name should appear with %s, but in game it's just blank.
Reply
#3

You can use the stock getname:
pawn Код:
stock GetName(playerid)
{
    new pName[68];
    GetPlayerName(playerid, (pName), sizeof(pName));
    return pName;
}
and then in your command:
pawn Код:
String("Adminstrator %s has set your admin level to %d!",GetName(playerid),level);
    SendClientMessage(id,-1,string);
    String("You have set %s's level to %d! ",GetName(playerid),level);
Reply
#4

Thanks a lot! Rep given!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)