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) 

th_GTA-17.jpg
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) 

If I helped you, please click the like button on the right ;) Thanks!

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

th_GTA-17.jpg
Posted

Jaysd1, the variable "localPlayer" doesn't has to be defined anymore, the new MTA has it built-on.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

th_GTA-17.jpg
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 :(

th_GTA-17.jpg
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) 

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

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

th_GTA-17.jpg
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) 

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

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