Loads but doesn't spawn vehicles - 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: Loads but doesn't spawn vehicles (
/showthread.php?tid=205290)
Loads but doesn't spawn vehicles -
Scenario - 01.01.2011
Evening... I have this code:
pawn Код:
stock LoadSQLVehicles()
{
mysql_query("SELECT * FROM `Vehicles`");
mysql_store_result();
new Query[128], Owner[23], Model, Float:vPos[4], Color[2];
if(mysql_num_rows() > 0)
{
while(mysql_fetch_row_format(Query, "|"))
{
if(sscanf(Query, "p<|>s[23]dffffdd", Owner, Model, vPos[0], vPos[1], vPos[2], vPos[3], Color[0], Color[1]))
{
new vehicle = CreateVehicle(Model, vPos[0], vPos[1], vPos[2], vPos[3], Color[0], Color[1], -1);
vInfo[vehicle][vOwner] = Owner;
vInfo[vehicle][vModel] = Model;
vInfo[vehicle][vPosX] = vPos[0];
vInfo[vehicle][vPosY] = vPos[1];
vInfo[vehicle][vPosZ] = vPos[2];
vInfo[vehicle][vAngle] = vPos[3];
vInfo[vehicle][vColor1] = Color[0];
vInfo[vehicle][vColor2] = Color[1];
}
}
}
mysql_free_result();
}
It seems to be storing the information into the variables and it prints what it loads in the MySQL log file, the only problem is that the vehicles aren't being "created" or "spawned". Am I missing something?
Re: Loads but doesn't spawn vehicles -
Scenario - 02.01.2011
Bump...
Re: Loads but doesn't spawn vehicles -
Krx17 - 02.01.2011
Use print statements inside the loop to see if it really is storing information.
Re: Loads but doesn't spawn vehicles -
Scenario - 02.01.2011
Okay, I have this:
pawn Код:
if(sscanf(Query, "p<|>s[23]dffffdd", Owner, Model, vPos[0], vPos[1], vPos[2], vPos[3], Color[0], Color[1]))
{
print(Query);
new vehicle = CreateVehicle(Model, vPos[0], vPos[1], vPos[2], vPos[3], Color[0], Color[1], -1);
vInfo[vehicle][vOwner] = Owner;
vInfo[vehicle][vModel] = Model;
vInfo[vehicle][vPosX] = vPos[0];
vInfo[vehicle][vPosY] = vPos[1];
vInfo[vehicle][vPosZ] = vPos[2];
vInfo[vehicle][vAngle] = vPos[3];
vInfo[vehicle][vColor1] = Color[0];
vInfo[vehicle][vColor2] = Color[1];
}
... and I guess the data isn't being stored because nothing was printed. Perhaps you know of a possible solution?
EDIT: I found an old vehicle system I had on my HDD some time ago and noticed my issue was on the sscanf line. It's working well now.