[Help] Vehicle System - 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: [Help] Vehicle System (
/showthread.php?tid=294326)
[Help] Vehicle System -
mikiii18 - 01.11.2011
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
Re: [Help] Vehicle System -
Sascha - 01.11.2011
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);"
Respuesta: [Help] Vehicle System -
mikiii18 - 01.11.2011
Thanks.