Weapons won't save- MYSQL(Code inside) - 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: Weapons won't save- MYSQL(Code inside) (
/showthread.php?tid=293754)
Weapons won't save- MYSQL(Code inside) -
Dokins - 29.10.2011
pawn Код:
SaveWeapons()
{
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(LoggedIn[p] == 1 && IsPlayerConnected(p))
{
for(new w = 0; w < 13; w++)
{
GetPlayerWeaponData(p, w, PlayerWeapons[p][w], PlayerWeaponAmmo[p][w]);
new fieldname[50], Float:armour;
format(fieldname, sizeof(fieldname), "Weapon%d", w);
MySQL_SetInteger(PlayerSQLID[p], fieldname, PlayerWeapons[p][w], "Accounts");
format(fieldname, sizeof(fieldname), "Weapon%dAmmo", w);
MySQL_SetInteger(PlayerSQLID[p], fieldname, PlayerWeaponAmmo[p][w], "Accounts");
GetPlayerArmour(p, armour);
MySQL_SetFloat(PlayerSQLID[p], "Armour", armour, "Accounts");
}
}
}
return 1;
}
As the title says, weapons won't save at all which is very strange, also the above code is placed in a timer which saves every 5 seconds. It simply will not save although, I gave myself a weapon via mysql and then connected and it loaded.
Re: Weapons won't save- MYSQL(Code inside) -
Pinguinn - 29.10.2011
Why you don't update through mysql_query?
pawn Код:
new name[MAX_PLAYER_NAME], GetPlayerName(p, name, sizeof(name));
mysql_query("UPDATE 'Accounts' SET 'Weapons' = '%d' AND 'Ammo' = '%d' AND Armour = '%f' WHERE name = '%s'", PlayerWeapons[p][w], PlayerWeaponAmmo[p][w], armour, name);
Re: Weapons won't save- MYSQL(Code inside) -
Vince - 29.10.2011
Ew .. 2x13x500 = 13000 queries (in the worst case) every 5 seconds.
Re: Weapons won't save- MYSQL(Code inside) -
Dokins - 29.10.2011
Resolved. Thanks