2023-05-05, 08:16 AM
Hello, I'm making a weapon/save load system to MySQL and it seems working but I have a problem.
I need something to check if two weapons are in the same slot because now the save system inserts 2 rows in the table.
Example:
I buy Spas12, weapon gets inserted in the table, but if I buy sawn off, the weapon gets inserted in the table so I have 2 weapons of the same slot saved.
I need to avoid this.
This is the save code:
I need something to check if two weapons are in the same slot because now the save system inserts 2 rows in the table.
Example:
I buy Spas12, weapon gets inserted in the table, but if I buy sawn off, the weapon gets inserted in the table so I have 2 weapons of the same slot saved.
I need to avoid this.
This is the save code:
Code:
public GivePlayerWeaponEx(playerid, weaponid, ammo)
{
new wepQuery[300];
if(IsValidWeaponID(weaponid))
{
mysql_format(g_SQL, wepQuery, sizeof(wepQuery), "INSERT INTO `weapons` (`userid`, `weaponid`, `ammo`) VALUES (%d, %d, %d) ON DUPLICATE KEY UPDATE ammo = %d",
ReturnAccDbID(playerid), weaponid, ammo, GetPlayerAmmo(playerid) + ammo);
mysql_pquery(g_SQL, wepQuery);
}
return GivePlayerWeapon(playerid, weaponid, ammo);
}