[FIXED]SetVehicleVirtualWorld doesn't want to work
#1

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

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 !");
}
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
Reply
#2

Also tried with SetVehicleToRespawn on creation and SetVehicleVirtualWorld on OnVehicleSpawn with no results
Reply
#3

After a lot of experimenting I figured out that SetVehicleVirtualWorld is quite bugged. I couldn't find a way to have it working with a timer, so I tried it via a command "/sync" which worked. After that I put
pawn Код:
OnPlayerCommandText(playerid, "/sync");
under OnPlayerConnect which didn't work, BUT putting it under OnPlayerSpawn amazingly fixed the problem.
I hope this'll help others with the same problem
Reply
#4

Quote:
Originally Posted by dice7
After a lot of experimenting I figured out that SetVehicleVirtualWorld is quite bugged. I could find a way to have it working with a timer, so I tried it via a command "/sync" which worked. After that I put
pawn Код:
OnPlayerCommandText(playerid, "/sync");
under OnPlayerConnect which didn't work, BUT putting it under OnPlayerSpawn amazingly fixed the problem.
I hope this'll help others with the same problem
Well, at least you stated how you fixed it so others who have similar problems can find the solution.
Reply
#5

Iknow its an old topic but i wonder if this is better fixed now in samp ?
Because im making vehicles in a virtual world ..when i teleport to them they wont show
But if im standing at the place they should show up and use a command that sets me as a player to
the viirtual world there at then it does work.
Anyone an idea why teleporting to it doesnt ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)