Loading vehicles form mysql table
#1

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

This might seem stupid, but do you populated the table `vehicles` in your database?
Reply
#3

I would like that people who understand scripting well would say if this script is good or should I change it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)