18.10.2009, 16:03
So I have a custom vehicle file saving/loading system combined with a turf wars script. The problem is that what ever I tried, the vehicles didn't want to spawn in a specific virtual world, always in 0
Everything works fine, the numbers are correct, the cars spawn, but they are not in the correct virtual world.
BUT if I create a car via a command, it will go into the correct virtual world. The timer is being executed from OnFilterScriptInit. I also tried it from OnGameModeInit and even OnPlayerConnect, but it still didn't work.
Also, this is 0.2X
pawn Код:
#define VIRTUAL_WORLD 6
public LoadCars()
{
new turf,
File: file = fopen("/Gang_System/cars.txt", io_read);
if (file)
{
new idx;
while (idx < MAX_CARS)
{
fread(file, str[idx]);
///if the data in the file is incorrect
if(sscanf(str[idx], "p|ddffff", turf, TurfCars[idx][CarID], TurfCars[idx][CarX], TurfCars[idx][CarY], TurfCars[idx][CarZ], TurfCars[idx][CarAngle]))
{
printf("Error on line %d", idx+1);
printf("ID: %d, X: %f, Y:%f:, Z: %f, Angle: %f",TurfCars[idx][CarID], TurfCars[idx][CarX], TurfCars[idx][CarY], TurfCars[idx][CarZ], TurfCars[idx][CarAngle]);
idx++;
continue;
}
//this mechanism makes it so that can be only 2 cars per turf
if(TurfCars[ turf ][ CarsInTurf ][ 0 ] == 0)
{
TurfCars[ turf ][ VehID ][ 0 ] = CreateVehicle(TurfCars[idx][CarID], TurfCars[idx][CarX], TurfCars[idx][CarY], TurfCars[idx][CarZ], TurfCars[idx][CarAngle], -1, -1, 360);
SetVehicleVirtualWorld(TurfCars[ turf ][ VehID ][ 0 ], VIRTUAL_WORLD);
printf("LINE %d ID: %d, X: %f, Y:%f:, Z: %f, Angle: %f",idx+1 ,TurfCars[idx][CarID], TurfCars[idx][CarX], TurfCars[idx][CarY], TurfCars[idx][CarZ], TurfCars[idx][CarAngle]);
}
else
{
TurfCars[ turf ][ VehID ][ 1 ] = CreateVehicle(TurfCars[idx][CarID], TurfCars[idx][CarX], TurfCars[idx][CarY], TurfCars[idx][CarZ], TurfCars[idx][CarAngle], -1, -1, 360);
SetVehicleVirtualWorld(TurfCars[ turf ][ VehID ][ 1 ], VIRTUAL_WORLD);
printf("LINE %d ID: %d, X: %f, Y:%f:, Z: %f, Angle: %f",idx+1 ,TurfCars[idx][CarID], TurfCars[idx][CarX], TurfCars[idx][CarY], TurfCars[idx][CarZ], TurfCars[idx][CarAngle]);
}
TurfCars[ turf ][ CarsInTurf ][ 0 ]++;
idx++;
}
fclose(file);
}
print("Gang Cars Loaded !");
}
BUT if I create a car via a command, it will go into the correct virtual world. The timer is being executed from OnFilterScriptInit. I also tried it from OnGameModeInit and even OnPlayerConnect, but it still didn't work.
Also, this is 0.2X