SA-MP Forums Archive
MySQL R8 Loading problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL R8 Loading problem (/showthread.php?tid=421706)



MySQL R8 Loading problem - Knappen - 10.03.2013

pawn Код:
stock LoadAccount(playerid, Password[])
{
    new Query[150], PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    format(Query, sizeof(Query), "SELECT * FROM `players` WHERE `Name`='%s' AND `Password`='%s' LIMIT 0,1", PlayerName, Password);
    mysql_function_query(MySQLConnection, Query, true, "OnLoadAccount", "ds", playerid, PlayerName);
    return 1;
}
       

public OnLoadAccount(playerid, PlayerName)
{
    new Rows, Fields, String[100];
    cache_get_data(Rows, Fields, MySQLConnection);
    if(Rows)
    {    
        // Floats
        PlayerInfo[playerid][pPos_x] = cache_get_field_float(0, "Pos_x", MySQLConnection);
        PlayerInfo[playerid][pPos_y] = cache_get_field_float(0, "Pos_y", MySQLConnection);
        PlayerInfo[playerid][pPos_z] = cache_get_field_float(0, "Pos_z", MySQLConnection);
        PlayerInfo[playerid][pPos_a] = cache_get_field_float(0, "Pos_a", MySQLConnection);
        printf("%f - %f - %f", PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);      
 
    }
I'm pretty sure I got this right, but it doesn't load coordinates properly. It works sometimes, and somtimes I spawn under a bridge in the middle of nowhere. I've tried debugging, and it loads the right coordinates one time, and then I quit and login again, and then it loads other coords.

I've double checked the coords in the database, and they are different than the ones being loaded.

Thanks for any suggestions on what may be wrong.


Re: MySQL R8 Loading problem - Bakr - 10.03.2013

I don't see any problem besides PlayerName should be a string in the OnLoadAccount function.

Other than that, the only problem I could conclude is the values in the database aren't correct.


Re: MySQL R8 Loading problem - Knappen - 10.03.2013

PlayerName is a string

I've double checked the values as well! :/


Re: MySQL R8 Loading problem - Bakr - 10.03.2013

pawn Код:
public OnLoadAccount(playerid, PlayerName[])
Now it is a string, though I'm not sure why you pass it as it is never used.


Re: MySQL R8 Loading problem - Patrick - 10.03.2013

Quote:
Originally Posted by Bakr
Посмотреть сообщение
pawn Код:
public OnLoadAccount(playerid, PlayerName[])
Now it is a string, though I'm not sure why you pass it as it is never used.
that's what i'm thinking too Bakr. but i'm not just too sure if its right. but try it out. Knappen


Re: MySQL R8 Loading problem - Knappen - 11.03.2013

Oh, never noticed! Thank you, I will try it out.

EDIT: Isn't there usually a warning that pops up when that happens? Missing arguments or something

EDIT: It didn't change anything at all. Still loads the wrong values. Anyone has any ideas?


Re: MySQL R8 Loading problem - Knappen - 11.03.2013

I've tried editing a little bit, and it still doesn't work as it should. If anyone has any suggestions, please, do tell me, because I'll try anything at this moment.