Can't use SetVehiclePos and SetVehicleVirtualWorld together
#1

Hey,
I have a problem with SetVehiclePos and SetVehicleVirtualWorld.
I want to move a vehicle, change its VirtualWorld for 10 seconds to something else and the let it reappear in the standardworld (id=0)
I've tried both Linking to another interior and setting another virtual world. Both doesn't work. I could fix the problem by moving the car to an invisible place without any problem but I'm kinda curious why it doesn't work.
The car which shall be moved is attached as a trailer beforehand and it gets detached before moving/changing the virtual world.

So here is the code (the public funciton is forwarded):
Код:
public BringBackRepairedCar(vehicleid)
{
SetVehicleVirtualWorld(vehicleid, 0);
}

RepairAndDisappearTrailer(vehicleid)
{
new towedcar = GetVehicleTrailer(GetPlayerVehicleID(playerid));
towedcarplace[i][VEHICLEID] = towedcar;
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
SetVehicleVirtualWorld(towedcar, 10);
RepairVehicle(towedcar);
SetVehiclePos(towedcar, coordx,  coordy,  coordz);
SetTimerEx("BringBackRepairedCar", 10000, false , "i", towedcar);
}
coordx,y,z are any coordinates. it doesn't matter which I use.
Reply
#2

Your SetTimerEx has wrong order of arguments. Switch false and 10000 (https://sampwiki.blast.hk/wiki/SetTimerEx)
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Your SetTimerEx has wrong order of arguments. Switch false and 10000 (https://sampwiki.blast.hk/wiki/SetTimerEx)
Wow didn't noticed that. I'll try it out but wouldn't it be strange if that's the problem? Because the car actually gets moved and putted into the other vw before this functions gets called. But I'll try it.+

Edit: Yea, the reappearing works now, but still the car only is the virtual world but doesn't get moved.
Reply
#4

Where do you store coords in coordx, coordy, coordz variables?
Reply
#5

Normally they are in an array. But right now I'm testing with constants.
Код:
SetVehiclePos(towedcar, 2318.0681,-2364.0303,13.3784);
SetVehicleZAngle(towedcar, 44.6877);
Reply
#6

Push, I've got it done by using a timer on setting the virtual world. So first I set the position and then I wait 100ms and set the VW.
But that's pretty bad style imho. No way to fixing that?
Reply
#7

Apparently not, if that worked.
Reply
#8

Hm ok. But can someone explain please why it doesn't work in the different order? So first setting the VW and then setting the position a little time after?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)