Returning Vehicle ID in an array (with loop) causes 'not continueing' -
Jochemd - 14.05.2011
As you see here, I create a new vehicle. Before it, there is 'new vehicle = ' so I can store the vehicle ID for a while. If I use this, the server will stop after it (the last thing it prints is "Debug 3", while that gets called AFTER it). If I remove that 'new vehicleid = ' it just works fine. So I guess this is bugged, for everything where vehicleid is used after it, cause the server stops at VehicleInfo[vehicleid][FileVehicleID] = v;
According to
this topic, where we couldn't find a solution.
pawn Код:
for(new v = 0; v < MAX_VEHICLES; v ++)
{
new QueryString[128],Line[128],ID,modelid,VehicleColor,Own[MAX_PLAYER_NAME],vehicleid,Float:VehicleAngle,doors,panels,lights,tires,Float:Health,Float:VehiclePos[3],Fuel2,ParkedLot2,PhoneBooks2,Ropes2,BlindFolds2,MedicalKits2;
VehicleInfo[v][Fuel] = 100;
format(QueryString,sizeof(QueryString),"SELECT * FROM `VehicleInfo` WHERE `ID` = '%d'",v);
mysql_query(QueryString);
mysql_store_result();
if(mysql_num_rows())
{
if(mysql_fetch_row(Line))
{
print("Debug 1");
sscanf(Line,"p<|>dds[24]ffffdddddfddddd",ID,modelid,VehicleColor,Own,VehiclePos[0],VehiclePos[1],VehiclePos[2],VehicleAngle,Fuel2,doors,panels,lights,tires,Health,ParkedLot2,PhoneBooks2,Ropes2,BlindFolds2,MedicalKits2);
print("Debug 2");
vehicleid = CreateVehicle(modelid,VehiclePos[0],VehiclePos[1],VehiclePos[2],VehicleAngle,VehicleColor,VehicleColor,-1);
print("Debug 3");
VehicleInfo[vehicleid][FileVehicleID] = v;
print("Debug 4");
VehicleInfo[vehicleid][Owned] = 1;
print("Debug 5");
VehicleInfo[vehicleid][Fuel] = Fuel2;
print("Debug 6");
VehicleInfo[vehicleid][ParkedLot] = ParkedLot2;
print("Debug 7");
VehicleInfo[vehicleid][ContainingPhonebooks] = PhoneBooks2;
print("Debug 8");
VehicleInfo[vehicleid][ContainingRopes] = Ropes2;
print("Debug 9");
VehicleInfo[vehicleid][ContainingBlindfolds] = BlindFolds2;
print("Debug 10");
VehicleInfo[vehicleid][ContainingMedicalKits] = MedicalKits2;
print("Debug 11");
format(VehicleInfo[vehicleid][Owner],MAX_PLAYER_NAME,"%s",Own);
print("Debug 12");
SetVehicleHealth(vehicleid,Health);
print("Debug 13");
OnVehicleDamageStatusUpdate(vehicleid,-1);
print("Debug 14");
UpdateVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
printf("Owner File Vehicle ID '%d' (vehicleid '%d') has been created at X:%.3f || Y:%.3f || Z:%.3f",v,vehicleid,VehiclePos[0],VehiclePos[1],VehiclePos[2]);
}
}
}
Re: Returning Vehicle ID in an array (with loop) causes 'not continueing' -
beckzy - 14.05.2011
Change VehicleInfo[vehicleid][] to VehicleInfo[vehicleid-1][] or change new VehicleInfo[MAX_VEHICLES][] to VehicleInfo[MAX_VEHICLES+1][]
Re: Returning Vehicle ID in an array (with loop) causes 'not continueing' -
Jochemd - 14.05.2011
Why that? It didn't work though
Re: Returning Vehicle ID in an array (with loop) causes 'not continueing' -
Biesmen - 14.05.2011
Try to change
to
You're storing "ID", not "vehicleid".
Also, you're using VehicleColor twice, so if he has color1 = 127 and color2 = 182, it will only store color1.
But I'm not sure if this would solve the bug.
Re: Returning Vehicle ID in an array (with loop) causes 'not continueing' -
DRIFT_HUNTER - 14.05.2011
How did you defined your vehicleid?
new vehicleid = v;
Re: Returning Vehicle ID in an array (with loop) causes 'not continueing' -
Seven_of_Nine - 14.05.2011
*did you define, and maybe he / she is right about that.
Have you tried that -1 before?
![Cheesy](images/smilies/biggrin.png)
And maybe just maybe the modelid is wrong. Debug that, too!
And my last think is the mysql_query. Maybe has some problems..
Well, good luck with this code :\
Re: Returning Vehicle ID in an array (with loop) causes 'not continueing' -
Joe Staff - 14.05.2011
You should just call all mysql rows from that table instead of one at a time.
Re: Returning Vehicle ID in an array (with loop) causes 'not continueing' -
leong124 - 15.05.2011
Man he say the last thing printed out is Debug 3.
So the line under it is the problem.
pawn Код:
VehicleInfo[vehicleid][FileVehicleID] = v;
vehicleid is correct, because it is retrieved in CreateVehicle,
so vehicleid should not be decreased/increased by 1.
Make sure the VehicleInfo array is large enough.
Also try to change the sscanf as a check(i.e. if( !sscanf(...)) ).
Re: Returning Vehicle ID in an array (with loop) causes 'not continueing' -
Raimis_R - 15.05.2011
Yes you need call all rows
pawn Код:
mysql_query("SELECT * FROM `VehicleInfo`");
and when split.
Re: Returning Vehicle ID in an array (with loop) causes 'not continueing' -
Jochemd - 15.05.2011
Like I told before, the problem is in 'vehicleid'. If I remove 'vehicleid' and just leave 'CreateVehicle' without 'vehicleid = ' stuff it just works fine.