MySQL Help - Urgent help
#1

Can't work out the issue here.. Hoping someone here can.


pawn Код:
case DIALOG_LOGIN:
            {
                new query[144];

                mysql_format(sqlHandle, query, sizeof(query), "SELECT `Password` FROM `samp_users` WHERE `Username` = '%e'", Name[playerid]);
                mysql_tquery(sqlHandle, query, "", "");

                new rows, fields;
       
                cache_get_data(rows, fields);

                cache_get_field_content(0, "Password", Account[playerid][Password]);       

                if(!strcmp(hash, Account[playerid][Password]))
                {
                    new query2[1024];
                    SCM(playerid, COLOR_GREEN, "You have successfully logged into "GAMEMODE_SHORTNAME". You will be spawned in a minute.");
                    SCM(playerid, COLOR_GREEN, "Remember, if you need help use "EMBED_WHITE"/assistance");
                    SCM(playerid, COLOR_GREEN, "And if you find a player is breaking the rules use "EMBED_WHITE"/report");


                    strcat(query2, "SELECT `age`, `AdminLevel`, `money`, `skin`, `gender`, `pDisX`, `pDisY`, `pDisZ`, pDisA`, ");
                    strcat(query2, "`health`, `armour` FROM `samp_users` WHERE `Username` = '%e'");
                    mysql_format(sqlHandle, query2, sizeof(query), query, Name[playerid]);
                    mysql_function_query(sqlHandle, query2, true, "OnAccountLoad", "i", playerid);
                   
                }


    Function:OnAccountLoad(playerid)
    {
        new rows,
            fields;
        // Collect rows
        cache_get_data(rows, fields);

        // Load Strings ----------------------------------------------------
        cache_get_field_content(0, "Password", Account[playerid][Password]);
        // -----------------------------------------------------------------

        // Load Integers ------------------------------------------------------------
        Account[playerid][AdminLevel] = cache_get_field_content_int(0, "AdminLevel");
        Account[playerid][Money] = cache_get_field_content_int(0, "money");
        Account[playerid][Faction] = cache_get_field_content_int(0, "faction");
        Account[playerid][pSkin] = cache_get_field_content_int(0, "skin");
        Account[playerid][pGender] = cache_get_field_content_int(0, "gender");
        // --------------------------------------------------------------------------

        // Load Floats --------------------------------------------------------------
        Account[playerid][pX] = cache_get_field_content_float(0, "pDisX");
        Account[playerid][pY] = cache_get_field_content_float(0, "pDisY");
        Account[playerid][pZ] = cache_get_field_content_float(0, "pDisZ");
        Account[playerid][pA] = cache_get_field_content_float(0, "pDisA");

        // --------------------------------------------------------------------------
       
        // Set Money ----------------------------------------
        ResetPlayerMoney(playerid);
        GivePlayerMoney(playerid, Account[playerid][Money]);
        // --------------------------------------------------

        // Set Clothes -----------------------------------
        SetPlayerSkin(playerid, Account[playerid][pSkin]);
        // -----------------------------------------------

        // Spawn Player ----------------------------------
        SetSpawnInfo(playerid, 0, Account[playerid][pSkin], Account[playerid][pX], Account[playerid][pY], Account[playerid][pZ], Account[playerid][pA], 0, 0, 0, 0, 0, 0);
        SpawnPlayer(playerid);
        // -----------------------------------------------
       
        // Log
        printf("[LoadCheck] Admin Level: %d || Money: %d || Faction: %d || Skin: %d || Gender: %d || Spawn X: %f || Spawn Y: %f || Spawn Z: %f || Spawn A: %f",
                Account[playerid][AdminLevel], Account[playerid][Money], Account[playerid][Faction], Account[playerid][pSkin], Account[playerid][pGender],
                Account[playerid][pX], Account[playerid][pY], Account[playerid][pZ], Account[playerid][pA]);
        // ---
        return 1;
    }
Reply
#2

Can you tell what's not working exactly? and why a function inside a function?
Reply
#3

It's not loading anything and I just took snippets of code. They are not within each other, they're at oppisite ends of the script lol
Reply
#4

You are not using the rows in loading data function, Try not loading them. remove:
pawn Код:
new rows, fields;
cache_get_data(rows, fields);
Reply
#5

It's still not loading anything.
Reply
#6

then check your mysql_log.txt , there must be something wrong, would be better if you post it here
Reply
#7

Код:
[15:23:01] [WARNING] cache_get_data - no active cache
[15:23:01] [WARNING] cache_get_field_content - no active cache
[15:23:01] [WARNING] CMySQLResult::GetRowDataByName - field not found ("AdminLevel")
[15:23:01] [WARNING] CMySQLResult::GetRowDataByName - field not found ("money")
[15:23:01] [WARNING] CMySQLResult::GetRowDataByName - field not found ("faction")
[15:23:01] [WARNING] CMySQLResult::GetRowDataByName - field not found ("skin")
[15:23:01] [WARNING] CMySQLResult::GetRowDataByName - field not found ("gender")
[15:23:01] [WARNING] CMySQLResult::GetRowDataByName - field not found ("pDisX")
[15:23:01] [WARNING] CMySQLResult::GetRowDataByName - field not found ("pDisY")
[15:23:01] [WARNING] CMySQLResult::GetRowDataByName - field not found ("pDisZ")
[15:23:01] [WARNING] CMySQLResult::GetRowDataByName - field not found ("pDisA")
Just added the pDisX, pDisY, pDisZ and pDisA to the database.. Away to test it lol
Reply
#8

Fixed the issue. Turns out I didn't need to run this query on a new thread, so i just used an unthreaded query and it works now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)