Jump to content

Gui Shows On EVERY Resource Start/Restart


Recommended Posts

Well The Title Says All, No Errors Here My Lua

login_Window = {} 
login_Button = {} 
login_Label = {} 
login_Edit = {} 
login_Checkbox = {} 
  
register_Window = {} 
register_Button = {} 
register_Label = {} 
register_Edit = {} 
  
login_Window[1] = guiCreateWindow(481,254,399,232,"Login By haws1290",false) 
login_Edit[1] = guiCreateEdit(45,80,310,20,"",false,login_Window[1]) 
login_Label[1] = guiCreateLabel(102,25,205,21,"Welcome To Gangster Roleplay!!!!",false,login_Window[1]) 
guiLabelSetColor(login_Label[1],255,255,255) 
guiLabelSetVerticalAlign(login_Label[1],"top") 
guiLabelSetHorizontalAlign(login_Label[1],"left",false) 
guiSetFont(login_Label[1],"clear-normal") 
login_Edit[2] = guiCreateEdit(46,129,310,20,"",false,login_Window[1]) 
login_Label[2] = guiCreateLabel(168,109,215,15,"Password",false,login_Window[1]) 
guiLabelSetColor(login_Label[2],255,255,255) 
guiLabelSetVerticalAlign(login_Label[2],"top") 
guiLabelSetHorizontalAlign(login_Label[2],"left",false) 
login_Label[3] = guiCreateLabel(165,55,148,15,"Username",false,login_Window[1]) 
guiLabelSetColor(login_Label[3],255,255,255) 
guiLabelSetVerticalAlign(login_Label[3],"top") 
guiLabelSetHorizontalAlign(login_Label[3],"left",false) 
login_Button[1] = guiCreateButton(48,161,141,28,"Login!",false,login_Window[1]) 
login_Button[2] = guiCreateButton(217,161,141,28,"Register!",false,login_Window[1]) 
login_Label[4] = guiCreateLabel(9,57,85,15,"Remember Me:",false,login_Window[1]) 
guiLabelSetColor(login_Label[4],255,255,255) 
guiLabelSetVerticalAlign(login_Label[4],"top") 
guiLabelSetHorizontalAlign(login_Label[4],"left",false) 
login_Checkbox[1] = guiCreateCheckBox(94,58,15,14,"",false,false,login_Window[1]) 
  
register_Window[1] = guiCreateWindow(481,254,399,232,"Register By haws1290",false) 
register_Edit[1] = guiCreateEdit(45,80,310,20,"",false,register_Window[1]) 
register_Label[1] = guiCreateLabel(102,25,205,21,"Welcome To Gangster Roleplay!!!!",false,register_Window[1]) 
guiLabelSetColor(register_Label[1],255,255,255) 
guiLabelSetVerticalAlign(register_Label[1],"top") 
guiLabelSetHorizontalAlign(register_Label[1],"left",false) 
guiSetFont(register_Label[1],"clear-normal") 
register_Edit[2] = guiCreateEdit(46,129,310,20,"",false,register_Window[1]) 
register_Label[2] = guiCreateLabel(168,109,215,15,"Password",false,register_Window[1]) 
guiLabelSetColor(login_Label[2],255,255,255) 
guiLabelSetVerticalAlign(login_Label[2],"top") 
guiLabelSetHorizontalAlign(login_Label[2],"left",false) 
register_Label[3] = guiCreateLabel(165,55,148,15,"Username",false,register_Window[1]) 
guiLabelSetColor(register_Label[3],255,255,255) 
guiLabelSetVerticalAlign(register_Label[3],"top") 
guiLabelSetHorizontalAlign(register_Label[3],"left",false) 
register_Button[1] = guiCreateButton(48,161,141,28,"Register!",false,register_Window[1]) 
register_Button[2] = guiCreateButton(217,161,141,28,"Cancel!",false,register_Window[1]) 
  
local datroot = getRootElement() 
local localPlayer = getLocalPlayer() 
  
addEvent("login:failed",true) 
function hideallreg() 
    guiSetVisible(register_Window[1], false) 
    guiSetVisible(login_Window[1], true) 
    guiEditSetMasked ( login_Edit[2], true ) 
    showCursor( true ) 
end 
addEventHandler("onClientResourceStart", root, hideallreg) 
addEventHandler("onClientGUIClick", register_Button[2], hideallreg) 
addEventHandler("login:failed", localPlayer, hideallreg) 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
function() 
    guiSetInputMode("no_binds_when_editing") 
end) 
  
--[[addEventHandler("onClientResourceStart", root, 
function() 
    local Remembermeh = getElementData(source, "remember") 
    local Remember = guiCheckBoxGetSelected(login_Checkbox[1], source) 
    if ( Remember ) then 
    guiSetText(login_Edit[1], getPlayerName(source)) 
    setElementData(source, "remember", remember) 
    elseif ( Remembermeh ) then 
    guiCheckBoxSetSelected(login_Checkbox, true) 
    guiSetText(login_Edit[1], getPlayerName(source)) 
    end 
end 
)]] 
  
  
function showreg() 
    guiSetVisible(register_Window[1], true) 
    guiSetVisible(login_Window[1], false) 
    showCursor( true ) 
end 
addEventHandler("onClientGUIClick", login_Button[2], showreg) 
  
addEventHandler('onClientGUIClick',register_Button[1], 
    function() 
        triggerServerEvent('account:register',localPlayer,guiGetText(register_Edit[1]), guiGetText(register_Edit[2])) 
        guiSetVisible( register_Window[1], false ) 
        guiSetVisible( login_Window[1], true ) 
        playSoundFrontEnd ( 1 ) 
    end 
) 
  
addEventHandler('onClientGUIClick',login_Button[1], 
    function() 
        triggerServerEvent('account:login',localPlayer,guiGetText(login_Edit[1]), guiGetText(login_Edit[2])) 
        guiSetVisible( register_Window[1], false ) 
        guiSetVisible( login_Window[1], false ) 
        playSoundFrontEnd ( 1 ) 
        showCursor( false ) 
    end 
) 
  
  

Link to comment
addEventHandler("onClientResourceStart", root, hideallreg) 

If you use predefined variable root like attached element to event onClientResourceStart this will triggered if any resource started.

You should use predefined variable resourceRoot.

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