Jump to content

BadArgument at @addeventhandler


Recommended Posts

Here is the debug log screen shot

http://i.imgur.com/yBbuKJf.png

function Information (button) 
MainWindow = guiCreateWindow ( 0.2, 0.20, 0.55, 0.5, "Information", true ) --Main Window 
MainCloseButton = guiCreateButton(0.6747, 0.1599, 0.075, 0.04, "CLOSE", true) 
local TabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, MainWindow )  
local RuleTab = guiCreateTab( "Rules", TabPanel ) 
local CommandTab = guiCreateTab( "Commands", TabPanel )  
guiCreateMemo(15,10,1000,420,"Deatmatching is'nt allowed! \nbla bla bla!",false,RuleTab) --Main/Rules Window Text 
guiCreateMemo(15,10,1000,420,"This part was too long so I dont put this part to the forum.",false,CommandTab) --Commands Window Text 
end 
addCommandHandler ("info",Information) 
addEventHandler ( "onClientGUIClick", MainCloseButton, CloseButton, false ) --run closebuyon function 
function CloseButton (button)  
guiSetVisible(MainWindow, false)--close the mainwindow gui 
end 

Link to comment

Just a matter of ordering your stuff. Creating your windows should be done only once; not attached to any function at all. When you need them (typing the command), you use that guiSetVisible function to make the window appear. And when you click the button, you make it disappear.

tl;dr this should work

btw, why isn't MainCloseButton attached to MainWindow?

local MainWindow = guiCreateWindow(0.2, 0.20, 0.55, 0.5, "Information", true) 
local MainCloseButton = guiCreateButton(0.6747, 0.1599, 0.075, 0.04, "CLOSE", true) 
local TabPanel = guiCreateTabPanel(0, 0.1, 1, 1, true, MainWindow)  
local RuleTab = guiCreateTab("Rules", TabPanel) 
local CommandTab = guiCreateTab("Commands", TabPanel)  
guiCreateMemo(15, 10, 1000, 420, "Deatmatching is'nt allowed! \nbla bla bla!", false, RuleTab) --Main/Rules Window Text 
guiCreateMemo(15, 10, 1000, 420, "This part was too long so I dont put this part to the forum.", false, CommandTab)  
guiSetVisible(MainWindow, false) 
  
  
function CloseButton ()  
   guiSetVisible(MainWindow, false) 
end 
addEventHandler("onClientGUIClick", MainCloseButton, CloseButton, false) 
  
function Information() 
   guiSetVisible(MainWindow, true) 
end 
addCommandHandler ("info", Information) 

Link to comment

For your question:

I tried to attach button to the windows but it get dissepeated.

local MainCloseButton = guiCreateButton(0.6747, 0.1599, 0.075, 0.04, "CLOSE", true,MainWindow) 

I tried to attach it as same as I saw in the wiki but it get dissepeared all the time without any debug errors.

thank you for your help, if you can tell me whats wrong with the button I will really appreciate it.

Link to comment

--Client

local MainWindow = guiCreateWindow(0.2, 0.20, 0.55, 0.5, "Information", true) 
local MainCloseButton = guiCreateButton(0.6747, 0.1599, 0.075, 0.04, "CLOSE", true, MainWindow) 
local TabPanel = guiCreateTabPanel(0, 0.1, 1, 1, true, MainWindow) 
local RuleTab = guiCreateTab("Rules", TabPanel) 
local CommandTab = guiCreateTab("Commands", TabPanel) 
guiCreateMemo(15, 10, 1000, 420, "Deatmatching is'nt allowed! \nbla bla bla!", false, RuleTab) --Main/Rules Window Text 
guiCreateMemo(15, 10, 1000, 420, "This part was too long so I dont put this part to the forum.", false, CommandTab) 
guiSetVisible(MainWindow, false) 
  
addEventHandler ( 'onClientGUIClick', resourceRoot, 
function ( )  
if (  source == MainCloseButton ) then 
guiSetVisible(MainWindow, false) 
  end 
 end 
) 
  
addCommandHandler ('info', 
function ( ) 
   if ( guiGetVisible ( MainWindow  == true )) then 
   guiSetVisible(MainWindow, false) 
   showCursor ( false )  
   else 
   guiSetVisible(MainWindow, true) 
   showCursor ( true ) 
  end 
end 
) 
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...