Hey,
habe eine Funktion die Autos direkt nach dem Spawnen speichert und beim nächsten Server start wieder lädt.
Wenn die Datei (cars.cfg) leer ist, kann ich ganz normal joinen.
Wenn ich allerdings ein Auto spawne, und danach den Server neustarte und wieder joine.
Dann crasht mein Client.
Hier der Code:
public LoadVehicles()
{
new
INFO[128];
new File: CarFile = fopen("cars.cfg", io_read);
if ( CarFile )
{
new key[ 256 ], val[ 256 ];
new Data[ 256 ];
while ( fread( CarFile , Data , sizeof( Data ) ) )
{
for(new v=0;v<MAX_VEHICLES;v++)
{
key = ini_GetKey( Data );
format(INFO, sizeof(INFO), "Owner[%d]",v);
if( strcmp( key , INFO, true ) == 0 ) { val = ini_GetValue( Data ); Vehicle[v][vOwner] = strval( val ); }
else { return 1; }
format(INFO, sizeof(INFO), "Color1[%d]",v);
if( strcmp( key , INFO, true ) == 0 ) { val = ini_GetValue( Data ); Vehicle[v][vColor1] = strval( val ); }
format(INFO, sizeof(INFO), "Color2[%d]",v);
if( strcmp( key , INFO, true ) == 0 ) { val = ini_GetValue( Data ); Vehicle[v][vColor2] = strval( val ); }
format(INFO, sizeof(INFO), "Number[%d]",v);
if( strcmp( key , INFO, true ) == 0 ) { val = ini_GetValue( Data ); Vehicle[v][vNumber] = strval( val ); }
format(INFO, sizeof(INFO), "Health[%d]",v);
if( strcmp( key , INFO, true ) == 0 ) { val = ini_GetValue( Data ); Vehicle[v][vHealth] = strval( val ); }
format(INFO, sizeof(INFO), "Model[%d]",v);
if( strcmp( key , INFO, true ) == 0 ) { val = ini_GetValue( Data ); Vehicle[v][vModel] = strval( val ); }
format(INFO, sizeof(INFO), "X[%d]",v);
if( strcmp( key , INFO, true ) == 0 ) { val = ini_GetValue( Data ); Vehicle[v][vX] = strval( val ); }
format(INFO, sizeof(INFO), "Y[%d]",v);
if( strcmp( key , INFO, true ) == 0 ) { val = ini_GetValue( Data ); Vehicle[v][vY] = strval( val ); }
format(INFO, sizeof(INFO), "Z[%d]",v);
if( strcmp( key , INFO, true ) == 0 ) { val = ini_GetValue(Data); Vehicle[v][vZ] = strval(val);}
format(INFO, sizeof(INFO), "A[%d]",v);
if( strcmp( key , INFO, true ) == 0 ) { val = ini_GetValue(Data); Vehicle[v][vA] = strval(val);}
format(INFO, sizeof(INFO), "Locked[%d]",v);
if( strcmp( key , INFO, true ) == 0 ) { val = ini_GetValue(Data); Vehicle[v][vLocked] = strval(val);}
format(INFO, sizeof(INFO), "ID[%d]",v);
if( strcmp( key , INFO, true ) == 0 ) { val = ini_GetValue(Data); Vehicle[v][vID] = strval(val);}
Vehicle[v][vID] = CreateVehicle(Vehicle[v][vModel],Vehicle[v][vX],Vehicle[v][vY],Vehicle[v][vZ],Vehicle[v][vA],Vehicle[v][vColor1],Vehicle[v][vColor2],-1);
SpawnedVehicles ++;
}
}
fclose(CarFile);
}
return 1;
}
Und so sieht meine cars.cfg zZ. aus:
ZitatAlles anzeigenOwner[0]=AlexandA
Model[0]=522
X[0]=-2636.216308
Y[0]=1366.561889
Z[0]=7.127454
A[0]=0.000000
Color1[0]=3
Color2[0]=6
Number[0]=AlexandA
Locked[0]=1
ID[0]=0