Jump to content

Need some help with combo boxes


Recommended Posts

Hey I'm having some problems with combo boxes. here's some of the code.

window = guiCreateWindow(x/2 - -100,y/2 - 110,280,310,"World",false) 
label7 = guiCreateLabel(10,180,80,40,"Reset Colors:",false,window) 
box2 = guiCreateComboBox(100,180,60,90,"Sky",false,window) 
guiComboBoxAddItem(box2,"Sky") 
guiComboBoxAddItem(box2,"Water") 
guiComboBoxAddItem(box2,"Sun") 
  
function resetColors() 
if (source == button13) then 
if guiComboBoxGetSelected(box2) == -1 or 0 then 
resetSkyGradient() 
if guiComboBoxGetSelected(box2) == 1 then 
resetWaterColor() 
if guiComboBoxGetSelected(box2) == 2 then 
resetSunColor() 
end 
end 
end 
end 
end 
addEventHandler("onClientGUIClick",button13,resetColors) 

The problem is if I select Sky it resets the Sky, but if i select Water and the Sky color is changed it will still reset the Sky, but it wont reset the water color. If i select Sun nothing resets. I believe the problem is with the item indexes.

Link to comment

your conditions are wrong:

window = guiCreateWindow(x/2 - -100,y/2 - 110,280,310,"World",false) 
label7 = guiCreateLabel(10,180,80,40,"Reset Colors:",false,window) 
box2 = guiCreateComboBox(100,180,60,90,"Sky",false,window) 
guiComboBoxAddItem(box2,"Sky") 
guiComboBoxAddItem(box2,"Water") 
guiComboBoxAddItem(box2,"Sun") 
  
function resetColors() 
  if (source == button13) then 
    if guiComboBoxGetSelected(box2) == -1 or guiComboBoxGetSelected(box2) == 0 then 
      resetSkyGradient() 
    elseif guiComboBoxGetSelected(box2) == 1 then 
      resetWaterColor() 
    elseif guiComboBoxGetSelected(box2) == 2 then 
      resetSunColor() 
    end 
  end 
end 
addEventHandler("onClientGUIClick",button13,resetColors) 

PS: x/2 - -100 == x/2 + 100 :D

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