Having issues loading ammo. MYSQL.
#1

First off, I use my own system of saving and loading my weapons, I save them like you would save vehicles etc.

pawn Код:
for(new w = 0; w < 13; w++)
        {
            format(fieldname, sizeof(fieldname), "Weapon%d", w);
            MySQL_SetInteger(PlayerSQLID[playerid], fieldname, PlayerWeapons[playerid][w], "accounts");
            ammo = WepAmmo[PlayerWeapons[playerid][w]];
            MySQL_SetInteger(PlayerWeapons[playerid][w], "WepAmmo", ammo, "weapons");
        }
PlayerWeapons[playerid][w] is the ID of the weapon in the database, not the actual weaponid like Desert Eagle or anything, but the row id.

WepAmmo Is the same thing, it should get the ammo from the ID in the PlayerWeapons, but it won't and I can't figure it out.

Here is where I load the weapons.

pawn Код:
mysql_get_field( "WepAmmo", QueryString);
            WepAmmo[x] = strval( QueryString);
Here is where the player SHOULD get them, but it won't set the ammo correctly.

pawn Код:
for(new w = 0; w < 13; w++)
                {

                        new ammo = WepAmmo[PlayerWeapons[playerid][w]];
                        printf("Ammo: %d", ammo);
                        new weapon = WepModel[PlayerWeapons[playerid][w]];
                        printf("WepModel :%d", WepModel[PlayerWeapons[playerid][w]]);
                        GivePlayerWeapon(playerid,weapon,ammo);

                }
it gets the ID correctly, but not the weapon ammo from WepAmmo.
Reply
#2

Quote:
Originally Posted by Dokins
Посмотреть сообщение
I save them like you would save vehicles etc.
Which in all honestly is a terrible way to do it. If you need to add a number to a field name then you're doing it wrong. In no occasion should you ever need to format a field name. I might write a full fledged tutorial later today on how to do it properly, which will be an extension on my previous tutorial on the subject.

For instance, my weapons table (yes, a separate table) currently looks like this:

Fairly simple to understand how it works, I think. Get a weapon = insert a row, lose a weapon = delete a row.
Reply
#3

I toy'd with how I was going to do it, but I want to save the WeaponSerial Number etc. I want to save all of this:
pawn Код:
new WepModel[MAX_WEAPONS];
new WepAmmo[MAX_WEAPONS];
new WepOwner[MAX_WEAPONS];
new WepObject[MAX_WEAPONS];
new WepSerial[MAX_WEAPONS];
new LastShot[MAX_WEAPONS];
new Float: WepX[MAX_WEAPONS];
new Float: WepY[MAX_WEAPONS];
new Float: WepZ[MAX_WEAPONS];
new WepEvi[MAX_WEAPONS];
new WepDate[MAX_WEAPONS];
new WepVW[MAX_WEAPONS];
new WepInt[MAX_WEAPONS];
Also, I only need to loop for the fieldname of the weapon for the playerid. As in, what Weapon Slot.

I need it to work like this, could you help me?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)