Jump to content

Problem with guiSetEnabled in Freeroam panel


Anzo

Recommended Posts

Posted

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) 

Posted
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" 
    }, 

Posted
'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?

Posted

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 

Posted
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

Posted
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) 

Posted

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?

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

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