SA-MP Forums Archive
Vehicle not created? - 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: Vehicle not created? (/showthread.php?tid=97310)



Vehicle not created? - x-cutter - 13.09.2009

Ok. I edited a bit of my code to discover DestroyVehicle wasn't the actual problem. The problem (I think) is that the vehicle doesn't get created.
Код:
stock CreateVehicleEx(vehicletype,Float:x,Float:y,Float:z,Float:rot,color1,color2,resp,owner[],cost)
{
	VehicleCount++;
	new str[128];
	format(str,128,"WSSFILES/CARDATA/%d.xcu",VehicleCount);
	if(fexist(str))
	{
	  VehicleVar[VehicleCount][vtype]=djInt(str,"VehicleType",false);
	  VehicleVar[VehicleCount][carX]=djFloat(str,"X",false);
	  VehicleVar[VehicleCount][carY]=djFloat(str,"Y",false);
	  VehicleVar[VehicleCount][carZ]=djFloat(str,"Z",false);
	  VehicleVar[VehicleCount][carRot]=djFloat(str,"Rot",false);
		VehicleVar[VehicleCount][vcolor1]=djInt(str,"color1",false);
		VehicleVar[VehicleCount][vcolor2]=djInt(str,"color2",false);
	  VehicleVar[VehicleCount][resp_time]=djInt(str,"Resp",false);
	  CreateVehicle(VehicleVar[VehicleCount][vtype],VehicleVar[VehicleCount][carX],VehicleVar[VehicleCount][carY],VehicleVar[VehicleCount][carZ],VehicleVar[VehicleCount][carRot],VehicleVar[VehicleCount][vcolor1],VehicleVar[VehicleCount][vcolor2],VehicleVar[VehicleCount][resp_time]);
	  format(VehicleVar[VehicleCount][ownername],24,"%s",dj(str,"Owner",false));
		VehicleVar[VehicleCount][value]=djInt(str,"Cost",false);
	}
	else
	{
		// ....
	}
 	if(!strcmp(VehicleVar[VehicleCount][ownername],"ForSale"))
 	{
		VehicleVar[VehicleCount][locked]=0;
 	}
  	if(!strcmp(VehicleVar[VehicleCount][ownername],"SFPD"))
  	{
		VehicleVar[VehicleCount][locked]=1;
 	}
	VehicleVar[VehicleCount][engine]=0;
	return VehicleCount;
}
VehicleCount; is for counting Vehicle IDs
EDIT: Yes I forgot to say that at the end no vehicle is created. BTW sorry for indentation, the forum fucks it up

Please help me get why the vehicles aren't getting created/get destroyed!

Thanx


Re: DestroyVehicle bug? - x-cutter - 13.09.2009

*bump*


Re: DestroyVehicle bug? - x-cutter - 13.09.2009

Quote:
Originally Posted by Y_Leѕѕ
Why are you creating a vehicle then loading another vehicle with information about that vehicle from a file? Why not just load the information in the first place?
Because I need the actual vehicle ID to know which file I should get the data from.



Re: Vehicle not created? - x-cutter - 13.09.2009

Updated problem... See first post


Re: Vehicle not created? - dice7 - 13.09.2009

Does the file exist ? Also, add debug messages at every ~third line so you'll see where it gets stuck