Jump to content

GUI help


mint3d

Recommended Posts

I have a car spawner script but when i walk into the marker no gui shows up help

    Wnd = guiCreateWindow(550,100,382,450,"Vehicle System",false) 
    guiSetAlpha( Wnd, 1 ) 
    guiWindowSetMovable(Wnd,true) 
    guiWindowSetSizable(Wnd,false) 
      
    button = guiCreateButton(36,400,110,47,"Exit",false,Wnd) 
    button2 = guiCreateButton(249,400,110,47,"Spawn",false,Wnd) 
      
    label2 = guiCreateLabel(127,47,242,15,'',false,Wnd) 
    label = guiCreateLabel(127,34,242,15,"Click on the vehicle you want",false,Wnd) 
    guiLabelSetVerticalAlign(label2,"center") 
    guiLabelSetHorizontalAlign(label2,"center",false) 
    showCursor(false) 
    guiSetVisible( Wnd, false ) 
      
        vehicles =( 
                 
               ("Infernus", 411)             
          
        grid = guiCreateGridList(36,78,300,300,false,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 use2() 
             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 
                  --takePlayerMoney (thePlayer, 1000) 
                  --takePlayerMoney (player, 1000) 
                       triggerServerEvent("CreVehice", localPlayer, model) 
                  end 
             end 
        end 
        addEventHandler("onClientGUIClick", button2, use2, false) 
         
        function close2() 
        if (source == button2) then 
        --takePlayerMoney (localPlayer, 1000) 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
        end 
        end 
        addEventHandler("onClientGUIClick", button2, close2) 
         
        
        function close() 
        if (source == button) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
        end 
        end 
        addEventHandler("onClientGUIClick", button, close) 
        
    function showGUI2(hitElement) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then  
    guiSetVisible(Wnd,true) 
    showCursor(true) 
    end 
    end 
    addEvent("showGUI2",true) 
    addEventHandler("showGUI2", getRootElement(), showGUI2) 

Link to comment
     f = createMarker( x,y,z, "cylinder", 2, 0, 100, 255, 100 ) 
  
    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 + 3, 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",t,showGUI) 
  
  
  

Link to comment

-- client side:

function showGUI2 ( ) 
    guiSetVisible ( Wnd, true ) 
    showCursor ( true ) 
end 
addEvent ( "showGUI2", true ) 
addEventHandler ( "showGUI2", getRootElement(), showGUI2 ) 

-- server side:

function showGUI ( hitPlayer ) 
    if ( getElementType ( hitPlayer ) == "player" ) then 
        triggerClientEvent ( hitPlayer, "showGUI2", hitPlayer ) 
    end 
end 
addEventHandler ( "onMarkerHit", f, showGUI ) 

P.S: Stop double-triple posting, use the "EDIT" button.

Link to comment

try this :

addEvent("showGUI2",true) 
function open() 
        guiSetVisible(Wnd, true) 
        showCursor(true) 
end 
addEventHandler("showGUI2", getRootElement(),open) 

-- Server

function showGUI2(player) 
                triggerClientEvent(player,"showGUI2", player) 
end 
addEventHandler("onMarkerHit",f,showGUI2) 
Link to comment

That's because the problem is not on that part, you have another script errors on the client side.

Wnd = guiCreateWindow(550,100,382,450,"Vehicle System",false) 
guiSetAlpha( Wnd, 1 ) 
guiWindowSetMovable(Wnd,true) 
guiWindowSetSizable(Wnd,false) 
button = guiCreateButton(36,400,110,47,"Exit",false,Wnd) 
button2 = guiCreateButton(249,400,110,47,"Spawn",false,Wnd) 
label2 = guiCreateLabel(127,47,242,15,'',false,Wnd) 
label = guiCreateLabel(127,34,242,15,"Click on the vehicle you want",false,Wnd) 
guiLabelSetVerticalAlign(label2,"center") 
guiLabelSetHorizontalAlign(label2,"center",false) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
  
vehicles = 
    { 
        { "Infernus", 411 } 
    } 
  
grid = guiCreateGridList(36,78,300,300,false,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 use2() 
    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", button2, use2, false) 
  
function close2() 
    if (source == button2) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", button2, close2) 
  
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
That's because the problem is not on that part, you have another script errors on the client side.
Wnd = guiCreateWindow(550,100,382,450,"Vehicle System",false) 
guiSetAlpha( Wnd, 1 ) 
guiWindowSetMovable(Wnd,true) 
guiWindowSetSizable(Wnd,false) 
button = guiCreateButton(36,400,110,47,"Exit",false,Wnd) 
button2 = guiCreateButton(249,400,110,47,"Spawn",false,Wnd) 
label2 = guiCreateLabel(127,47,242,15,'',false,Wnd) 
label = guiCreateLabel(127,34,242,15,"Click on the vehicle you want",false,Wnd) 
guiLabelSetVerticalAlign(label2,"center") 
guiLabelSetHorizontalAlign(label2,"center",false) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
  
vehicles = 
    { 
        { "Infernus", 411 } 
    } 
  
grid = guiCreateGridList(36,78,300,300,false,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 use2() 
    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", button2, use2, false) 
  
function close2() 
    if (source == button2) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", button2, close2) 
  
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 ) 

Line 45 and 53 , why you wrote name of the button and you already difend this.

Link to comment
That's because the problem is not on that part, you have another script errors on the client side.
Wnd = guiCreateWindow(550,100,382,450,"Vehicle System",false) 
guiSetAlpha( Wnd, 1 ) 
guiWindowSetMovable(Wnd,true) 
guiWindowSetSizable(Wnd,false) 
button = guiCreateButton(36,400,110,47,"Exit",false,Wnd) 
button2 = guiCreateButton(249,400,110,47,"Spawn",false,Wnd) 
label2 = guiCreateLabel(127,47,242,15,'',false,Wnd) 
label = guiCreateLabel(127,34,242,15,"Click on the vehicle you want",false,Wnd) 
guiLabelSetVerticalAlign(label2,"center") 
guiLabelSetHorizontalAlign(label2,"center",false) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
  
vehicles = 
    { 
        { "Infernus", 411 } 
    } 
  
grid = guiCreateGridList(36,78,300,300,false,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 use2() 
    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", button2, use2, false) 
  
function close2() 
    if (source == button2) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", button2, close2) 
  
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 ) 

Line 45 and 53 , why you wrote name of the button and you already difend this.

I didn't change how he wrote it, I just fixed the script errors.

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