Jump to content

Login button doesn't works.


brocky

Recommended Posts

My login button doesn't works.

 

 local window1 = guiCreateWindow(455, 178, 710, 532, "", false)
       guiWindowSetSizable(window1, false)
      local editUsername = guiCreateEdit(167, 108, 361, 40, "", false, window1)
      local  editPassword = guiCreateEdit(170, 197, 358, 36, "", false, window1)
        btnLogin = guiCreateButton(9, 434, 691, 43, "Login", false, window1)
        btnClose = guiCreateButton(14, 486, 686, 36, "Close", false, window1)    
        guiSetVisible(window1, true)
        showCursor(true)

function closeGui() 
if btnClose == source then
guiSetVisible(window1, false)
showCursor(false)
  end 
end 
addEventHandler("onClientGUIClick", btnClose, closeGui, false)

function logToServer()
account = guiGetText(editUsername)
password = guiGetText(editPassword)
local name = getPlayerName(getLocalPlayer())
triggerServerEvent("test", localPlayer, account, password, name)
end 
addEventHandler("onClientGUIClick", btnLogin, logToServer, false)

 

server side 

function myMoney(account, password, name)
logIn (source, account, password) 
end
addEvent("test", true)
addEventHandler("test", getRootElement(), myMoney)

 

Link to comment

Try this:

-- Client

window1 = guiCreateWindow(455, 178, 710, 532, "", false)
editUsername = guiCreateEdit(167, 108, 361, 40, "", false, window1)
editPassword = guiCreateEdit(170, 197, 358, 36, "", false, window1)
btnLogin = guiCreateButton(9, 434, 691, 43, "Login", false, window1)
btnClose = guiCreateButton(14, 486, 686, 36, "Close", false, window1)    
guiSetVisible(window1, true)
showCursor(true)
guiWindowSetSizable(window1, false)

function closeGui() 
	if btnClose == source then
		guiSetVisible(window1, false)
		showCursor(false)
  	end 
end 
addEventHandler("onClientGUIClick", root, closeGui) -- changed "root"

function logToServer()
	if (source == btnLogin) then -- Check button clicked
		local account = guiGetText(editUsername)
		local password = guiGetText(editPassword)
		local name = getPlayerName(getLocalPlayer())
		triggerServerEvent("test", localPlayer, account, password, name)
	end
end 
addEventHandler("onClientGUIClick", root, logToServer) -- changed "root"

-- Server

function myMoney(account, password, name)
	outputChatBox(name);
	logIn (source, account, password) 
end
addEvent("test", true)
addEventHandler("test", root, myMoney)

 

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