How to get data from MySQL? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to get data from MySQL? (
/showthread.php?tid=86382)
How to get data from MySQL? -
Vince - 13.07.2009
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;
}
Re: How to get data from MySQL? -
MenaceX^ - 13.07.2009
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.
Re: How to get data from MySQL? -
hanzen - 13.07.2009
What are you asking for? The command or the query?
SELECT * FROM `buildings` WHERE `id` > 0 AND `id` < 39; ?