Jump to content

GUI button not clicking


Zonex Favel

Recommended Posts

Posted

Hello Everyone,

I'm having trouble making my buttons click and work. Here's the code:

  
local logWin = guiCreateWindow(0.3,0.3,0.25,0.2,"Log On", true) 
local username = guiCreateEdit(0.35,0.3,0.55,0.15,"",true,logWin) 
local password = guiCreateEdit(0.35,0.5,0.55,0.15,"",true,logWin) 
local logButton = guiCreateButton(0.05,0.7,0.25,0.2,"Sign In",true,logWin) 
local regButton = guiCreateButton(0.7, 0.7,0.25,0.2,"Register",true,logWin) 
  
function loginScreen() 
    guiCreateLabel(0.05,0.3,0.3,0.2,"Username:",true,logWin) 
    guiCreateLabel(0.05,0.5,0.3,0.2,"Password:",true,logWin) 
end 
  
addEventHandler("onClientResourceStart",getRootElement(),loginScreen) 
  
function sendLogInfo() 
    local usrname = guiGetText(username) 
    local pass = guiGetText(password) 
    triggerServerEvent("login",getRootElement(), usrname, pass) 
end 
  
addEventHandler("onClientGUIClick", logButton, sendLogInfo) 
  
function registerWin() 
    outputChatBox("Need register GUI") 
end 
  
addEventHandler("onClientGUIClick", regButton, registerWin) 
  

I put all of the GUI outside of the login screen function because I thought that was the problem, it's easy to move back in if I have to. They show either way though. Thanks for the advise in advance.

Posted

Looks like it should work to me. Add some debug output around and see if your events are called. The gui stuff should all be created inside the onClientResourceStart event.

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