Jump to content

help with getElementPosition


MajdMTA

Recommended Posts

Posted

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.

Posted
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 

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

Posted (edited)
vehicle still not defined in your code, did you create a vehicle or you just using this parameter for no reason?
Edited by Guest
Posted
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 

Posted
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

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

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

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

Posted

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?

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

Posted
  
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 
  

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

Posted

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) 

Posted
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

Posted

"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!

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

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