Jump to content

help me in Telports scripts


AnDReJ98

Recommended Posts

Posted

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) 

Posted

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) 

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

Posted
iam not need warp ped in vehicle

i need setElementPosition

telpoort

when player in the Vehicle

and also when player out the Vehicle

I don't understand you. (Google translator sucks too hard for you.)

Posted (edited)
--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
Posted

I left an error in on purpose just to see if you'd use common sense and fix it. Had you looked at debugscript, you would have noticed that addEventHandler("onClientGUIClick", GUIEditor_Button[1], end) would not work - as 'end' is not even a function. If you cant figure that out, you need to quit scripting.

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

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

Posted

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) 

Posted
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 :(

Posted
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) 

Posted
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?????

Posted

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) 

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