LiOneLMeSsIShoT Posted November 22, 2013 Share Posted November 22, 2013 I'm Tried to close window on Button Click but it Gives me bad Argument..see Client: CloseButton = guiCreateButton(432, 298, 108, 43, "Close", false, GUIEditor.staticimage[1]) guiSetProperty(CloseButton, "NormalTextColour", "FFEF0000") function CloseShop() if guiGetVisible (GUIEditor.Window[1]) then guiSetVisible (GuiEditor.Window[1], false) showCursor (false) end end addEventHandler ("onClientGUIClick", CloseButton, CloseShop) Error: :84: Bad Argument @ 'addEventHandler' [Expected Element at argument 2, got nil] Link to comment
TAPL Posted November 22, 2013 Share Posted November 22, 2013 If your code looks like: function CloseShop() if guiGetVisible (GUIEditor.Window[1]) then guiSetVisible (GuiEditor.Window[1], false) showCursor (false) end end addEventHandler ("onClientGUIClick", CloseButton, CloseShop) CloseButton = guiCreateButton(432, 298, 108, 43, "Close", false, GUIEditor.staticimage[1]) guiSetProperty(CloseButton, "NormalTextColour", "FFEF0000") Then it will show the error bad argument. So you have to correct it like this: CloseButton = guiCreateButton(432, 298, 108, 43, "Close", false, GUIEditor.staticimage[1]) guiSetProperty(CloseButton, "NormalTextColour", "FFEF0000") function CloseShop() if guiGetVisible (GUIEditor.Window[1]) then guiSetVisible (GuiEditor.Window[1], false) showCursor (false) end end addEventHandler ("onClientGUIClick", CloseButton, CloseShop) Link to comment
LiOneLMeSsIShoT Posted November 22, 2013 Author Share Posted November 22, 2013 If your code looks like: function CloseShop() if guiGetVisible (GUIEditor.Window[1]) then guiSetVisible (GuiEditor.Window[1], false) showCursor (false) end end addEventHandler ("onClientGUIClick", CloseButton, CloseShop) CloseButton = guiCreateButton(432, 298, 108, 43, "Close", false, GUIEditor.staticimage[1]) guiSetProperty(CloseButton, "NormalTextColour", "FFEF0000") Then it will show the error bad argument. So you have to correct it like this: CloseButton = guiCreateButton(432, 298, 108, 43, "Close", false, GUIEditor.staticimage[1]) guiSetProperty(CloseButton, "NormalTextColour", "FFEF0000") function CloseShop() if guiGetVisible (GUIEditor.Window[1]) then guiSetVisible (GuiEditor.Window[1], false) showCursor (false) end end addEventHandler ("onClientGUIClick", CloseButton, CloseShop) Actually not like how you said...It's: CloseButton = guiCreateButton(432, 298, 108, 43, "Close", false, GUIEditor.staticimage[1]) guiSetProperty(CloseButton, "NormalTextColour", "FFEF0000") end ) function Marker() guiSetVisible (GUIEditor.window[1],true) showCursor ( true ) end addEvent ("Marker", true) addEventHandler ("Marker", getRootElement(), Marker) function CloseShop() if guiGetVisible (GUIEditor.Window[1]) then guiSetVisible (GuiEditor.Window[1], false) showCursor (false) end end addEventHandler ("onClientGUIClick", CloseButton, CloseShop) Link to comment
TAPL Posted November 22, 2013 Share Posted November 22, 2013 oh i got it, you used event onClientResourceStart for create the gui window, button.. Move this line and put it inside event onClientResourceStart below the guiCreateButton. addEventHandler ("onClientGUIClick", CloseButton, CloseShop) Link to comment
LiOneLMeSsIShoT Posted November 22, 2013 Author Share Posted November 22, 2013 oh i got it, you used event onClientResourceStart for create the gui window, button..Move this line and put it inside event onClientResourceStart below the guiCreateButton. addEventHandler ("onClientGUIClick", CloseButton, CloseShop) Alright i did it: CloseButton = guiCreateButton(432, 298, 108, 43, "Close", false, GUIEditor.staticimage[1]) guiSetProperty(CloseButton, "NormalTextColour", "FFEF0000") addEventHandler ("onClientGUIClick", CloseButton, CloseShop) end ) function Marker() guiSetVisible (GUIEditor.window[1],true) showCursor ( true ) end addEvent ("Marker", true) addEventHandler ("Marker", getRootElement(), Marker) function CloseShop() if guiGetVisible (GUIEditor.Window[1]) then guiSetVisible (GuiEditor.Window[1], false) showCursor (false) end and Error now is: :80: attempt to index field 'window' (a nil value) and :80: is if guiGetVisible (GUIEditor.Window[1]) then Link to comment
LiOneLMeSsIShoT Posted November 22, 2013 Author Share Posted November 22, 2013 Window ~> window Thanks..work but i got another problem....It's with Trigger sides....i've triggerd client side and then in debugscript it says i triggerd client side but serverside not added...see server side: ShopMarker = createMarker(2285.8000488281,549.59997558594,6.8000001907349,"cylinder",1.5,0,125,250,153) function Marker(hitPlayer) triggerClientEvent(hitPlayer,"Marker",getRootElement(),hitPlayer) end addEventHandler ("onMarkerHit",ShopMarker,Marker) client side: function Marker() guiSetVisible (GUIEditor.window[1],true) showCursor ( true ) end addEvent ("Marker", true) addEventHandler ("Marker", getRootElement(), Marker) Error: Server triggered clientside event Marker, but event is not added client side. Link to comment
TAPL Posted November 22, 2013 Share Posted November 22, 2013 I don't see anything wrong, it might be the client file have another code which contains error and it lead to failure in loading the client side OR maybe there is something wrong with the meta. Link to comment
LiOneLMeSsIShoT Posted November 22, 2013 Author Share Posted November 22, 2013 I don't see anything wrong, it might be the client file have another code which contains error and it lead to failure in loading the client side OR maybe there is something wrong with the meta. Solved ... and Thanks a lot for your Help! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now