Jump to content

[HELP]Basic GUI


Recommended Posts

Posted

Hello Community,

I tried to make a GUI which is visible on the command /heal and dissapears on the command /heal too.

CLIENT:

function createHealWindow() 
    local X = 0.375 
    local Y = 0.375 
    local Width = 0.25 
    local Height = 0.25 
    heal = guiCreateWindow(X, Y, Width, Height, "Heal yourself", true) 
    guiSetVisible ( heal, 0 ) 
end 
  
function changeVisibility ( ) 
    guiSetVisible (heal, not guiGetVisible ( heal ) ) 
end 
  
addCommandHandler("heal", changeVisibility) 

Posted
local X = 0.375 
local Y = 0.375 
local Width = 0.25 
local Height = 0.25 
heal = guiCreateWindow(X, Y, Width, Height, "Heal yourself", true) 
guiSetVisible ( heal, false ) 
  
function changeVisibility ( ) 
    guiSetVisible (heal, not guiGetVisible ( heal ) ) 
    showCursor (guiGetVisible(heal)) 
end 
addCommandHandler("heal", changeVisibility) 

Posted (edited)

Okay can you tell what I did wrong so I can learn something about my mistake

+Why the f*ck you say Signature Thief too me! Everyone can take it :redhotevil:

There is no Copyright on it so it's no theft.

++ I've reported that Document too Google as Insulting and took a screenshot

Edited by Guest
Posted

in this

guiSetVisible ( element guiElement, bool state ) 

it has guiElement and the state, you wrote 0 for state.. it must be true/false ..

and you have created the gui in a function and that function is not being called, in this case it is not necessary to put in a function cuz its not visible

Posted
in this
guiSetVisible ( element guiElement, bool state ) 

it has guiElement and the state, you wrote 0 for state.. it must be true/false ..

and you have created the gui in a function and that function is not being called, in this case it is not necessary to put in a function cuz its not visible

Thank you very much for explaining that

Posted

Okay another Question:

I've added the last part (yes as text not code) but how can I attach the button to the right upper corner of the GUI?

Like on a Windows Program the left upper red "X" to close the Program (GUI)

The button (button) needs to be in the middle. 50% up-down 50% left-right

local X = 0.375 
local Y = 0.375 
local Width = 0.25 
local Height = 0.25 
heal = guiCreateWindow(X, Y, Width, Height, "Heal yourself", true) 
button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Heal!", true ) 
guiSetVisible ( heal, false ) 
  
function changeVisibility ( ) 
    guiSetVisible (heal, not guiGetVisible ( heal ) ) 
    showCursor (guiGetVisible(heal)) 
end 
  
addCommandHandler("heal", changeVisibility) 
triggerServerEvent ( "onClientGUIClick", button, heal)  
  
--[[ Close Button Test 
  
x = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true ) 
  
function closeGui ( ) 
    guiSetVisible (heal, not guiGetVisible ( heal ) ) 
    showCursor (guiGetVisible(heal)) 
end 
  
addEventHandler ("onClientGUIClick",x,closeGui,false) 
--]] 

Posted

Is this correct?

local X = 0.375 
local Y = 0.375 
local Width = 0.25 
local Height = 0.25 
heal = guiCreateWindow(X, Y, Width, Height, "Heal yourself", true) 
button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Heal!", true, heal ) 
x = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "x", true, heal ) 
guiSetVisible ( heal, false ) 
  
function changeVisibility ( ) 
    guiSetVisible (heal, not guiGetVisible ( heal ) ) 
    showCursor (guiGetVisible(heal)) 
end 
  
addCommandHandler("heal", changeVisibility) 
triggerServerEvent ( "onClientGUIClick", button, heal) 
  
function closeGui ( ) 
    guiSetVisible (heal, not guiGetVisible ( heal ) ) 
    showCursor (guiGetVisible(heal)) 
end 
  
addEventHandler ("onClientGUIClick",x,closeGui,false) 

Posted

No, it doesn't, you are triggering that event just when script starts, using the button element as "theElement" and sending the window element, explain me how does it make sense.

  • Moderators
Posted

for your question from skype.

local sWidth,sHeight = guiGetScreenSize() 
local halveSWidth   = sWidth    /   2 
local halveSHeight  = sHeight   /   2 
  
-- your gui size and position. 
local guiSizeX,guiSizeY = sWidth *.25,sHeight *.25 
local guiPosStartX = halveSWidth    -   (guiSizeX/2) 
local guiPosStartY = halveSHeight   -   (guiSizeY/2) 

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