[Help] Vehicle System
#1

Hello

I'm editing the Carlitos roleplay, and I decided to change the system of cars, so that each car has a file.

But when the server loads the cars for each file it creates nine cars and a car was to create a file ..

I'll leave here the code for if they can help.




Код:
public LoadDynamicCars()
{
 	new idx = 0;
	while (idx < 500)
	{
		new string11[128];
		format(string11, sizeof(string4),"CRP_Scriptfiles/Cars/%d.ini",idx);
		new File: CarroFile = fopen(string11, io_read);
		if(fexist(string11))
		{
 			new key[ 256 ] , val[ 256 ];
    		new Data[ 256 ];
		    while ( fread( CarroFile , Data , sizeof( Data ) ) )
			{
			    key = ini_GetKey( Data );
		    	if( strcmp( key , "CarModel" , true ) == 0 ) { val = ini_GetValue( Data ); DynamicCars[idx][CarModel] = strval( val ); }
		    	if( strcmp( key , "CarX" , true ) == 0 ) { val = ini_GetValue( Data ); DynamicCars[idx][CarX] = floatstr( val ); }
		    	if( strcmp( key , "CarY" , true ) == 0 ) { val = ini_GetValue( Data ); DynamicCars[idx][CarY] = floatstr( val ); }
		    	if( strcmp( key , "CarZ" , true ) == 0 ) { val = ini_GetValue( Data ); DynamicCars[idx][CarZ] = floatstr( val ); }
		    	if( strcmp( key , "CarAngle" , true ) == 0 ) { val = ini_GetValue( Data ); DynamicCars[idx][CarAngle] = floatstr( val ); }
		    	if( strcmp( key , "CarColor1" , true ) == 0 ) { val = ini_GetValue( Data ); DynamicCars[idx][CarColor1] = strval( val ); }
		    	if( strcmp( key , "CarColor2" , true ) == 0 ) { val = ini_GetValue( Data ); DynamicCars[idx][CarColor2] = strval( val ); }
		    	if( strcmp( key , "FactionCar" , true ) == 0 ) { val = ini_GetValue( Data ); DynamicCars[idx][FactionCar] = strval( val ); }
		    	if( strcmp( key , "CarType" , true ) == 0 ) { val = ini_GetValue( Data ); DynamicCars[idx][CarType] = strval( val ); }

				new vehicleid=CreateVehicle(DynamicCars[idx][CarModel],DynamicCars[idx][CarX],DynamicCars[idx][CarY],DynamicCars[idx][CarZ],DynamicCars[idx][CarAngle],DynamicCars[idx][CarColor1],DynamicCars[idx][CarColor2], -1);
                ncarros++;
				if(DynamicCars[idx][FactionCar] != 255)
				{
					SetVehicleNumberPlate(vehicleid, DynamicFactions[DynamicCars[idx][FactionCar]][fName]);
					SetVehicleToRespawn(vehicleid);
				}
			}
      		fclose(CarroFile);
		}
		idx++;
	}
    new wstring[126];
	format(wstring, sizeof(wstring), "Foram criados %d carros",ncarros);
 	print(wstring);
}

Thank you very much
Reply
#2

pawn Код:
new vehicleid=CreateVehicle(DynamicCars[idx][CarModel],DynamicCars[idx][CarX],DynamicCars[idx][CarY],DynamicCars[idx][CarZ],DynamicCars[idx][CarAngle],DynamicCars[idx][CarColor1],DynamicCars[idx][CarColor2], -1);
needs to be outside of the second "while" loop..
so before or behind
"fclose(CarroFile);"
Reply
#3

Thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)