[MySQL]Wont save
#1

Hey, well im trying to save the weapons on player disconnect in the smarter manner, but it wont work. Heres the script:
pawn Код:
new
                weaponid,
                MySQLQuery[300],
                ammo;

            for(new i; i < 13; i++) // looping through all weapon slots (0 - 12)
            {
                GetPlayerWeaponData(playerid, i, weaponid, ammo); // get weaponid and ammo

                if(!weaponid) continue; // don't insert if there's no weapon in this slot

                format(MySQLQuery, sizeof(MySQLQuery), "INSERT INTO ginklai VALUES (%d, %d, %d) ON DUPLICATE KEY UPDATE ammo = %d;", GetPVarInt(playerid, "AccID"), weaponid, ammo, ammo);
                mysql_query(MySQLQuery);
}
I put it onplayerdisconnect, and database is all set up. What is the problem?
Reply
#2

bump
Reply
#3

Bump
Reply
#4

Bump
Reply
#5

What is your mysql plugin version?

Would you kindly do this:
pawn Код:
mysql_query(MySQLQuery);
//changes into
new queryResult = mysql_query(MySQLQuery);
if (!queryResult) {
    printf("Query failed, errno %d", mysql_errno());
} else {
    print("Apparently query succeeded");
}
Reply
#6

Ok so i have MySQL R5. Right now this said query suceeded 3 times, because i had 3 weapons, but in the database only a baseball bat appeared :/ Could my database be setup incorrectly?
Reply
#7

bump
Reply
#8

Yup, it could be. Could you show your ginklai table structure? Also before the query, dump it:
pawn Код:
printf("Query looks like: %s", MySQLQuery);
Reply
#9

It seems like it works from the script:

Quote:

[15:33:32] Query looks like: INSERT INTO ginklai VALUES (1, 5, 500) ON DUPLICATE KEY UPDATE ammo = 500;
[15:33:32] Apparently query succeeded
[15:33:32] Query looks like: INSERT INTO ginklai VALUES (1, 22, 100) ON DUPLICATE KEY UPDATE ammo = 100;
[15:33:33] Apparently query succeeded

It seems it only save the last query, that it runs. Heres the database:






Any ideas?
Reply
#10

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)