Jump to content

A little help in GUI buttons.


Bilal135

Recommended Posts

Posted
for close button use guisetvisible.

I'm not quite sure how it would be, and how to use the onClientGUIClick to make this work, that's where I am confused.

Posted
for close button use guisetvisible.

I'm not quite sure how it would be, and how to use the onClientGUIClick to make this work, that's where I am confused.

Try to use defined variables for windows, buttons , etc

Posted

Client :

  
local root = getRootElement() 
local this = getThisResource() 
local resourceRoot = getResourceRootElement(this) 
local localPlayer = getLocalPlayer() 
local Marker = {} 
  
 GUIEditor = { 
    button = {}, 
    window = {}, 
    label = {} 
} 
-- Resource Start 
addEventHandler("onClientResourceStart", resourceRoot, 
function() 
createObject(1271, 201.85633850098, 1858.2962646484, 12.50, 0, 0, 0, false) 
Marker[1] = createMarker(202.94039916992, 1858.2836914063, 12.25,"cylinder", 1, 255, 255, 255) 
GUIEditor.window[1] = guiCreateWindow(567, 296, 151, 181, "Pickup Menu", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
GUIEditor.label[1] = guiCreateLabel(17, 32, 77, 15, "Weapon: M4", false, GUIEditor.window[1]) 
guiSetFont(GUIEditor.label[1], "default-bold-small") 
GUIEditor.label[2] = guiCreateLabel(16, 55, 113, 15, "Ammo: 1000 bullets", false, GUIEditor.window[1]) 
guiSetFont(GUIEditor.label[2], "default-bold-small") 
GUIEditor.button[1] = guiCreateButton(15, 81, 114, 34, "Pick Up", false, GUIEditor.window[1]) 
GUIEditor.button[2] = guiCreateButton(17, 127, 112, 32, "Close Menu", false, GUIEditor.window[1]) 
guiSetVisible (GUIEditor.window[1],false)    
end 
) 
-- Marker Hit 
addEventHandler("onClientMarkerHit", root, 
function(player, matchingDimension) 
if not matchingDimension then return end 
if player == localPlayer then 
if source == Marker[1] then  
guiSetVisible (GUIEditor.window[1],true) 
showCursor(true) 
            end 
        end 
    end 
) 
  
-- Gui Click 
function onGuiClick ()  
if (source == GUIEditor.button[2]) then -- Close Button 
guiSetVisible (GUIEditor.window[1],false) 
showCursor ( false )  
elseif (source == GUIEditor.button[1]) then -- Pick Up Button 
-- Here 
-- like  triggerServerEvent ( "eventName", getLocalPlayer()) 
end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), onGuiClick) 
  
-- Command Close 
function closeWindow () 
if ( guiGetVisible ( GUIEditor.window[1]) == true )then 
guiSetVisible(GUIEditor.window[1], false) 
showCursor ( false )  
end 
end 
addCommandHandler ( "close", closeWindow ) 
  

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