Jump to content

Vehicle Teleport problem, fly in the sky...


Recommended Posts

I have a problem with my Vehicle teleport, when the player teleport with a vehicle its fly in the sky and make many 360° rotation.

First i thought the teleport points are not good and i add some for a test in the sky but the same problem the vehicle goes from 0 to ~250km and make many rotation :(

This are my teleport scripts:

For the chat teleport is use this one:

function hjwarp (player) 
    if isPlayerInVehicle(player) then -- If the player is in a vehicle... 
        local vehicle=getPlayerOccupiedVehicle(player) -- Obtain the vehicle the player is in 
        if getVehicleController(vehicle)==player then -- If the player is the driver... 
            setElementPosition (vehicle , 886.24, 2479.17, 261.32 ) -- Warp the vehicle 
            outputChatBox ( "You're warped to High Jump /hj!", player, 0, 255, 0 ) 
        end 
    else -- If the player isn't in a vehicle... 
        setElementPosition (player , 886.24, 2479.17, 261.32 ) -- Warp the player 
        outputChatBox ( "You're warped to High Jump /hj!", player, 0, 255, 0 ) 
    end 
end 
addCommandHandler ( "hj", hjwarp ) 

and this is my menu teleport server side:

LOCATIONS = { }; 
-- Add your locations here, 
-- text between [ and ] MUST be the same as on the buttons 
-- because client will send text from the buttons: 
LOCATIONS[ "Huge Jump" ] = { 886.24, 2479.17, 261.32 }; 
LOCATIONS[ "Water Jump" ] = { 2339.720703125, -161.08451843262, 181.44232177734 }; 
LOCATIONS[ "Airport Jump" ] = { -92.949096679688, 1445.4046630859, 1101.4439697266 }; 
LOCATIONS[ "Super Jump" ] = { -162.94660949707, 1781.0217285156, 674.16528320313 }; 
LOCATIONS[ "Beach Jump" ] = { 827.25946044922, -3171.4382324219, 595.85174560547 }; 
LOCATIONS[ "Looping" ] = { 1696.9108886719, -1257.9813232422, 363.45672607422 }; 
LOCATIONS[ "Las Venturas Jump" ] = { 2067.7434082031, 2382.5844726563, 482.86682128906 }; 
LOCATIONS[ "Las Venturas Airport" ] = { 1886.8115234375, -2455.1220703125, 16.459857940674 }; 
  
addEvent( "YOUR_CUSTOM_EVENT", true ); 
addEventHandler( "YOUR_CUSTOM_EVENT", getRootElement( ), 
    function( locationName ) 
        if LOCATIONS[ locationName ] then 
            local veh = getPlayerOccupiedVehicle( client ); 
  
            setElementPosition( ( ( veh and getVehicleOccupant( veh ) == client) and veh or client ), unpack( LOCATIONS[ locationName ] ) ); 
  
        end 
    end 
) 

I hope someone can say me why and how i can fix this problem :)

THX for this help and BIG THX for all the other help post!!!!

Very nice people here!!! THX :D

Link to comment

i have now:

function hjwarp (player) 
    if isPlayerInVehicle(player) then -- If the player is in a vehicle... 
        local vehicle=getPlayerOccupiedVehicle(player) -- Obtain the vehicle the player is in 
        if getVehicleController(vehicle)==player then -- If the player is the driver... 
            setVehicleFrozen(vehicle, true) 
            setElementPosition (vehicle , 886.24, 2479.17, 261.32 ) -- Warp the vehicle 
            outputChatBox ( "You're warped to High Jump /hj!", player, 0, 255, 0 ) 
        end 
    else -- If the player isn't in a vehicle... 
        setElementPosition (player , 886.24, 2479.17, 261.32 ) -- Warp the player 
        outputChatBox ( "You're warped to High Jump /hj!", player, 0, 255, 0 ) 
    end 
end 
addCommandHandler ( "hj", hjwarp ) 

and

addEvent( "YOUR_CUSTOM_EVENT", true ); 
addEventHandler( "YOUR_CUSTOM_EVENT", getRootElement( ), 
    function( locationName ) 
        if LOCATIONS[ locationName ] then 
            local veh = getPlayerOccupiedVehicle( client ); 
           
            setVehicleFrozen(veh, true) 
            setElementPosition( ( ( veh and getVehicleOccupant( veh ) == client) and veh or client ), unpack( LOCATIONS[ locationName ] ) ); 
  
        end 
    end 
) 

but how i unfreeze the vehicle?

Link to comment

BIG THX for the help!!!!!!!!

I have use this:

setTimer(setVehicleFrozen, 200, 1, vehicle, false) -- Time not under 200 or the vehicle teleport problem comes back 

I have use setTime so that when the vehicle is Frozen on the spawn point not in the same time the vehicle unfrozen.

Without setTime the crazy Vehicle teleport problem comes back and the time not under 200!

Link to comment

The server send me a error when i use my script... its work very good but the server send me the error :?:

[22:37:21] WARNING: menu_server.lua: Bad argument @ 'setVehicleFrozen' - Line: 21 

and this is my script:

LOCATIONS[ "Halfpipe" ] = { 2857.1716308594, -1961.9986572266, 11.400349617004 }; 
  
addEvent( "YOUR_CUSTOM_EVENT", true ); 
addEventHandler( "YOUR_CUSTOM_EVENT", getRootElement( ), 
    function( locationName ) 
        if LOCATIONS[ locationName ] then 
            local veh = getPlayerOccupiedVehicle( client ); 
           
            setVehicleFrozen(veh, true) 
            setElementPosition( ( ( veh and getVehicleOccupant( veh ) == client) and veh or client ), unpack( LOCATIONS[ locationName ] ) ); 
            setTimer(setVehicleFrozen, 200, 1, veh, false) 
  
        end 
    end 
) 

When i teleport with a bike i fall og from the bike, is there a way for add a antibike-fall-off for some secs too?

I know that i say all the time thx but im happy for all this help here so THX for the help! :)

Link to comment

Check if veh is not nil or false and if it's not then proceed with the vehicle functions. You should know how if statement works by now so I'm not going to explain it to you... if you don't know how it works then I'd suggest you to start learning by looking into other scripts, wiki or even google.

About the falling off the bike... If you're using DP2.x then there is a function canPlayerBeKnockedOffBike if you're using nightly build replace Player with Ped (in the function name).

Link to comment

OK i have understand what you mean :)

And i have now:

Server side:

addEvent( "YOUR_CUSTOM_EVENT", true ); 
addEventHandler( "YOUR_CUSTOM_EVENT", getRootElement( ), 
    function( locationName ) 
        if LOCATIONS[ locationName ] then 
            local veh = getPlayerOccupiedVehicle( client ); 
            if ( ( veh ) and ( client == getVehicleOccupant( veh ) ) then 
                setVehicleFrozen(veh, true) 
                setElementPosition( veh, unpack( LOCATIONS[ locationName ] ) ); 
                setTimer(setVehicleFrozen, 200, 1, veh, false) 
            else 
                setElementPosition( client, unpack( LOCATIONS[ locatioName ] ) ); 
            end 
        end 
    end 
) 

But i get a error from the server and the script dont work :? This is the error:

[17:58:27] ERROR: Client triggered serverside event YOUR_CUSTOM_EVENT, but event is not added serverside 

Client:

... 
function teleportTo( ) 
    triggerServerEvent( "YOUR_CUSTOM_EVENT", getLocalPlayer( ), guiGetText( source ) ); 
end 
  
bindKey( "F1", "down", 
  function () 
    showCursor( not isCursorShowing() ) 
  end 
) 

Link to comment

It seems that server-side script didn't start. Didn't you get another error? addEvent never failed for me... and I doubt it failed for you. Usually you get an error that server triggered clientside event but event is not added clientside. It happens when you try to triggerClientEvent in onResourceStart because player has to download script and addEvent before server triggers that event.

Make sure server-side script started by outputting some text.

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