Jump to content

doubleClick to buttonClick


-misterX-

Recommended Posts

how do i convert this from double click to on button click? i have already created the button "accept"

client

Wnd = guiCreateWindow ( 0.2, 0.2, 0.25, 0.5, "Free Vehicles", true ) 
guiSetAlpha( Wnd, 1 ) 
button = guiCreateButton ( 0.5, 0.8, 0.45, 0.15, "Close", true, Wnd ) 
button1 = guiCreateButton ( 0.01, 0.8, 0.45, 0.15, "Accept", true, Wnd ) 
label = guiCreateLabel ( 0.1, 0.1, 0.9, 0.1, "Double Click Vehicle to take it.", true, Wnd ) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
guiWindowSetSizable( Wnd, false ) 
guiWindowSetMovable( Wnd, false ) 
  
    vehicles = 
            { 
            {"BMX", 481}, 
            {"Bike", 509}, 
            {"Mountain Bike", 510}, 
            {"Faggio", 462}, 
            } 
      
    grid = guiCreateGridList(0.01, 0.2, 0.99, 0.5, true, Wnd) 
    guiGridListAddColumn(grid, "Vehicles", 0.85) 
      
    for i,veh in ipairs(vehicles) do 
         row = guiGridListAddRow(grid) 
         -- 
         guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) 
         guiGridListSetItemData(grid, row, 1, tostring(veh[2])) 
    end 
      
    function use() 
         local row, col = guiGridListGetSelectedItem(grid)   
         if (row and col and row ~= -1 and col ~= -1) then 
              local model = tonumber(guiGridListGetItemData(grid, row, 1)) 
              if model ~= "" then 
                   triggerServerEvent("CreVehice", localPlayer, model) 
              end 
         end 
    end 
    addEventHandler("onClientDoubleClick", root, use, false) 
     
    function close() 
    if (source == button) then 
    guiSetVisible(Wnd,false) 
    showCursor(false) 
    end 
    end 
    addEventHandler("onClientGUIClick", button, close) 
     
function showGUI2() 
guiSetVisible(Wnd,true) 
showCursor(true) 
end 
addEvent("showGUI2",true) 
addEventHandler("showGUI2", getRootElement(), showGUI2) 

server

    marker = createMarker( -2639.0168457031, 635.59753417969, 13, "cylinder", 2, 255, 255, 255, 255 ) 
    marker2 = createMarker( -1636.9022216797, 672.30364990234, 6, "cylinder", 2, 255, 255, 255, 255 ) 
    marker3 = createMarker( 1187.6276855469, -1308.4471435547, 12, "cylinder", 2, 255, 255, 255, 255 ) 
    marker4 = createMarker( 1537.5406494141, -1684.6533203125, 12, "cylinder", 2, 255, 255, 255, 255 ) 
    marker5 = createMarker( 2014.55078125, -1431.0400390625, 12, "cylinder", 2, 255, 255, 255, 255 ) 
    marker6 = createMarker( 1592.2445068359, 1820.3737792969, 9, "cylinder", 2, 255, 255, 255, 255 ) 
     
    local vehicles = {} 
      
    function spawnVeh(id) 
        local x, y, z = getElementPosition(source) 
        if isElement(vehicles[source]) then destroyElement(vehicles[source]) end 
        vehicles[source] = createVehicle(id, x + 1, y, z) 
        warpPedIntoVehicle(source, vehicles[source]) 
    end 
    addEvent("CreVehice",true) 
    addEventHandler("CreVehice", root, spawnVeh) 
      
    addEventHandler("onPlayerQuit", root, 
    function() 
         if isElement(vehicles[source]) then 
              destroyElement(vehicles[source]) 
              vehicles[source] = nil 
         end 
    end) 
     
    function showGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",marker,showGUI) 
  
    function showGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",marker2,showGUI) 
  
    function showGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",marker3,showGUI) 
  
    function showGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",marker4,showGUI) 
  
    function showGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",marker5,showGUI) 
  
    function showGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",marker6,showGUI) 

Link to comment
Wnd = guiCreateWindow ( 0.2, 0.2, 0.25, 0.5, "Free Vehicles", true ) 
guiSetAlpha( Wnd, 1 ) 
button = guiCreateButton ( 0.5, 0.8, 0.45, 0.15, "Close", true, Wnd ) 
button1 = guiCreateButton ( 0.01, 0.8, 0.45, 0.15, "Accept", true, Wnd ) 
label = guiCreateLabel ( 0.1, 0.1, 0.9, 0.1, "Double Click Vehicle to take it.", true, Wnd ) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
guiWindowSetSizable( Wnd, false ) 
guiWindowSetMovable( Wnd, false ) 
  
    vehicles = 
            { 
            {"BMX", 481}, 
            {"Bike", 509}, 
            {"Mountain Bike", 510}, 
            {":O", 462}, 
            } 
      
    grid = guiCreateGridList(0.01, 0.2, 0.99, 0.5, true, Wnd) 
    guiGridListAddColumn(grid, "Vehicles", 0.85) 
      
    for i,veh in ipairs(vehicles) do 
         row = guiGridListAddRow(grid) 
         -- 
         guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) 
         guiGridListSetItemData(grid, row, 1, tostring(veh[2])) 
    end 
      
function use() 
    local row, col = guiGridListGetSelectedItem(grid)   
    if (row and col and row ~= -1 and col ~= -1) then 
        local model = tonumber(guiGridListGetItemData(grid, row, 1)) 
        if model ~= "" then 
            triggerServerEvent("CreVehice", localPlayer, model) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", button1, use, false) 
  
function close() 
    if (source == button) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", button, close) 
    
function showGUI2() 
    guiSetVisible(Wnd,true) 
    showCursor(true) 
end 
addEvent("showGUI2",true) 
addEventHandler("showGUI2", getRootElement(), showGUI2) 

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