SA-MP Forums Archive
[MySQL]Wont save - 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]Wont save (/showthread.php?tid=530604)



[MySQL]Wont save - Type-R - 08.08.2014

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?


Re: [MySQL]Wont save - Type-R - 08.08.2014

bump


Re: [MySQL]Wont save - Type-R - 09.08.2014

Bump


Re: [MySQL]Wont save - Type-R - 10.08.2014

Bump


Re: [MySQL]Wont save - Misiur - 10.08.2014

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");
}



Re: [MySQL]Wont save - Type-R - 12.08.2014

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?


Re: [MySQL]Wont save - Type-R - 13.08.2014

bump


Re: [MySQL]Wont save - Misiur - 13.08.2014

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



Re: [MySQL]Wont save - Type-R - 13.08.2014

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?


Re: [MySQL]Wont save - Type-R - 14.08.2014

bump