data doesnt save
#1

i deleted alot of code from here and i misplaced a bracket but im having a hard time finding it :S
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_LOGIN)
    {
        if(!response) return Kick(playerid);
        if(IsPlayerConnected(playerid))
        {
            new DBResult:query, string[256];
            format(string, sizeof(string), "SELECT * FROM `USERS` WHERE `NAME`='%s' AND `PASSWORD`='%s'", DB_Escape(GetPlayerNameEx(playerid)), HashInput(inputtext));
            query = db_query(UserDatabase, string);
            if(db_num_rows(query) > 0) // Logged In
            {

                new szValue[64];

                db_get_field_assoc(query, "MONEY", szValue, sizeof(szValue));
                SetPVarInt(playerid, "pMoney", strval(szValue));
                db_get_field_assoc(query, "SKIN", szValue, sizeof(szValue));
                PlayerInfo[playerid][pSkin] = strval(szValue);
                db_get_field_assoc(query, "ADMINLEVEL", szValue, sizeof(szValue));
                PlayerInfo[playerid][pAdminLevel] = strval(szValue);
                db_get_field_assoc(query, "ADMINDUTY", szValue, sizeof(szValue));
                PlayerInfo[playerid][pAdminDuty] = strval(szValue);
                db_get_field_assoc(query, "POSITION_X", szValue, sizeof(szValue));
                PlayerInfo[playerid][pPositionX] = floatstr(szValue);
                db_get_field_assoc(query, "POSITION_Y", szValue, sizeof(szValue));
                PlayerInfo[playerid][pPositionY] = floatstr(szValue);
                db_get_field_assoc(query, "POSITION_Z", szValue, sizeof(szValue));
                PlayerInfo[playerid][pPositionZ] = floatstr(szValue);
                db_get_field_assoc(query, "POSITION_ANGLE", szValue, sizeof(szValue));
                PlayerInfo[playerid][pFacingAngle] = floatstr(szValue);
                db_get_field_assoc(query, "HEALTH", szValue, sizeof(szValue));
                PlayerInfo[playerid][pHealth] = strval(szValue);
                db_get_field_assoc(query, "ARMOUR", szValue, sizeof(szValue));
                PlayerInfo[playerid][pArmour] = strval(szValue);
                db_get_field_assoc(query, "WEAPON_SLOT1", szValue, sizeof(szValue));
                PlayerInfo[playerid][pWeapons][0] = strval(szValue);
                db_get_field_assoc(query, "WEAPON_SLOT2", szValue, sizeof(szValue));
                PlayerInfo[playerid][pWeapons][1] = strval(szValue);
                db_get_field_assoc(query, "WEAPON_SLOT3", szValue, sizeof(szValue));
                PlayerInfo[playerid][pWeapons][2] = strval(szValue);
                db_get_field_assoc(query, "WEAPON_SLOT4", szValue, sizeof(szValue));
                PlayerInfo[playerid][pWeapons][3] = strval(szValue);
                db_get_field_assoc(query, "WEAPON_SLOT5", szValue, sizeof(szValue));
                PlayerInfo[playerid][pWeapons][4] = strval(szValue);
                db_get_field_assoc(query, "WEAPON_SLOT6", szValue, sizeof(szValue));
                PlayerInfo[playerid][pWeapons][5] = strval(szValue);
                db_get_field_assoc(query, "WEAPON_SLOT7", szValue, sizeof(szValue));
                PlayerInfo[playerid][pWeapons][6] = strval(szValue);
                db_get_field_assoc(query, "WEAPON_SLOT8", szValue, sizeof(szValue));
                PlayerInfo[playerid][pWeapons][7] = strval(szValue);
                db_get_field_assoc(query, "INTERIOR", szValue, sizeof(szValue));
                PlayerInfo[playerid][pInterior] = strval(szValue);
                db_get_field_assoc(query, "VIRTUALWORLD", szValue, sizeof(szValue));
                PlayerInfo[playerid][pVirtualWorld] = strval(szValue);
                db_get_field_assoc(query, "BANNED", szValue, sizeof(szValue));
                PlayerInfo[playerid][pBanned] = strval(szValue);
                db_get_field_assoc(query, "JAILED", szValue, sizeof(szValue));
                PlayerInfo[playerid][pJail] = strval(szValue);
                TextDrawHideForPlayer(playerid, Welcome);

     if(PlayerInfo[playerid][pBanned] == 1)
                {
                 SendClientMessage(playerid, COLOR_WHITE, "You are currently banned from {0093FF}"servername"!");
                    SendClientMessage(playerid, COLOR_WHITE, "You may post a ban appeal at www.sa-mp.com");
                    format(string, sizeof(string), "AdmWarning: %s was kicked for attempting to login while being banned", GetPlayerNameEx(playerid));
                    SendAdminMessage(COLOR_LIGHTRED, string);
                    Ban(playerid);
                }
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{0093FF}"servername":{FFFFFF} Authentication", "{FFFFFF}Welcome to {0093FF}"servername"!{FFFFFF}\nThis account is currently registered, please enter your password to login:", "Login", "Quit");
            }
            db_free_result(query);
  }
 }
    else if(dialogid == DIALOG_REGISTER)
    {
        if(!response) return Kick(playerid);
        if(IsPlayerConnected(playerid))
        {
            new string[256];
            format(string, sizeof(string), "INSERT INTO `USERS` (`NAME`, `PASSWORD`) VALUES ('%s','%s')", DB_Escape(GetPlayerNameEx(playerid)), HashInput(inputtext));
            db_free_result(db_query(UserDatabase, string));

            format(string, sizeof(string), "UPDATE `USERS` SET `MONEY`='%i' WHERE `NAME`='%s'", PLAYER_START_CASH, DB_Escape(GetPlayerNameEx(playerid)));
            db_free_result(db_query(UserDatabase, string));

            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{0093FF}"servername":{FFFFFF} Authentication", "{FFFFFF}Welcome to {0093FF}"servername"!{FFFFFF}\nThis account is currently registered, please enter your password to login:", "Login", "Quit");
        }
 }
    return 1;
}
database:
pawn Код:
BEGIN TRANSACTION;
CREATE TABLE USERS (REPORTCOUNT NUMERIC, ID INTEGER PRIMARY KEY, NAME TEXT, PASSWORD TEXT, MONEY INTEGER, SKIN INTEGER, ADMINLEVEL INTEGER, ADMINDUTY INTEGER, POSITION_X FLOAT, POSITION_Y FLOAT, POSITION_Z FLOAT, POSITION_ANGLE FLOAT, HEALTH INTEGER, ARMOUR INTEGER, WEAPON_SLOT1 INTEGER, WEAPON_SLOT2 INTEGER, WEAPON_SLOT3 INTEGER, WEAPON_SLOT4 INTEGER, WEAPON_SLOT5 INTEGER, WEAPON_SLOT6 INTEGER, WEAPON_SLOT7 INTEGER, WEAPON_SLOT8 INTEGER, INTERIOR INTEGER, VIRTUALWORLD INTEGER, BANNED INTEGER, BANREASON TEXT, JAIL INTEGER);
CREATE TABLE sqlite_sequence(name,seq);
COMMIT;
saving part
pawn Код:
SavePlayerProfile(playerid)
{
    if(IsPlayerLogged(playerid))
    {
        new string[128];
        GetPlayerPos(playerid, PlayerInfo[playerid][pPositionX], PlayerInfo[playerid][pPositionY], PlayerInfo[playerid][pPositionZ]);
        GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pFacingAngle]);
        GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
        GetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
        PlayerInfo[playerid][pInterior] = GetPlayerInterior(playerid);
        PlayerInfo[playerid][pVirtualWorld] = GetPlayerVirtualWorld(playerid);
        format(string, sizeof(string), "UPDATE `USERS` SET `MONEY`='%i' WHERE `NAME`='%s'", GetPlayerCash(playerid), DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `SKIN`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pSkin], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `ADMINLEVEL`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pAdminLevel], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `ADMINDUTY`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pAdminDuty], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `POSITION_X`='%f' WHERE `NAME`='%s'", PlayerInfo[playerid][pPositionX], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `POSITION_Y`='%f' WHERE `NAME`='%s'", PlayerInfo[playerid][pPositionY], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `POSITION_Z`='%f' WHERE `NAME`='%s'", PlayerInfo[playerid][pPositionZ], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `POSITION_ANGLE`='%f' WHERE `NAME`='%s'", PlayerInfo[playerid][pFacingAngle], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `HEALTH`='%i' WHERE `NAME`='%s'", floatround(PlayerInfo[playerid][pHealth]), DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `ARMOUR`='%i' WHERE `NAME`='%s'", floatround(PlayerInfo[playerid][pArmour]), DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `WEAPON_SLOT1`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pWeapons][0], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `WEAPON_SLOT2`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pWeapons][1], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `WEAPON_SLOT3`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pWeapons][2], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `WEAPON_SLOT4`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pWeapons][3], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `WEAPON_SLOT5`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pWeapons][4], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `WEAPON_SLOT6`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pWeapons][5], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `WEAPON_SLOT7`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pWeapons][6], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `WEAPON_SLOT8`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pWeapons][7], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `INTERIOR`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pInterior], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `VIRTUALWORLD`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pVirtualWorld], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        format(string, sizeof(string), "UPDATE `USERS` SET `JAIL`='%i' WHERE `NAME`='%s'", PlayerInfo[playerid][pJail], DB_Escape(GetPlayerNameEx(playerid)));
        db_free_result(db_query(UserDatabase, string));
        return 1;
    }
    return 0;
}
enum
pawn Код:
enum pInfo
{
    pSkin,
    pAdminLevel,
    pAdminDuty,
    Float:pPositionX,
    Float:pPositionY,
    Float:pPositionZ,
    Float:pFacingAngle,
    Float:pHealth,
    Float:pArmour,
    pWeapons[8],
    pInterior,
    pVirtualWorld,
    pBanned,
    pJail
}
Reply
#2

BUMP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)