Jump to content

help me in Telports scripts


AnDReJ98

Recommended Posts

hi guys

i make this teleports

its work

but when in the vehicle

when click the button

vehicle fly and blow

please some one help me

this client side

addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == GUIEditor_Button[1]) then 
     local theplayer = getLocalPlayer()      
     local theVehicle = getPedOccupiedVehicle 
                    setElementPosition (theplayer , 1523.9138183594, 1527.1204833984, 10.2602405548  ) 
                    setElementPosition (theVehicle , 1523.9138183594, 1527.1204833984, 10.2602405548  ) 
  
    end 
end) 

Link to comment

Try this.

addEventHandler("onClientGUIClick", getResourceRootElement(getThisResource()), 
function() 
    if (source == GUIEditor_Button[1]) then 
        local thePlayer = getLocalPlayer()     
        local theVehicle = getPedOccupiedVehicle(thePlayer) 
         
        if theVehicle and thePlayer then 
            setElementPosition(theVehicle , 1523.9138183594, 1527.1204833984, 10.2602405548) 
        elseif not theVehicle and thePlayer then 
            setElementPosition(thePlayer , 1523.9138183594, 1527.1204833984, 10.2602405548) 
        elseif not theVehicle and not thePlayer then 
            return 
        end 
    end 
end) 

Link to comment
  
--This function is executed when the button is clicked - it warps the local player. 
local function onTeleportButtonClicked() 
    local localVehicle = getPedOccupiedVehicle(localVehicle) 
    if localVehicle then 
        if getVehicleController(localVehicle) == localPlayer then --IF the player is driving a vehicle, warp the vehicle. 
            setElementPosition(localVehicle, 1523.9138183594, 1527.1204833984, 10.2602405548) 
            return 
        else 
            outputChatBox("* You must be driving the vehicle to warp it!", 255, 0, 0) 
            return 
        end 
    else 
        setElementPosition(localPlayer, 1523.9138183594, 1527.1204833984, 10.2602405548) 
        return 
    end 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[1], end) 
  

There is no need to attach the event handler resourceRoot - just the button you are tracking clicks for. Also, the crazy if statement stuff doesn't make much sense.

Link to comment
--This function is executed when the button is clicked - it warps the local player. 
local function onTeleportButtonClicked() 
    local localVehicle = getPedOccupiedVehicle(localPlayer) 
    if localVehicle then 
        if getVehicleController(localVehicle) == localPlayer then --IF the player is driving a vehicle, warp the vehicle. 
            setElementPosition(localVehicle, 1523.9138183594, 1527.1204833984, 10.2602405548) 
        end 
    else 
        setElementPosition(localPlayer, 1523.9138183594, 1527.1204833984, 10.2602405548) 
    end 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[1], onTeleportButtonClicked, false) 

Edited by Guest
Link to comment
--This function is executed when the button is clicked - it warps the local player. 
local function onTeleportButtonClicked() 
    local localVehicle = getPedOccupiedVehicle(localPlayer) 
    if localVehicle then 
        if getVehicleController(localVehicle) == localPlayer then --IF the player is driving a vehicle, warp the vehicle. 
            setElementPosition(localVehicle, 1523.9138183594, 1527.1204833984, 10.2602405548) 
        end 
    else 
        setElementPosition(localPlayer, 1523.9138183594, 1527.1204833984, 10.2602405548) 
    end 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[1], onTeleportButtonClicked, false) 

not work

Link to comment
--This function is executed when the button is clicked - it warps the local player. 
local function onTeleportButtonClicked() 
  if (source == GUIEditor_Button[1]) then 
    local localVehicle = getPedOccupiedVehicle(localPlayer) 
    if localVehicle then return end 
        if getVehicleController(localVehicle) == localPlayer then return end 
            setElementPosition(localVehicle, 1523.9138183594, 1527.1204833984, 10.2602405548) 
        end 
    else 
        setElementPosition(localPlayer, 1523.9138183594, 1527.1204833984, 10.2602405548) 
    end 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[1], onTeleportButtonClicked, false) 

why this not work

Link to comment

Try This

addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == GUIEditor_Button[1]) then 
     local theplayer = getLocalPlayer()      
     local theVehicle = getPedOccupiedVehicle 
                    setElementPosition (theplayer , 1523.9138183594, 1527.1204833984, 10.2602405548  ) 
                    setElementPosition (theVehicle , 1523.9138183594, 1527.1204833984, 10.2602405548  ) 
                    warpPedIntoVehicle ( theplayer, theVechicle )  
    end 
end) 

Link to comment
Try This
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
        function ( ) 
            if (source == GUIEditor_Button[1]) then 
     local theplayer = getLocalPlayer()      
     local theVehicle = getPedOccupiedVehicle 
                    setElementPosition (theplayer , 1523.9138183594, 1527.1204833984, 10.2602405548  ) 
                    setElementPosition (theVehicle , 1523.9138183594, 1527.1204833984, 10.2602405548  ) 
                    warpPedIntoVehicle ( theplayer, theVechicle )  
    end 
end) 

not work :(

Link to comment
addEventHandler ( "onClientGUIClick", resourceRoot, 
        function ( ) 
            if (source == GUIEditor_Button[1]) then    
     local theVehicle = getPedOccupiedVehicle(localPlayer) 
                    setElementPosition (localPlayer, 1523.9138183594, 1527.1204833984, 10.2602405548  ) 
                    setElementPosition (theVehicle , 1523.9138183594, 1527.1204833984, 10.2602405548  ) 
                    warpPedIntoVehicle ( localPlayer, theVehicle) 
    end 
end) 

Link to comment
addEventHandler ( "onClientGUIClick", resourceRoot, 
        function ( ) 
            if (source == GUIEditor_Button[1]) then    
     local theVehicle = getPedOccupiedVehicle(localPlayer) 
                    setElementPosition (localPlayer, 1523.9138183594, 1527.1204833984, 10.2602405548  ) 
                    setElementPosition (theVehicle , 1523.9138183594, 1527.1204833984, 10.2602405548  ) 
                    warpPedIntoVehicle ( localPlayer, theVehicle) 
    end 
end) 

this work

but when in the Vehicle

click the button

Vehicle fly and blow

why?????

Link to comment

If I'm right, you need to remove the player from the vehicle.

addEventHandler ( "onClientGUIClick", resourceRoot, 
        function ( ) 
            if (source == GUIEditor_Button[1]) then   
     local theVehicle = getPedOccupiedVehicle(localPlayer) 
     if not theVehicle then 
                    setElementPosition (localPlayer, 1523.9138183594, 1527.1204833984, 10.2602405548  ) 
                    return 
     end 
                    removePedFromVehicle ( localPlayer ) 
                    setElementPosition (theVehicle , 1523.9138183594, 1527.1204833984, 10.2602405548  ) 
                    warpPedIntoVehicle ( localPlayer, theVehicle) 
    end 
end) 

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