How to get data from MySQL?
#1

Hi

I finally got the MySQL server working and I've entered all buildings' coords into the database.
Now I need some help making a function that can load them from the database.

I need to fetch row 0 to 39 from the database and then assign the values to their respective variables ( BuildingInfo[idx][var] ).
I tried to look on the example filterscript, but I don't fully understand that ..

Hope someone can help.
pawn Код:
#define MAX_BUILDINGS 39

enum bInfo
{
    Float:x,
    Float:y,
    Float:z,
    Float:a,
    Float:int_x,
    Float:int_y,
    Float:int_z,
    Float:int_a,
    int_id,
    btext[128]
};

new BuildingInfo[MAX_BUILDINGS][bInfo];

public LoadBuildings()
{
    MySQLCheckConnection();

    new idx;
    while(idx < sizeof(BuildingInfo))
    {
      printf("Idx: %d", idx);
     
      // What goes here? Something like this?
       format(line, sizeof(line), "%d", idx);
       samp_mysql_fetch_row(line);
       samp_mysql_strtok(result, "|", line);
     
      idx++; pickupamount++;
    }
    return 1;
}
Reply
#2

I prefer g-Stylez's plugin, and also using split than samp_mysql_strtok.
You can try mysql_fetch_format in G-Stylez's plugin.
Reply
#3

What are you asking for? The command or the query?

SELECT * FROM `buildings` WHERE `id` > 0 AND `id` < 39; ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)