Jump to content

The GUI doesn't works


bmat

Recommended Posts

Posted (edited)

Hello!

I've got a problem. I making GUI now and this GUI doesn't work good. I want to make a button, which will close the window, but this not working good.

This is code:

function Internet()
local screenWidth, screenHeight = guiGetScreenSize()
browser = guiCreateWindow(50, 50, screenWidth-100, screenHeight-100, "Please Log In", false)
guiSetVisible(browser, true)
showCursor(true)
guiSetInputEnabled(true)
guiWindowSetMovable(browser, true)
guiWindowSetSizable(browser, true)
 
go = guiCreateButton(0.7, 0.1, 0.1, 0.05, "Go!", true)
quit = guiCreateButton(0.9, 0.05, 0.03, 0.03, "x", true)
end
 
addCommandHandler("internet", Internet)
 
addEventHandler("onClientGUIClick", quit, quitInternet)
function quitInternet(button, state)
if button == "left" and state == "up" then
guiSetInputEnabled(false)
guiSetVisible(browser, false)
showCursor(false)
end
end

Please, help me.

Sorry for my bad English.

Edited by Guest
Posted

You must put the event handler after the funtion, like this

function Internet()
local screenWidth, screenHeight = guiGetScreenSize()
  browser = guiCreateWindow(50, 50, screenWidth-100, screenHeight-100, "Please Log In", false)
guiSetVisible(browser, true)
showCursor(true)
guiSetInputEnabled(true)
guiWindowSetMovable(browser, true)
guiWindowSetSizable(browser, true)
 
  go = guiCreateButton(0.7, 0.1, 0.1, 0.05, "Go!", true)
  quit = guiCreateButton(0.9, 0.05, 0.03, 0.03, "x", true)
end
 
addCommandHandler("internet", Internet)
 
function quitInternet(button, state)
if button == "left" and state == "up" then
guiSetInputEnabled(false)
guiSetVisible(browser, false)
showCursor(false)
end
end
addEventHandler("onClientGUIClick", quit, quitInternet)

oh and remember to use lua tags

 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Ok.

But this code still doesn't work.

local screenWidth, screenHeight = guiGetScreenSize()
  browser = guiCreateWindow(50, 50, screenWidth-100, screenHeight-100, "Please Log In", false)
guiSetVisible(browser,false)
guiWindowSetMovable(browser, true)
guiWindowSetSizable(browser, true)
 
go = guiCreateButton(0.7, 0.1, 0.1, 0.05, "Go!", true)
  quit = guiCreateButton(0.9, 0.05, 0.03, 0.03, "x", true)
 
function visible()
guiSetVisible(browser, true)
showCursor(true)
guiSetInputEnabled(true)
end
addCommandHandler("internet", visible)
 
function quitInternet (button, state)
if button == "left" and state == "up" then
guiSetInputEnabled(false)
guiSetVisible(browser, false)
showCursor(false)
end
end
addEventHandler("onClientGUIClick", quit, quitInternet)

I edited your code a bit

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

It works!

Thanks, but when I click a window this one is closing. I want to close window only when I click a button x. Could you help me?

Posted
It works!

Thanks, but when I click a window this one is closing. I want to close window only when I click a button x. Could you help me?

for me works like must work, i dont understand what u mean.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

change last line to:

addEventHandler("onClientGUIClick", quit, quitInternet,false)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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