Jump to content

Teleport Bug


Bonsai

Recommended Posts

Posted

Hi all,

I've got another problem.

I made a map with a portal, but everytime I drive in it, I just spin around and fall in the water.

Maybe someone know how to fix that. I heard something about setVehicleFrozen, but I dont know exactly how to.

Here is the Code.

function warp (player)
 
if source == grav6 then
if isPedInVehicle(player) then 
local vehicle=getPedOccupiedVehicle(player) 
setElementPosition (vehicle , 328.11853027344, -3056.39453125, 635.34979248047 )
end
end
addEventHandler( "onClientMarkerHit", getRootElement(), warp )

UPDATE: Freeze works now, but how to unfreeze after it arrived?

Posted

IMHO It's better to:

1. Save vehicles current speed

2. Set it to 0

3. Set position

4. Apply saved speed values on vehicle

# 1 and 4 in case you want the vehicle to keep moving after entering the portal, otherwise skip them.

Still, setVehicleFrozen() serves both for freezing\unfreezing, what is your question about?

Posted
if source == grav6 then
if isPedInVehicle(player) then 
local vehicle=getPedOccupiedVehicle(player) 
setElementPosition (vehicle , 328.11853027344, -3056.39453125, 635.34979248047 )
setVehicleFrozen ( vehicle , true )
--Here I would need a command like "wait 2 sec and setVehicleFrozen ( vehicle , false )"
end
 
end

But I think there is no command like that.

EDIT: How to set vehicle speed? :(

Posted

setElementVelocity(), the speedX\Y\Z are related to world.. just try it out yourself )

As for the "wait for 2 seconds.. etc":

setTimer( setVehicleFrozen, 2000, 1, vehicle, false )

should work. You use the standart setTimer() function, first goes the function you'd like to execute, then delay (milliseconds), then how many times to repeat execution; after this you pass arguments you'd pass to setVehicleFrozen() itself.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...