AnDReJ98 Posted November 23, 2011 Share 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) Link to comment
myonlake Posted November 23, 2011 Share 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) Link to comment
AGENT_STEELMEAT Posted November 23, 2011 Share 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. Link to comment
AnDReJ98 Posted November 23, 2011 Author Share Posted November 23, 2011 John_Michael thanks so much i need telpoort when player in the Vehicle and also when player out the Vehicle Link to comment
AnDReJ98 Posted November 23, 2011 Author Share Posted November 23, 2011 not work plz someone help me Link to comment
^Dev-PoinT^ Posted November 23, 2011 Share Posted November 23, 2011 use this function https://wiki.multitheftauto.com/wiki/WarpPedIntoVehicle Link to comment
CapY Posted November 23, 2011 Share Posted November 23, 2011 how????? With a brain. warpPedIntoVehicle ( Ped, vehicle ) Link to comment
AnDReJ98 Posted November 23, 2011 Author Share 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 Link to comment
CapY Posted November 23, 2011 Share 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.) Link to comment
Castillo Posted November 23, 2011 Share 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 Link to comment
AGENT_STEELMEAT Posted November 23, 2011 Share 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. Link to comment
AnDReJ98 Posted November 23, 2011 Author Share 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 Link to comment
Jaysds1 Posted November 24, 2011 Share Posted November 24, 2011 What's the error? The "localplayer" is not defined? The "GUIEditor_Button[1]" is not defined? Link to comment
Castillo Posted November 24, 2011 Share Posted November 24, 2011 Jaysd1, the variable "localPlayer" doesn't has to be defined anymore, the new MTA has it built-on. Link to comment
Jaysds1 Posted November 24, 2011 Share Posted November 24, 2011 ohh, I never knew that, why didn't anyone told me b4? ok, i learned something else 2day Link to comment
AnDReJ98 Posted November 24, 2011 Author Share 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 Link to comment
Jaysds1 Posted November 24, 2011 Share Posted November 24, 2011 Was there any error messages? Link to comment
AnDReJ98 Posted November 24, 2011 Author Share Posted November 24, 2011 no please some one help me Link to comment
^Dev-PoinT^ Posted November 24, 2011 Share 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) Link to comment
AnDReJ98 Posted November 24, 2011 Author Share 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 Link to comment
JR10 Posted November 24, 2011 Share 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) Link to comment
AnDReJ98 Posted November 24, 2011 Author Share 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????? Link to comment
12p Posted November 24, 2011 Share Posted November 24, 2011 That's another script, dude. Link to comment
JR10 Posted November 24, 2011 Share 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) Link to comment
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