MYSQL Weapon Saving
#1

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.
Reply
#2

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, ...)
Reply
#3

could you give an example of 2 weapons please? Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)