SA-MP Forums Archive
Question regarding mysql and getting rows. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question regarding mysql and getting rows. (/showthread.php?tid=619524)



Question regarding mysql and getting rows. - Dokins - 18.10.2016

I have a MAX_WEAPONS which is set to 1000.

However, when a weapon is deleted it leaves an ID missing, so while there may be 10 weapons, it might be rows 990 to 1000 that are in the game, therefore leaving 990 slots free but it would return no weapon slots.


pawn Код:
forward LoadWeapons();
public LoadWeapons()//This is loading weapons, simple as.
{
    new QueryString[128];
    //mysql_query( "SELECT id, VehModel,VehOwner, VehColour1, VehColour2, VehPlate, VehSpawnX, VehSpawnY, VehSpawnZ, VehSpawnAngle, VehFuel, VehCash,VehWep1,VehWepA1,VehWep2,VehWepA2, VehArmour,VehFaction,VehFRank, VehOwned, VehFactioned, VehWeed, VehCoke, VehBizID, VehForSale,VehPrice FROM vehicles");
    //mysql_store_result();
    new weaponid;
    new rows, fields;
    cache_get_data(rows, fields);
    for(new y; y != rows; y++)
    {
            cache_get_row(y, wwid, QueryString);
            weaponid = strval(QueryString);

            cache_get_row(y, wWepModel, QueryString);
            WepModel[weaponid] = strval( QueryString);
How do I load it to make sure that MAX_WEAPONS is filled but the ID is stored in the variables without their being 1000.


Re: Question regarding mysql and getting rows. - SickAttack - 18.10.2016

I'm not quite sure what you're trying to do with that, but SQL IDs should be like that, and shouldn't be used for counting or anything in between.


Re: Question regarding mysql and getting rows. - Dokins - 18.10.2016

What I mean is that.

When I load weapons and I loop through them all.

The ID's that aren't occupied i.e WepModel[1] might be empty but how do I make it use that slot as opposed to looping and reaching ID 500 ?


Re: Question regarding mysql and getting rows. - SickAttack - 18.10.2016

Store them starting at index 0 when loading?

When you delete index 5, and implying 10 is the last index, put index 10's info in index 5's, then lower the count of total weapons (if you have a count). Or start a loop begging at 6, all the way to the last index, and set the values down one index.