View Single Post
Old 25/09/2018, 07:19 PM   #2
Join Date: May 2018
Posts: 1,227
Reputation: 205
Default Re: Weapons loading problem

Databases were not designed to store a text with a bunch of integer values just to split them on your own. Create another table for the weaponry (userid, weaponid, ammo).

As for the reason your code fails is because it takes the ASCII character, you have to use strval. Any ID of weapon which is 2-digit will not work as it expects 1-digit. sscanf is the best choice if you decide to use this method which I advise you not to!

pawn Code:
new split_weapons[13], split_ammo[13];

sscanf(string1, "a<d>[13]", split_weapons);
sscanf(string2, "a<d>[13]", split_ammo);

for (new i; i < 13; i++)
    C_Weapons[playerid][cWeaponID][i] = split_weapons[i];
    C_Weapons[playerid][cWeaponAmmo][i] = split_ammo[i];

It may be possible to pass `C_Weapons[playerid][cWeaponID]` directly in sscanf arguments as replacement of `split_weapons` but I am unable to test it myself.
Calisthenics is offline   Reply With Quote