Loading vehicles form mysql table - 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: Loading vehicles form mysql table (
/showthread.php?tid=516356)
Loading vehicles form mysql table -
Yako - 30.05.2014
Good evening people, I want to ask for help in loading vehicles from mysql script.
Here is my current script:
Код:
stock LoadVehiclesMySQL()
{
new Str[128], i = 1;
mysql_query("SELECT * FROM `vehicles`");
mysql_store_result();
if(mysql_num_rows() != 0)
{
while(mysql_fetch_row(Str))
{
sscanf(Str, "p<|>iffffiiis[32]s[32]ii", vInfo[i][Model], vInfo[i][vPosX], vInfo[i][vPosY], vInfo[i][vPosZ], vInfo[i][vPosA],
vInfo[i][vColor1], vInfo[i][vColor2], vInfo[i][Faction], vInfo[i][Plate], vInfo[i][Owner], vInfo[i][Paintjob], vInfo[i][Locked]);
CreateVehicle(vInfo[i][Model], vInfo[i][vPosX], vInfo[i][vPosY], vInfo[i][vPosZ], vInfo[i][vPosA], vInfo[i][vColor1], vInfo[i][vColor2], -1);
SetVehicleNumberPlate(i, vInfo[i][Plate]);
SetVehicleToRespawn(i);
i++;
}
}
mysql_free_result();
printf("--- %i vehicles loaded from the MySQL Database. ---", i);
return 1;
}
But it doesn't load any vehicles. maybe it's wrong with the
i in brackets?
Re: Loading vehicles form mysql table -
Koala818 - 30.05.2014
This might seem stupid, but do you populated the table `vehicles` in your database?
Re: Loading vehicles form mysql table -
Yako - 31.05.2014
I would like that people who understand scripting well would say if this script is good or should I change it