MYSQL Weapon Saving - 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 Weapon Saving (
/showthread.php?tid=308851)
MYSQL Weapon Saving -
DarkKillerWithPride<3 - 05.01.2012
Hey,
On my script I attempt to save the players weapon and ammo on disconnect however I save the 6 weapons that they should have. On the Login I use this code:
pawn Код:
mysql_fetch_field_row(string,"Weapon1"); PlayerInfo[playerid][pWeapon1] = strval(string);
mysql_fetch_field_row(string,"Ammo1"); PlayerInfo[playerid][pAmmo1] = strval(string);
And the when a player spawns:
pawn Код:
new Ammo, Weapon;
PlayerInfo[playerid][pWeapon1] = Weapon;
PlayerInfo[playerid][pAmmo1] = Ammo;
Safe_GivePlayerWeapon(playerid,Weapon,Ammo);
What I need to fix(I think) is how to save each slots so I'm not just saving the same weapon 6times also saving the ammo used. Any ideas?
Thanks,
-Dark.
Re: MYSQL Weapon Saving -
Johnson_boy - 05.01.2012
pawn Код:
new weapons[13][2];
for (new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
}
Then you'll actually need 24 columns in database to store both weapon id and ammo.
(weapon1, weapon1ammo, weapon2, weapon2ammo, ...)
Re: MYSQL Weapon Saving -
DarkKillerWithPride<3 - 05.01.2012
could you give an example of 2 weapons please? Thanks