SOLVED: GUI button code problem

Started by barefoot, Mon 03/01/2011 17:59:28

Previous topic - Next topic

barefoot

Hi

Ive started to have a few problems with the following GUI.. particularly with the button GUI that opens them up.

Could someone please check below code and see where i may have errored...

At the moment a gui comes up when no clue is found... ie the else statement..

Code: ags

function Button7_OnClick(GUIControl *control, MouseButton button)
{
 
  
   if (player.HasInventory(ihair)) {
    ghair.Visible=true;
     gdocs.Visible=false;
}
  if (player.HasInventory(idoc)) {
    gdocs.Visible=true;
     ghair.Visible=false;
    
}
 
 
  if(player.HasInventory(ihair)&& player.HasInventory(idoc)){
    ghair.Visible=false;
     gdocs.Visible=false;
      ghairdoc.Visible=true;
  
}
 
 
 
    if(player.HasInventory(iphoto)){
      gprofile.Visible=true;

  
  
  
    }
 
     if(player.HasInventory(idisguise)){
        gdablodis.Visible=true;
   
  
   }
 
     if(player.HasInventory(icordainates)){
        gcords.Visible=true;
   
  }
  
  
   if(player.HasInventory(idisguise)&& player.HasInventory(icordainates)){
    gcorddisguise.Visible=true;
    
    
    
    }
  
  
   if(player.HasInventory(iphoto)){
    gcorddisguise.Visible=true;
    
    
       }
  
  
   if(player.HasInventory(idis)){
    gbossdiss.Visible=true;
    
    
      }
  
  
   if(player.HasInventory(iprint)){
    gprints.Visible=true;
  
  
  
    }
  
  
   if(player.HasInventory(inote2)){
    gprofnote.Visible=true;
  
  
  
}

  else { gnotepad.Visible=true;

}

}


Cheers if someone could check for me..

barefoot



I May Not Be Perfect but I Have A Big Heart ..

Matti

Currently your else statement is called whenever this isn't true:

Code: ags

if(player.HasInventory(inote2)){
  gprofnote.Visible=true;
}


Everything else isn't taken into account. Instead of

Code: ags

if..
if..
if..
if..
else..


you need to use "else if":

Code: ags

if..
else if..
else if..
else if..
else..


I don't know if that is your problem, but it seems to be.

barefoot

That sounds logical Matti.. guess  im going senile..  :=

just trying to get this bit right at the end:

Code: ags

}
    else {
 gnotepad1.Visible=true;

}
}


barefoot

I May Not Be Perfect but I Have A Big Heart ..

SMF spam blocked by CleanTalk