Jump to content

some problem whit gui button


bandi94

Recommended Posts

Posted

i start to make a new login panel and more whit tabs now my problem is i make this its only a part of a big client and server script

local window = guiCreateWindow(0.25,0.25,0.5,0.55,"|DGT| Clan Server",true) 
guiWindowSetSizable(window,false) 
guiWindowSetMovable(window,false) 
local tab =  guiCreateTabPanel(0,0.05,1,0.85,true,window) 
local loginregister =  guiCreateTab("Login/Register",tab) 
local rules = guiCreateTab("Rules",tab) 
local loginb = guiCreateButton ( 0.1,  0.8, 0.15, 0.15, "Login", true, loginregister ) 
local registerb = guiCreateButton ( 0.4,  0.8, 0.15, 0.15, "Register", true, loginregister ) 
guiSetProperty (loginb, "AlwaysOnTop", "true" ) 
guiSetProperty (registerb, "AlwaysOnTop", "true" ) 

and more many now my problem is i use addEventHandler ( "onClientGUIClick", loginb, sendLogin ) and many more but when i click on the window or on tab it click on all the button's on that tab and ...

(if i click ex. on the loginregister tab it will loop all the addEventHandler ( "onClientGUIClick",..., ... )

for all button's on that tab panel ) how can i fix it thx for helping

Posted

i say its only a par the full code is like 200 line i will not post the whole code ... the handler's are after each function like

 

function sendLogin() 
local usser = guiGetText(username) 
local pass = guiGetText(password) 
triggerServerEvent("login",getLocalPlayer(),usser,pass) 
  
 end 
  
  
addEventHandler ( "onClientGUIClick", loginb, sendLogin ) 

username and password are Edit fields

Posted

well some handler is probably messed up, attached to some parent element or something.

its hard to figure out anything when all you show are some random 5-line parts.

Posted
addEventHandler ( "onClientGUIClick", loginb, sendLogin, false )

every event should have 'false' like that ^

i'd just check the source element and do stuff accordingly.

Posted
local auuser 
local aupass 
local autologin =0 
local ena=0 
local window = guiCreateWindow(0.25,0.25,0.5,0.55,"|DGT| Clan Server",true) 
local tab =  guiCreateTabPanel(0,0.05,1,0.85,true,window) 
local loginregister =  guiCreateTab("Login/Register",tab) 
local rules = guiCreateTab("Rules",tab) 
local News = guiCreateTab("New,s",tab) 
local info = guiCreateTab("Info's",tab) 
local teamask = guiCreateTab("Team ask",tab) 
local tgf = guiCreateTab("TGF",tab) 
  
showCursor(true) 
  
------------login/register------------------- 
local ussertxt = guiCreateLabel (0.1,0.3,1,1,"Ussername :",true, loginregister) 
local passtxt = guiCreateLabel (0.1,0.5,1,1,"Passworld :",true, loginregister) 
local ussername = guiCreateEdit(0.25,0.29,0.2,0.07,"",true, loginregister) 
local passworld =  guiCreateEdit(0.25,0.49,0.2,0.07,"",true, loginregister) 
local loginb = guiCreateButton ( 0.1,  0.8, 0.15, 0.15, "Login", true, loginregister ) 
local registerb = guiCreateButton ( 0.4,  0.8, 0.15, 0.15, "Register", true, loginregister ) 
local guest = guiCreateButton ( 0.7,  0.8, 0.16, 0.15, "Play as Guest", true, loginregister ) 
local enableauto = guiCreateButton ( 0.7,  0.3, 0.15, 0.15, "Enable ", true, loginregister ) 
local disableauto = guiCreateButton ( 0.7,  0.5, 0.15, 0.15, "Disable ", true, loginregister ) 
local result = guiCreateWindow ( 0.4, 0.5, 0.3, 0.15, "Information", true ) 
local close=   guiCreateButton ( 0.4,  0.95, 0.15, 0.15, "Close ", true,window) 
local resultb=   guiCreateButton ( 0.4,  0.7, 0.15, 0.15, "OK ", true,result) 
local resulttxt=guiCreateLabel (0.1,0.4,1,1,"",true, result) 
guiSetProperty (ussername, "AlwaysOnTop", "true" ) 
guiSetProperty (passworld, "AlwaysOnTop", "true" ) 
guiSetProperty (guest, "AlwaysOnTop", "true" ) 
guiSetProperty (enableauto, "AlwaysOnTop", "true" ) 
guiSetProperty (disableauto, "AlwaysOnTop", "true" ) 
guiSetProperty (loginb, "AlwaysOnTop", "true" ) 
guiSetProperty (registerb, "AlwaysOnTop", "true" ) 
guiSetVisible (result,false) 
guiSetProperty (result, "AlwaysOnTop", "true" ) 
guiSetProperty (resultb, "AlwaysOnTop", "true" ) 
guiWindowSetSizable(window,false) 
guiWindowSetMovable(window,false) 
guiSetProperty (close, "AlwaysOnTop", "true" ) 
  
  
------------------Rules------------------------------------ 
local r =  guiCreateMemo(0.05,0.05,0.9,0.9,"",true,rules) 
 guiMemoSetReadOnly(r,true) 
  
--------------------New's------------------------------------- 
  
local n=  guiCreateMemo(0.05,0.05,0.9,0.9,"",true,News) 
 guiMemoSetReadOnly(n,true) 
  
------------------Info's-------------------------------------- 
  
local i =  guiCreateMemo(0.05,0.05,0.9,0.9,"",true,info) 
 guiMemoSetReadOnly(i,true) 
  
------------Team ask ------------------------------------------ 
  
local name =  guiCreateEdit(0.25,0.192,0.25,0.07,"",true, teamask) 
local tag =  guiCreateEdit(0.25,0.292,0.25,0.07,"",true, teamask) 
local color = guiCreateEdit(0.38,0.392,0.25,0.07,"",true, teamask) 
local oldname =  guiCreateEdit(0.3,0.492,0.25,0.07,"",true, teamask) 
local newname =  guiCreateEdit(0.32,0.592,0.25,0.07,"",true, teamask) 
local newtag =  guiCreateEdit(0.3,0.692,0.25,0.07,"",true, teamask) 
local newcolor =  guiCreateEdit(0.43,0.792,0.25,0.07,"",true, teamask) 
  
  
local askrule  = guiCreateLabel (0.03,0.03,1,1,"If you use this system for Insulting or Spam you will be banned from this system ! ",true, teamask) 
local nametxt =  guiCreateLabel (0.1,0.2,1,1,"Team Name :",true,teamask) 
local tagtxt =  guiCreateLabel (0.1,0.3,1,1,"Team Tag :",true, teamask) 
local colortxt =  guiCreateLabel (0.1,0.4,1,1,"Team Color Code (hex) :",true, teamask) 
local oldnametxt =  guiCreateLabel (0.1,0.5,1,1,"Team old Name :",true, teamask) 
local newnametxt =  guiCreateLabel (0.1,0.6,1,1,"Team new name  :",true, teamask) 
local newtagtxt =  guiCreateLabel (0.1,0.7,1,1,"Team new Tag :",true, teamask) 
local newcolortxt =  guiCreateLabel (0.1,0.8,1,1,"Team new Color code (hex):",true, teamask) 
  
local newteam = guiCreateCheckBox (  0.8,  0.3,  0.3,  0.1, "New Team", false, true, teamask) 
local modification = guiCreateCheckBox (  0.8,  0.5,  0.3,  0.1, "Modification", false, true, teamask ) 
local send =  guiCreateButton ( 0.8,  0.8, 0.15, 0.15, "Send", true,  teamask ) 
  
  
  
-------------TGF--------------- 
local tgfb =  guiCreateButton ( 0.4,  0.7, 0.16, 0.15, "Jelentkezem!", true, tgf) 
local tgfinfo = guiCreateMemo(0.01,0.01,0.99,0.3,"",true,tgf) 
local tgfszam = guiCreateLabel (0.4,0.5,1,1,"TGF hely :",true, tgf) 
  
-----------------Login script--------------------------------- 
function sendLogin() 
local usser = guiGetText(ussername) 
local pass = guiGetText(passworld) 
triggerServerEvent("login",getLocalPlayer(),usser,pass) 
outputChatBox("ok") 
 end 
addEventHandler ( "onClientGUIClick", loginb, sendLogin ) 
  
function resultLogin(msg) 
guiSetText(resulttxt,msg) 
guiSetVisible(result,true) 
end 
addEvent("loginresult",true) 
addEventHandler("loginresult",getRootElement(),resultLogin) 

this is the Login button and login function part now i tested and if i click ex on the loginregister tab panel it out put chat box "ok"(like if i clicked on the buton but i don't cilck on the button )

Posted

stop event propagation (as mentioned by BinSlayer1), or check the source in your handler function(s) (i do that to get away with single click handler function for all elements).

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