AnDReJ98 Posted November 23, 2011 Posted November 23, 2011 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)
myonlake Posted November 23, 2011 Posted November 23, 2011 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)
AGENT_STEELMEAT Posted November 23, 2011 Posted November 23, 2011 --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.
AnDReJ98 Posted November 23, 2011 Author Posted November 23, 2011 John_Michael thanks so much i need telpoort when player in the Vehicle and also when player out the Vehicle
^Dev-PoinT^ Posted November 23, 2011 Posted November 23, 2011 use this function https://wiki.multitheftauto.com/wiki/WarpPedIntoVehicle
CapY Posted November 23, 2011 Posted November 23, 2011 how????? With a brain. warpPedIntoVehicle ( Ped, vehicle )
AnDReJ98 Posted November 23, 2011 Author Posted November 23, 2011 iam not need warp ped in vehicle i need setElementPosition telpoort when player in the Vehicle and also when player out the Vehicle
CapY Posted November 23, 2011 Posted November 23, 2011 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.)
Castillo Posted November 23, 2011 Posted November 23, 2011 (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 November 23, 2011 by Guest
AGENT_STEELMEAT Posted November 23, 2011 Posted November 23, 2011 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.
AnDReJ98 Posted November 23, 2011 Author Posted November 23, 2011 --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
Jaysds1 Posted November 24, 2011 Posted November 24, 2011 What's the error? The "localplayer" is not defined? The "GUIEditor_Button[1]" is not defined?
Castillo Posted November 24, 2011 Posted November 24, 2011 Jaysd1, the variable "localPlayer" doesn't has to be defined anymore, the new MTA has it built-on.
Jaysds1 Posted November 24, 2011 Posted November 24, 2011 ohh, I never knew that, why didn't anyone told me b4? ok, i learned something else 2day
AnDReJ98 Posted November 24, 2011 Author Posted November 24, 2011 --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
^Dev-PoinT^ Posted November 24, 2011 Posted November 24, 2011 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)
AnDReJ98 Posted November 24, 2011 Author Posted November 24, 2011 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
JR10 Posted November 24, 2011 Posted November 24, 2011 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)
AnDReJ98 Posted November 24, 2011 Author Posted November 24, 2011 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?????
JR10 Posted November 24, 2011 Posted November 24, 2011 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)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now