Jump to content

help with getElementPosition


MajdMTA

Recommended Posts

Help me guys, with this function

  
function buttonPick(vehicle) 
        local x, y, z = getElementPosition(localPlayer) 
        local vehicleZoneName = getZoneName ( x, y, z ) 
         guiSetText(zonexad, "Veh Zone: "..vehicleZoneName) 
          
    end 
end 

I wanna it getting zone for vehicle, I tried to remove (LocalPlayer) It won't work.

Link to comment
function buttonPick(vehicle) 
    if not vehicle then return end 
    local x, y, z = getElementPosition(vehicle) 
    local vehicleZoneName = getZoneName(x, y, z) 
    guiSetText(zonexad, "Veh Zone: "..tostring(vehicleZoneName))         
end 

It's bugged, and it's saying in the text "false"

Link to comment
function buttonPickup(theVehicle) 
    if isElement(theVehicle) and getElementType(theVehicle) == "vehicle" then 
       local x, y, z = getElementPosition(theVehicle) 
       local vehicleZoneName = getZoneName(x, y, z) 
       guiSetText(zonexad, "Veh Zone: ", vehicleZoneName) 
    end 
end 

Link to comment
function buttonPickup(theVehicle) 
    if isElement(theVehicle) and getElementType(theVehicle) == "vehicle" then 
       local x, y, z = getElementPosition(theVehicle) 
       local vehicleZoneName = getZoneName(x, y, z) 
       guiSetText(zonexad, "Veh Zone: ", vehicleZoneName) 
    end 
end 

Didn't work, look at the full function

function buttonPick(theVehicle) 
    if (source == Button_VS_sn) then 
    if isElement(theVehicle) and getElementType(theVehicle) == "vehicle" then 
       local x, y, z = getElementPosition(theVehicle) 
       local vehicleZoneName = getZoneName(x, y, z) 
         guiSetText(Label_Zone, "", vehicleZoneName) 
         end      
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, buttonPick) 

@Dimos7

Link to comment
function buttonPick() 
    if (source == Button_VS_sn) then 
    local v = getPedOccupiedVehicle(localPlayer) 
    if v then 
       local x, y, z = getElementPosition(v) 
       local vehicleZoneName = getZoneName(x, y, z) 
         guiSetText(Label_Zone, "", tostring(vehicleZoneName)) 
         end      
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, buttonPick) 

Link to comment
function buttonPick() 
    if (source == Button_VS_sn) then 
    local v = getPedOccupiedVehicle(localPlayer) 
    if v then 
       local x, y, z = getElementPosition(v) 
       local vehicleZoneName = getZoneName(x, y, z) 
         guiSetText(Label_Zone, "", tostring(vehicleZoneName)) 
         end      
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, buttonPick) 

Didn't work, only works with getElementPosition, for player not for vehicle, cause it hidden.

Link to comment
function buttonPick(v) 
    if button == "left" and state == "down" then 
       if source == Button_VS_sn then 
          if isElement(v) and getElementType(v) == "vehicle" then 
             local x, y, z = getElementPosition(v) 
             local vehicleZoneName = getZoneName(x, y, z) 
             guiSetText(label_Zone, "", tostring(vehicleZoneName)) 
           end 
        end 
    end 
end 
addEventHandler("onClientGUIClick", root, buttonPick) 

Link to comment
It's like you go to the bathroom and expect a apple in your hand.

If you want that apple, you have to get it from the store or from the kitchen if you already bought it.

How do you expect to get vehicle by clicking on a GUI?

I told that to him multiple of time I hope he can understand that.

Link to comment
  
function buttonPick() 
     if (source == Button_VS_sn) then 
          if isPedInVehicle (localPlayer) then 
                local Vehicle =   getPedOccupiedVehicle (localPlayer) 
                local x, y, z = getElementPosition(Vehicle) 
                local vehicleZoneName = getZoneName ( x, y, z ) 
               guiSetText(zonexad, "Veh Zone: "..vehicleZoneName) 
          end 
    end 
end 
  

Link to comment
  
function buttonPick() 
     if (source == Button_VS_sn) then 
          if isPedInVehicle (localPlayer) then 
                local Vehicle =   getPedOccupiedVehicle (localPlayer) 
                local x, y, z = getElementPosition(Vehicle) 
                local vehicleZoneName = getZoneName ( x, y, z ) 
               guiSetText(zonexad, "Veh Zone: "..vehicleZoneName) 
          end 
    end 
end 
  

Didn't work, thanks for your hard work guys.

Link to comment

Did you put event handler? Does button even exist? Show us full code if this doesn't work:

function buttonPick() 
     if (source == Button_VS_sn) then 
          if isPedInVehicle (localPlayer) then 
                local Vehicle =   getPedOccupiedVehicle (localPlayer) 
                local x, y, z = getElementPosition(Vehicle) 
                local vehicleZoneName = getZoneName ( x, y, z ) 
               guiSetText(zonexad, "Veh Zone: "..vehicleZoneName) 
          end 
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, buttonPick) 

Link to comment
Did you put event handler? Does button even exist? Show us full code if this doesn't work:
function buttonPick() 
     if (source == Button_VS_sn) then 
          if isPedInVehicle (localPlayer) then 
                local Vehicle =   getPedOccupiedVehicle (localPlayer) 
                local x, y, z = getElementPosition(Vehicle) 
                local vehicleZoneName = getZoneName ( x, y, z ) 
               guiSetText(zonexad, "Veh Zone: "..vehicleZoneName) 
          end 
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, buttonPick) 

Yes, sure ido, I put the Event Handler

Link to comment
"Show us full code"

We don't even know what you want to do.

Which vehicle? Which GUI?

Show the full code or give more informations!

I'll give you more informations.... This is zone for my F2 vehicles system script, I do it when you press "Pick" Button the vehicle zone (City) will be seen instead of Label_Zone Label..

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