Jump to content

pushed away when driving in teleport, pleas help


Recommended Posts

Here is an alternative (maybe cleaner) method to prevent vehicle from being catapulted into the air. Your method works as well but could cause problems on slow computers. I have noticed that the catapulting is related to the streaming of world objects. When objects are not fully streamed in the vehicle is catapulted more often. What happens on slow computers is that the camera is not close enough to the vehicle when your method unfreezes it. The following code may prevent that from happening.

client

  
function trackcam(vehicle) 
  local x, y, z = getElementPosition(vehicle) 
  local cx, cy, cz = getCameraPosition() 
  local dist = getDistanceBetweenPoints3D(x, y, z, cx, cy, cz) 
  if (dist < 25.0) then 
    setVehicleFrozen(vehicle, false) 
  else 
    setTimer(trackcam, 50, 1, vehicle) 
  end 
end 
  
function yourtpfunc() 
  -- teleport the vehicle 
  trackcam(vehicle) 
end 
  

But i have a quick question in scripting: whats the opposite from isPlayerInVehicle? i searched in the wiki but found nothing like isPlayerNotInVehicle or isPlayerOnfoot. Can anybody help me?

Why do you need a function that says you are not in a vehicle when that is exactly what the isPlayerInVehicle function does?

Link to comment
  • Replies 63
  • Created
  • Last Reply

Top Posters In This Topic

Yea thanks Ace_Gambit!!!! :shock:

Why do you need a function that says you are not in a vehicle when that is exactly what the isPlayerInVehicle function does?

You mean this?:

if not isPlayerInVehicle then 
... 

I already tried it but it don´t works :?:

No warnings or so, or is "if not" not correct in lua? But i think its correct

Link to comment

Yea thanks Ace_Gambit!!!! :shock:

Why do you need a function that says you are not in a vehicle when that is exactly what the isPlayerInVehicle function does?

You mean this?:

if not isPlayerInVehicle then...

I already tried it but it don´t works :?:

No warnings or so, or is "if not" not correct in lua? But i think its correct

Link to comment

Thanks but don´t work, i want a teleporter to go back to the real world, but i only want to allow teleporting back when the player is not in a vehicle.

here a the code:

  
  function backBeamer( player ) 
    if not isPlayerInVehicle ( player ) then 
     setElementInterior ( player, 0, 1109.8060302734, 1721.865234375, 10.8203125 ) 
    end 
  end 
  

any ideas pleas :)

Link to comment

Thanks but don´t work, i want a teleporter to go back to the real world, but i only want to allow teleporting back when the player is not in a vehicle.

here a the code:

   function backBeamer( player )    if not isPlayerInVehicle ( player ) then     setElementInterior ( player, 0, 1109.8060302734, 1721.865234375, 10.8203125 )    end  end 

any ideas pleas :)

Link to comment
Thanks but don´t work, i want a teleporter to go back to the real world, but i only want to allow teleporting back when the player is not in a vehicle.

here a the code:

  
  function backBeamer( player ) 
    if not isPlayerInVehicle ( player ) then 
     setElementInterior ( player, 0, 1109.8060302734, 1721.865234375, 10.8203125 ) 
    end 
  end 
  

any ideas pleas :)

Strange, because that should work. Maybe you must add brackets?

  
... 
if (not isPlayerInVehicle ( player )) then 
... 
  

Link to comment
Thanks but don´t work, i want a teleporter to go back to the real world, but i only want to allow teleporting back when the player is not in a vehicle.

here a the code:

   function backBeamer( player )    if not isPlayerInVehicle ( player ) then     setElementInterior ( player, 0, 1109.8060302734, 1721.865234375, 10.8203125 )    end  end 

any ideas pleas :)

Strange, because that should work. Maybe you must add brackets?

  
... 
if (not isPlayerInVehicle ( player )) then 
... 
  

Link to comment

No i use it server side, i describe it better what happens:

When i use this code i posted befor the player _AND_ the CAR gets teleported, and by the way the interior NOT changes :?

But i want that i only teleports when i am not in a vehicle, but the "filter" (if not) don´t work.

Here is the code again:

  
  function backBeamer( player ) 
    if not isPlayerInVehicle ( player ) then 
     setElementInterior ( player, 0, 1109.8060302734, 1721.865234375, 10.8203125 ) 
    end 
  end 
  

PS:

Strange, because that should work. Maybe you must add brackets?

...

if (not isPlayerInVehicle ( player )) then

...

Don´t work, its still the same

Link to comment

No i use it server side, i describe it better what happens:

When i use this code i posted befor the player _AND_ the CAR gets teleported, and by the way the interior NOT changes :?

But i want that i only teleports when i am not in a vehicle, but the "filter" (if not) don´t work.

Here is the code again:

   function backBeamer( player )    if not isPlayerInVehicle ( player ) then     setElementInterior ( player, 0, 1109.8060302734, 1721.865234375, 10.8203125 )    end  end 

PS:

Strange, because that should work. Maybe you must add brackets?

...

if (not isPlayerInVehicle ( player )) then

...

Don´t work, its still the same

Link to comment
  
function markerExit(name) 
   if name ~= getThisResource() then return else 
   local marker = createMarker ( -1401.2969970703, -261.7790222168, 1043.65625, "cylinder", 2, 225, 200, 0, 100 ) 
     end 
  end 
  
Col = createColSphere ( -1401.2969970703, -261.7790222168, 1043.65625, 2 ) 
addEventHandler ( "onColShapeHit", Col, [b][color=#FF4040]backBeamer[/color][/b] ) 
  
addEventHandler ( "onResourceStart", getRootElement(), markerExit) 
  

Link to comment
 function markerExit(name)   if name ~= getThisResource() then return else   local marker = createMarker ( -1401.2969970703, -261.7790222168, 1043.65625, "cylinder", 2, 225, 200, 0, 100 )     end  end Col = createColSphere ( -1401.2969970703, -261.7790222168, 1043.65625, 2 )addEventHandler ( "onColShapeHit", Col, [b][color=#FF4040]backBeamer[/color][/b] ) addEventHandler ( "onResourceStart", getRootElement(), markerExit) 

Link to comment

Have you tried to enter the colshape using a car? If you "hit colshape" with a car, the vehicle element will be passed to that function and what the function thinks is do is check if "vehicle element" is in vehicle. Just do a check, like:

  function backBeamer( player ) 
    if getElementType( player ) == "player" and not isPlayerInVehicle ( player ) then 
     setElementInterior ( player, 0, 1109.8060302734, 1721.865234375, 10.8203125 ) 
    end 
  end 

Link to comment

Have you tried to enter the colshape using a car? If you "hit colshape" with a car, the vehicle element will be passed to that function and what the function thinks is do is check if "vehicle element" is in vehicle. Just do a check, like:

  function backBeamer( player )    if getElementType( player ) == "player" and not isPlayerInVehicle ( player ) then     setElementInterior ( player, 0, 1109.8060302734, 1721.865234375, 10.8203125 )    end  end

Link to comment
Here is an alternative (maybe cleaner) method to prevent vehicle from being catapulted into the air. Your method works as well but could cause problems on slow computers. I have noticed that the catapulting is related to the streaming of world objects. When objects are not fully streamed in the vehicle is catapulted more often. What happens on slow computers is that the camera is not close enough to the vehicle when your method unfreezes it. The following code may prevent that from happening.

client

  
function trackcam(vehicle) 
  local x, y, z = getElementPosition(vehicle) 
  local cx, cy, cz = getCameraPosition() 
  local dist = getDistanceBetweenPoints3D(x, y, z, cx, cy, cz) 
  if (dist < 25.0) then 
    setVehicleFrozen(vehicle, false) 
  else 
    setTimer(trackcam, 50, 1, vehicle) 
  end 
end 
  
function yourtpfunc() 
  -- teleport the vehicle 
  trackcam(vehicle) 
end 
  

But i have a quick question in scripting: whats the opposite from isPlayerInVehicle? i searched in the wiki but found nothing like isPlayerNotInVehicle or isPlayerOnfoot. Can anybody help me?

Why do you need a function that says you are not in a vehicle when that is exactly what the isPlayerInVehicle function does?

You are right, sometimes i falling down because the interior not loading so fast or so.

So i tried your tip:

        function unfrozen( player ) 
         local playerVehicle = getPlayerOccupiedVehicle ( player ) 
         local x, y, z = getElementPosition(playerVehicle) 
         local cx, cy, cz = getCameraPosition() 
         local dist = getDistanceBetweenPoints3D(x, y, z, cx, cy, cz) 
           if (dist < 25.0) then 
             setVehicleFrozen(playerVehicle, false) 
            else 
             setTimer(unfrozen, 50, 1, player) 
           end 
        end 

But the vehicle don´t get unfrozen. any ideas?

And a error:

.lua:196: attempt to call global 'getCameraPosition' (a nil value) 

I tries also getCameraPosition' (player) and getCameraPosition' (playerVehicle) but i get the same error :?:

(PS: sorry for doppelpost but i think its ok because i found a problem and now i have a question... ^^)

Link to comment
Here is an alternative (maybe cleaner) method to prevent vehicle from being catapulted into the air. Your method works as well but could cause problems on slow computers. I have noticed that the catapulting is related to the streaming of world objects. When objects are not fully streamed in the vehicle is catapulted more often. What happens on slow computers is that the camera is not close enough to the vehicle when your method unfreezes it. The following code may prevent that from happening.

client

  
function trackcam(vehicle) 
  local x, y, z = getElementPosition(vehicle) 
  local cx, cy, cz = getCameraPosition() 
  local dist = getDistanceBetweenPoints3D(x, y, z, cx, cy, cz) 
  if (dist < 25.0) then 
    setVehicleFrozen(vehicle, false) 
  else 
    setTimer(trackcam, 50, 1, vehicle) 
  end 
end 
  
function yourtpfunc() 
  -- teleport the vehicle 
  trackcam(vehicle) 
end 
  

But i have a quick question in scripting: whats the opposite from isPlayerInVehicle? i searched in the wiki but found nothing like isPlayerNotInVehicle or isPlayerOnfoot. Can anybody help me?

Why do you need a function that says you are not in a vehicle when that is exactly what the isPlayerInVehicle function does?

You are right, sometimes i falling down because the interior not loading so fast or so.

So i tried your tip:

        function unfrozen( player )         local playerVehicle = getPlayerOccupiedVehicle ( player )         local x, y, z = getElementPosition(playerVehicle)         local cx, cy, cz = getCameraPosition()         local dist = getDistanceBetweenPoints3D(x, y, z, cx, cy, cz)           if (dist < 25.0) then             setVehicleFrozen(playerVehicle, false)            else             setTimer(unfrozen, 50, 1, player)           end        end

But the vehicle don´t get unfrozen. any ideas?

And a error:

.lua:196: attempt to call global 'getCameraPosition' (a nil value)

I tries also getCameraPosition' (player) and getCameraPosition' (playerVehicle) but i get the same error :?:

(PS: sorry for doppelpost but i think its ok because i found a problem and now i have a question... ^^)

Link to comment

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...