Entries in the tables
#1

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
Reply
#2

PS: I use MySQL R5.

Can you help me?

+reps
Reply
#3

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.
Reply
#4

And how I took to the function?
Reply
#5

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;
Reply
#6

UP please.
Reply
#7

UP please
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)