SA-MP Forums Archive
Entries in the tables - 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: Entries in the tables (/showthread.php?tid=527593)



Entries in the tables - Baltimore - 23.07.2014

Hello there

Here I have a system object that you can ask / take down.

I use a table in this form:
variable [id] [nombre_maximum]

For security and other uses I record everything in MySQL, and the table entry I use a function.

The only trouble with this function is qu'admettons I 500 maximum, and I have a object id 1 and id 500 it does not use the unused inputs.

How do I change my function to use unused inputs?

Here's the function:

pawn Код:
stock IDExistantObjet()
{
    new requete[1024], result[1024];
   
    format(requete, sizeof(requete), "SELECT COUNT(*) FROM srp_players_objets");
    mysql_query(requete);
   
    mysql_store_result();
   
    mysql_fetch_row(result);
   
    new objvar = strval(result) + 1;
   
    mysql_free_result();
   
    return objvar;
}
thx


Re: Entries in the tables - Baltimore - 23.07.2014

PS: I use MySQL R5.

Can you help me?

+reps


Re: Entries in the tables - Virtual1ty - 23.07.2014

Show us your enums and variables in which you store object IDs - your loading and saving code.
Shortly put, using COUNT is wrong, and hence you run into these problems. The correct way would be to make a "GetFreeArraySlot" function to check which slots (array indices) are available - ie. not occupied - ie. > 0.


Re: Entries in the tables - Baltimore - 23.07.2014

And how I took to the function?


Re: Entries in the tables - Baltimore - 24.07.2014

I have coded this code but it's not work:

pawn Код:
new check_objet = 1;
   
    while(check_objet < MAX_OBJETS)
    {
        if(ObjetsInfo[check_objet][PosX] == 0 || ObjetsInfo[check_objet][PosY] == 0 || ObjetsInfo[check_objet][PosZ] == 0) // OBJET PAS UTILISЙ
        {
            return check_objet;
        }
        else
        {
            check_objet++;
            continue;
        }
        if(check_objet >= MAX_OBJETS)
        break;
    }
    return 0;



Re: Entries in the tables - Baltimore - 24.07.2014

UP please.


Re: Entries in the tables - Baltimore - 25.07.2014

UP please