MySQL Won't save..
#1

I used Clean, Blank, MySQL Gamemode and wamp but the problem is.. after i added some commands such as Setlevel, setadmin, setvip.. it won't save the player data..

basically.. if i set someone's level to 9 and when he rejoin i have to reset his level back to 9. I tried to remove all the commands.. and even remake the gamemode. But it's still won't save.
Reply
#2

Show as your mysql log (debug) and the commands that you try to use
Reply
#3

there's nothing in the mysql log..

command

pawn Код:
CMD:setlevel(playerid, params[])
{
    new string[256], targetid, level;
    if(PlayerInfo[playerid][pLevel] < 5 && !IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, "** You are not authorize to use this command.");
    if(PlayerInfo[playerid][pLevel] < 9 && PlayerInfo[playerid][pLevel] > 5 ) return SCM(playerid, COLOR_YELLOW, "** Your admin level is not high enough to use this command.");
    if(level > MPL) return SCM(playerid, COLOR_RED, "** The maximum level you can set is 9 (Head Administrator).");
    if(targetid == INVALID_PLAYER_ID)
    {
        SCM(playerid, COLOR_YELLOW, "** You have entered invalid player id");
    }
    if(sscanf(params, "ui", targetid, level))
    {
        SCM(playerid, COLOR_YELLOW, "*** SETLEVEL: /setlevel <PlayerID/PlayerName> <level>");
        SCM(playerid, COLOR_YELLOW, "** Valid Level:");
        SCM(playerid, COLOR_YELLOW, "* 1 = Registered Player.");
        SCM(playerid, COLOR_YELLOW, "* 2 = VIP.");
        SCM(playerid, COLOR_YELLOW, "* 3 = Gold VIP.");
        SCM(playerid, COLOR_YELLOW, "* 4 = Executive VIP.");
        SCM(playerid, COLOR_YELLOW, "* 5 = Moderator.");
        SCM(playerid, COLOR_YELLOW, "* 6 = Junior Administrator.");
        SCM(playerid, COLOR_YELLOW, "* 7 = General Administrator.");
        SCM(playerid, COLOR_YELLOW, "* 8 = Senior Administrator.");
        SCM(playerid, COLOR_YELLOW, "* 9 = Head Administrator.");
    }
    if(level >=2 && level <= 4)
    {
        switch(level)
        {
            case 2:
            {
                format(string,sizeof(string),"** You have been given a VIP status by %s.",GetName(playerid));
                SCM(targetid, COLOR_GREEN, string);
                SCM(targetid, COLOR_GREEN, "* To see when your VIP status will be expired use /vipstatus.");
                format(string,sizeof(string),"** You have given %s a VIP status.",GetName(targetid));
                SCM(playerid, COLOR_YELLOW, string);
            }
            case 3:
            {
                format(string,sizeof(string),"** You have been given a Gold VIP status by %s.",GetName(playerid));
                SCM(targetid, COLOR_GREEN, string);
                SCM(targetid, COLOR_GREEN, "* To see when your VIP status will be expired use /vipstatus.");
                format(string,sizeof(string),"** You have given %s a Gold VIP status.",GetName(targetid));
                SCM(playerid, COLOR_YELLOW, string);
            }
            case 4:
            {
                format(string,sizeof(string),"** You have been given a Executive VIP status by %s.",GetName(playerid));
                SCM(targetid, COLOR_GREEN, string);
                SCM(targetid, COLOR_GREEN, "* To see when your VIP status will be expired use /vipstatus.");
                format(string,sizeof(string),"** You have given %s a Executive VIP status.",GetName(targetid));
                SCM(playerid, COLOR_YELLOW, string);
            }
        }
        PlayerInfo[targetid][pVIP] = level;
        PlayerInfo[targetid][pLevel] = level;
        PlayerInfo[targetid][pVIPDate] = gettime()+2592000;
    }
    if(level >=5 && level <=9)
    {
        switch(level)
        {
            case 5:
            {
                if(PlayerInfo[targetid][pLevel] < level)
                {
                    format(string,sizeof(string),"** You have been promoted to Moderator by %s.",GetName(playerid));
                    SCM(targetid, COLOR_GREEN, string);
                    format(string,sizeof(string),"** You have promoted %s to Moderator.",GetName(targetid));
                    SCM(playerid, COLOR_YELLOW, string);
                    GameTextForPlayer(playerid,"~g~CONGRATULATIONS~n~~w~YOU HAVE BEEN PROMOTED",5000,3);
                }
                if(PlayerInfo[targetid][pLevel] > level)
                {
                    format(string,sizeof(string),"** You have been demoted from to Moderator by %s.", GetName(playerid));
                    SCM(targetid, COLOR_RED, string);
                    format(string,sizeof(string),"** You have demoted %s from Moderator.", GetName(targetid));
                    SCM(playerid, COLOR_YELLOW, string);
                }
            }
            case 6:
            {
                if(PlayerInfo[targetid][pLevel] < level)
                {
                    format(string,sizeof(string),"** You have been promoted to Junior Administrator by %s.", GetName(playerid));
                    SCM(targetid, COLOR_GREEN, string);
                    format(string,sizeof(string),"** You have promoted %s to Junior Administrator .",GetName(targetid));
                    SCM(playerid, COLOR_YELLOW, string);
                    GameTextForPlayer(playerid,"~g~CONGRATULATIONS~n~~w~YOU HAVE BEEN PROMOTED",5000,3);
                }
                if(PlayerInfo[targetid][pLevel] > level)
                {
                    format(string,sizeof(string),"** You have been demoted from Junior Administrator by %s.", GetName(playerid));
                    SCM(targetid, COLOR_RED, string);
                    format(string,sizeof(string),"** You have demoted %s from Junior Administrator.",GetName(targetid));
                    SCM(playerid, COLOR_YELLOW, string);
                }
            }
            case 7:
            {
                if(PlayerInfo[targetid][pLevel] < level)
                {
                    format(string,sizeof(string),"** You have been promoted to General Administrator by %s.", GetName(playerid));
                    SCM(targetid, COLOR_GREEN, string);
                    format(string,sizeof(string),"** You have promoted %s to General Administrator status.",GetName(targetid));
                    SCM(playerid, COLOR_YELLOW, string);
                    GameTextForPlayer(playerid,"~g~CONGRATULATIONS~n~~w~YOU HAVE BEEN PROMOTED",5000,3);
                }
                if(PlayerInfo[targetid][pLevel] > level)
                {
                    format(string,sizeof(string),"** You have been demoted from General Administrator status by %s.", GetName(playerid));
                    SCM(targetid, COLOR_RED, string);
                    format(string,sizeof(string),"** You have demoted %s from General Administrator status.",GetName(targetid));
                    SCM(playerid, COLOR_YELLOW, string);
                }
            }
            case 8:
            {
                if(PlayerInfo[targetid][pLevel] < level)
                {
                    format(string,sizeof(string),"** You have been promoted to Senior Administrator by %s.", GetName(playerid));
                    SCM(targetid, COLOR_GREEN, string);
                    format(string,sizeof(string),"** You have promoted %s to Senior Administrator status.",GetName(targetid));
                    SCM(playerid, COLOR_YELLOW, string);
                    GameTextForPlayer(playerid,"~g~CONGRATULATIONS~n~~w~YOU HAVE BEEN PROMOTED",5000,3);
                }
                if(PlayerInfo[targetid][pLevel] > level)
                {
                    format(string,sizeof(string),"** You have been demoted from Senior Administrator status by %s.", GetName(playerid));
                    SCM(targetid, COLOR_RED, string);
                    format(string,sizeof(string),"** You have demoted %s from Senior Administrator status.",GetName(targetid));
                    SCM(playerid, COLOR_YELLOW, string);
                }
            }
            case 9:
            {
                if(PlayerInfo[targetid][pLevel] < level)
                    {
                    format(string,sizeof(string),"** You have been promoted to Head Administrator by %s.", GetName(playerid));
                    SCM(targetid, COLOR_GREEN, string);
                    format(string,sizeof(string),"** You have promoted %s to Head Administrator status.",GetName(targetid));
                    SCM(playerid, COLOR_YELLOW, string);
                    GameTextForPlayer(playerid,"~g~CONGRATULATIONS~n~~w~YOU HAVE BEEN PROMOTED",5000,3);
                }
                if(PlayerInfo[targetid][pLevel] > level)
                {
                    format(string,sizeof(string),"** You have been demoted from Head Administrator status by %s.", GetName(playerid));
                    SCM(targetid, COLOR_RED, string);
                    format(string,sizeof(string),"** You have demoted %s from Head Administrator status.",GetName(targetid));
                    SCM(playerid, COLOR_YELLOW, string);
                }
            }
        }
        PlayerInfo[targetid][pLevel] = level;
    }
    format(string,sizeof(string),"%s used SETLEVEL command on %s to set %s's level to level %d",GetName(playerid),GetName(targetid),GetName(targetid),level);
    SendMessageToAdmins(COLOR_SETLEVEL_LOG,string);
    Log("logs/adminlogs.log",string);
    return 1;
}
Reply
#4

Quote:
Originally Posted by belhot1992
Посмотреть сообщение
You need to write an "update `accounts` SET playerlevel = '9' where id = %d;" <- (That won't work) in order to do that. You also need a database. Then you need to load the information from the database once the players log in.

Example to save:
Код:
new DB = mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_DATABASE,MYSQL_PASSWORD);
new query[256];
format(query, sizeof(query), "UPDATE `accounts` SET `playerlevel` = %d  WHERE `id` = %d",
		GetPVarInt(playerid, "playerlevel"),GetPVarInt(playerid, "accountid"));
		mysql_function_query(DB, query, true, "EmptyCallback", "");
already done that OnPlayerDisconnect
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)