Save weapons with sscanf
#1

Hello.

I think finally have found a way to back up my arms in BDD, and I want your opinion.

I have a table 'weapon_id' and 'weapon_muns'.

I would have 13 digits in each table for each slot separated by a space.

With sscanf, I get 13 int I store in a table.

Is it an option?

thank you
Reply
#2

I assume that you mean this

Saving the string:
pawn Код:
//Top
new WepData[2][50];

//Saving
new weapons[13][2];
for (new i = 0; i < 13; i++)
{
    GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
    if(!WepData[0][0])
    {
        format(WepData[0], 50, "%d", weapons[i][0]);
        format(WepData[1], 50, "%d", weapons[i][1]);
    }
    else if(WepData[0][0] != 0)
    {
        format(WepData[0], 50, "%d %d", WepData[0], weapons[i][0]);
        format(WepData[1], 50, "%d %d", WepData[1], weapons[i][1]);
    }
}

//WepData[0] prints the weapon IDS
//WepData[1] prints the ammo.
Then you could just split the line using sccanf. I don't see why you would want to, because it uses more cells and it's way easier to just store single digits.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)