Anzo Posted August 12, 2016 Share Posted August 12, 2016 Hi everyone, i have a problem when used guiSetEnabled in freeroam resource, this is the problem: WARNING:freeroam/fr_client.lua:107 Bad argument @ 'guiSetEnabled'[expected gui element at argument 1, got bolean] guiSetEnabled(getControl("BalasExplosivas"), false) Link to comment
Bonsai Posted August 12, 2016 Share Posted August 12, 2016 What is the getControl function returning? Apparently not a gui element as it should, at least in this case. Link to comment
Anzo Posted August 12, 2016 Author Share Posted August 12, 2016 What is the getControl function returning?Apparently not a gui element as it should, at least in this case. Mhm, freeroam used getControl for obtain variables/windows/labels. (i think) Line when defined ''BalasExplosivas'' { "btn", width=100, x=20, id ="BalasExplosivas",text="Balas explosivas" }, Link to comment
Gravestone Posted August 13, 2016 Share Posted August 13, 2016 'btn' element doesn't use 'x' attribute. Btw it's getControls, not getControl. Link to comment
Anzo Posted August 14, 2016 Author Share Posted August 14, 2016 'btn' element doesn't use 'x' attribute. Btw it's getControls, not getControl. getControls doesn't exist in freeroam panel. Someone knows what to do to make it work guiSetEnabled in freeroam panel? Link to comment
Gravestone Posted August 14, 2016 Share Posted August 14, 2016 There is no function in Freeroam to enable/disable controls by default. You can create your own. e.g function disableControls(wnd, ...) for i,ctrlName in ipairs({ ... }) do guiSetEnabled(getControl(wnd, ctrlName), false) end end function enableControls(wnd, ...) for i,ctrlName in ipairs({ ... }) do guiSetEnabled(getControl(wnd, ctrlName), true) end end Link to comment
Anzo Posted August 14, 2016 Author Share Posted August 14, 2016 There is no function in Freeroam to enable/disable controls by default. You can create your own. e.g function disableControls(wnd, ...) for i,ctrlName in ipairs({ ... }) do guiSetEnabled(getControl(wnd, ctrlName), false) end end function enableControls(wnd, ...) for i,ctrlName in ipairs({ ... }) do guiSetEnabled(getControl(wnd, ctrlName), true) end end Not work: function disableControls(wndItems) for i,ctrlName in ipairs({ "Balas(Explosivas)" }) do guiSetEnabled(getControl(wndItems, ctrlName), false) end end addEventHandler("onClientResourceStart", root, disableControls) Debug: WARNING: freeroam\fr_client.lua:106:Bad argument @ 'guiSetEnabled' [Expected gui-element at argument 1, got resource-data Link to comment
Gravestone Posted August 14, 2016 Share Posted August 14, 2016 onClientResourceStart's first parameter is the resource that has been started. Link to comment
Gravestone Posted August 14, 2016 Share Posted August 14, 2016 function disableControls(wndItems) -- This is the one and only parameter however wiki says that onClientResourceStart first parameter is the resource that was started Try using a timer instead. function disableControls(wndItems) for i,ctrlName in ipairs({ "Balas(Explosivas)" }) do guiSetEnabled(getControl(wndItems, ctrlName), false) end end setTimer(disableControls, 1000, 1) Link to comment
Anzo Posted August 14, 2016 Author Share Posted August 14, 2016 Not working. :[ Debug: ERROR: freeroam\gui.lua:376: attemp to index local 'currentData' (a nil value) Is best create a panel since 0? or there some solution? Link to comment
zneext Posted August 14, 2016 Share Posted August 14, 2016 You need to specify in which window the button is, Assuming that you defined the button in the main window (wndMain) the code should be the following: guiSetEnabled( getControl( wndMain, "BalasExplosivas" ), false ) Link to comment
Anzo Posted August 14, 2016 Author Share Posted August 14, 2016 You need to specify in which window the button is, Assuming that you defined the button in the main window (wndMain) the code should be the following: guiSetEnabled( getControl( wndMain, "BalasExplosivas" ), false ) wndItems is a window but not working... 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