MySQL Loading from Database error. - 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: MySQL Loading from Database error. (
/showthread.php?tid=502190)
MySQL Loading from Database error. -
KtotheYle - 22.03.2014
Hello, so I have been given a script to rid of all bugs and I have come accross one, when ever I need to read a vehicle from a Database and spawn the car once a player has spawned, it does not do this. I know the error is not with the spawning because I made a command to run the function. I have given this 2 days to think and look at and not I have to come and ask all you nice people for help.
Here is the code:
Код:
stock LoadPlayerVehicles(playerid)
{
format(query, sizeof(query), "SELECT * FROM `ownedvehicles` WHERE `owner` = '%s'", GetName(playerid));
mysql_function_query(dbHandle, query, true, "SpawnPlayerVehicles", "i", playerid);
return 1;
}
stock SpawnPlayerVehicles(playerid)
{
//new createcar = AddStaticVehicleEx(VehicleInfo[vehicleid][carModel], VehicleInfo[vehicleid][carParkX], VehicleInfo[vehicleid][carParkY], VehicleInfo[vehicleid][carParkZ] VehicleInfo[vehicleid][carParkA], 0, 0, -1);
new rows, fields, total = 0;
cache_get_data(rows, fields);
if(rows)
{
while(total < rows)
{
new modelid, Float:parkx, Float:parky, Float:parkz, Float:parka, color1, color2;
modelid = cache_get_row_int(total, 2);
parkx = cache_get_row_int(total, 5);
parky = cache_get_row_int(total, 6);
parkz = cache_get_row_int(total, 7);
parka = cache_get_row_int(total, 8);
color1 = cache_get_row_int(total, 3);
color2 = cache_get_row_int(total, 4);
CreateVehicle(modelid, parkx, parky, parkz, parka, color1, color2, -1);
}
}
return 1;
}
That is all the code where the errors should be happening, here is a screen shot of the DB where is is being loaded:
I hope someone can help!
Re: MySQL Loading from Database error. -
KtotheYle - 22.03.2014
Bump
Re: MySQL Loading from Database error. -
Sascha - 22.03.2014
use "cache_get_row_float" instead of "cahe_get_row_int" for the floats.
any error message in the rcon or the mysql log? if so, please post them