MySQL database! Data gets into wrong columns.
#1

Hi,
I just converted my GM to MySQL but the problem is that my Score, Money and Headshots gets MESSED up.
Like score goes into Money's column and Headshots gets into Score's columns.

The players are getting annoyed.
Please tell me what are the possible reasons behind this and how can I fix it.
All comments will be highly appreciated.
Reply
#2

maybe you are getting and loading into wrong enum ? show code
Reply
#3

So you mean wrong order of score money and headshots in saving and loading Enums?
Reply
#4

Can you show us what you're exactly doing in code?
Reply
#5

Quote:
Originally Posted by iAnonymous
Посмотреть сообщение
So you mean wrong order of score money and headshots in saving and loading Enums?
Nope. Such as, When you load/ save/ update a player the player in the correct enums/ player data etc. Just double check these things.

If you'd like, because we can't be certain of your problem currently, Show some code perhaps?
Reply
#6

Код:
forward MysqlLoadPlayer(playerid);
public MysqlLoadPlayer(playerid)
{
	new rows, fields;

    cache_get_data(rows, fields);
    if(rows)
    {
        new temp[128];

    	cache_get_row(0, 0, temp);
        PlayerInfo[playerid][UID] = strval(temp);
		cache_get_row(0, 1, temp);
		format(PlayerInfo[playerid][RegisterDate], 30, "%s", temp);
        cache_get_row(0, 2, temp);
        PlayerInfo[playerid][Level] = strval(temp);
        cache_get_row(0, 3, temp);
        PlayerInfo[playerid][Helper] = strval(temp);
        cache_get_row(0, 4, temp);
        PlayerInfo[playerid][dRank] = strval(temp);
        cache_get_row(0, 5, temp);
		format(PlayerInfo[playerid][Nick], 21, "%s", temp);
        cache_get_row(0, 6, temp);
		format(PlayerInfo[playerid][Password], 128, "%s", temp);
        cache_get_row(0, 7, temp);
        PlayerInfo[playerid][Kills] = strval(temp);
        cache_get_row(0, 8, temp);
        PlayerInfo[playerid][Deaths] = strval(temp);
        cache_get_row(0, 9, temp);
        PlayerInfo[playerid][Score] = strval(temp);
        cache_get_row(0, 10, temp);
        PlayerInfo[playerid][Money] = strval(temp);
        cache_get_row(0, 11, temp);
        PlayerInfo[playerid][Headshots] = strval(temp);

        GivePlayerCash(playerid, PlayerInfo[playerid][Money]);
	    SetPlayerScore(playerid, PlayerInfo[playerid][Score]);

	    format(query, sizeof(query), "SELECT * FROM `Prestiges` WHERE `Nick` = '%s'", escpname(playerid));
	    mysql_function_query(connectionhandle, query, true, "MysqlLoadPrestige", "i", playerid);

	    PlayerInfo[playerid][LoggedIn] = true;
            OnPlayerRequestClass(playerid, 0);
           return 1;
           }
Код:
SavePlayer(playerid)
{
	new score, money, kills, deaths, helper, donor, hs, string2[128];
    score = GetPlayerScore(playerid);
    money = GetPlayerCash(playerid);
    helper = PlayerInfo[playerid][Helper];
    donor = PlayerInfo[playerid][dRank];
    kills = PlayerInfo[playerid][Kills];
    deaths = PlayerInfo[playerid][Deaths];
    hs = PlayerInfo[playerid][Headshots];
    new Year, Month, Day;
    getdate(Year, Month, Day);
    format(string2, sizeof(string2), "%02d/%02d/%d",  Day, Month, Year);

    format(query, sizeof(query), "UPDATE `Accounts` SET `Helper`='%d', `Donor`='%d', `Score`='%d', `Money`='%d', `Kills`='%d', `Deaths`='%d', `Headshots`='%d', `laston`='%s' WHERE `Nick`='%s'",helper, donor, score, money, kills, deaths, hs, string2, GetName(playerid));
    mysql_function_query(connectionhandle, query, false, "", "");
    if(templevel[playerid] < 1)
    {
    	format(query, sizeof(query), "UPDATE `Accounts` SET `Admin`='%i' WHERE `Nick`='%s'", PlayerInfo[playerid][Level], GetName(playerid));
    	mysql_function_query(connectionhandle, query, false, "", "");
    }
    format(query, sizeof(query), "UPDATE `playeronlinetime` SET `ohours`='%d', `ominutes`='%d', `oseconds`='%d' WHERE `name`='%s'",PlayerInfo[playerid][hours],PlayerInfo[playerid][mins],PlayerInfo[playerid][secs],escpname(playerid));
    mysql_function_query(connectionhandle, query, false, "", "");
    format(query, sizeof(query), "UPDATE `Tag` SET `Allowed`='%d' WHERE `Nick`='%s'", PlayerInfo[playerid][Tag], GetName(playerid));
	mysql_function_query(connectionhandle, query, false, "", "");
}
Anything wrong here?
Reply
#7

Check PHP my admin table whether it is really in that sequence.
Reply
#8

Alright. Isn't the table sequence doesn't matters for MySQL?
Reply
#9

try to get row by row name
example
pawn Код:
forward MysqlLoadPlayer(playerid);
public MysqlLoadPlayer(playerid)
{
    new rows, fields;

    cache_get_data(rows, fields);
    if(rows)
    {
        new temp[128];

       

        PlayerInfo[playerid][UID] = cache_get_field_content_int(0, "ID"); // remeber use your column name this is an example
        cache_get_field_content(0,"RegisterDate", PlayerInfo[playerid][RegisterDate]);
        format(PlayerInfo[playerid][RegisterDate], 30, "%s", temp);
        PlayerInfo[playerid][Level] = cache_get_field_content_int(0, "Level");
        PlayerInfo[playerid][Helper] = cache_get_field_content_int(0, "Helper");
        PlayerInfo[playerid][dRank] = cache_get_field_content_int(0, "dRank");
        cache_get_field_content(0,"Password", PlayerInfo[playerid][Password]);
        cache_get_field_content(0,"Nick", PlayerInfo[playerid][Nick]);
        format(PlayerInfo[playerid][Nick], 21, "%s", temp);
        format(PlayerInfo[playerid][Password], 128, "%s", temp);
        PlayerInfo[playerid][Kills] = cache_get_field_content_int(0, "Kills");
        PlayerInfo[playerid][Deaths] = cache_get_field_content_int(0, "Deaths");
        PlayerInfo[playerid][Score] = cache_get_field_content_int(0, "Score");
        PlayerInfo[playerid][Money] = cache_get_field_content_int(0, "Money");
        PlayerInfo[playerid][Headshots] = cache_get_field_content_int(0, "Headshots");

        GivePlayerCash(playerid, PlayerInfo[playerid][Money]);
        SetPlayerScore(playerid, PlayerInfo[playerid][Score]);

        format(query, sizeof(query), "SELECT * FROM `Prestiges` WHERE `Nick` = '%s'", escpname(playerid));
        mysql_function_query(connectionhandle, query, true, "MysqlLoadPrestige", "i", playerid);

        PlayerInfo[playerid][LoggedIn] = true;
            OnPlayerRequestClass(playerid, 0);
           return 1;
           }
Reply
#10

Anyone else?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)