Forum

Menu Problems

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Menu Problems

Postby ceriux » Fri Mar 25, 2011 5:20 pm

Okay so i got a menu i started . it prints the first menu correctly as the player spawns. but after i select the first option. it doesnt change self.menu to (2). anyways i have Menu(); being called in playerprethink and i have self.menu = 1; in clientconnect.

here's my code can anyone tell me whats wrong?

Code: Select all
.float menu;
.float menutime;
void() Menu =
{
   if (self.menu < 1)
   {
   remove(self);
   }
   if (self.menu == 1)
   {
      centerprint(self,"Choose a Side\n1.Team 1\n 2.Team 2\n");
   }
   if (self.menu == 2)
   {
      centerprint(self,"Choose a Class\n1. Class 1\n 2.Class 2\n 3.Class 3\n");
   }
};

void(float inp) Select =
{
  if (!self.menu) // if not in a menu do nothing.
    return;
  if (self.menu == 1) // if the menu is on menu 1.
  {
    if (inp == 1) // and if inp equals 1. do stuff.
    {
     self.menu = 2;
    }
    if (inp == 2)
    {
      self.menu =2;
    }
   
    if (self.menu == 2) // if the menu is on menu 1.
  {
    if (inp == 1) // and if inp equals 1. do stuff.
    {
     self.menu = 0;
    }
    if (inp == 2)
    {
      self.menu = 0;
    }
    if (inp == 3)
    {
      self.menu = 0;
    }

  }
 
  self.menutime = time + 0.2;
  }
};



Code: Select all



/*
============
ImpulseCommands

============
*/
void() ImpulseCommands =
{
   if (self.menu < 1)
   {
   if (self.impulse >= 1 && self.impulse <= 8)
      W_ChangeWeapon ();

   if (self.impulse == 9)
      CheatCommand ();
   if (self.impulse == 10)
      CycleWeaponCommand ();
   if (self.impulse == 11)
      ServerflagsCommand ();
   if (self.impulse == 12)
      CycleWeaponReverseCommand ();
   if (self.impulse == 13)
      self.menu = 1;
      
   
      

   if (self.impulse == 255)
      QuadCheat ();
      
   self.impulse = 0;
   
}

   else
   {
   SecondImpulse();
   }
   
};

void() SecondImpulse =
// this is the second part of the menu select code its a special set of impulse commands. if you add on to the menu just simply add another impulse to the list.
{
   if (self.impulse == 1)
      Select(1);
   if (self.impulse == 2)
      Select(2);
   if (self.impulse == 3)
      Select(3);

};
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Menu Problems

Postby Nahuel » Fri Mar 25, 2011 6:54 pm

I believe that you must create a new function called Menu2 that encarge of the class, it is the best way to avoid this type of problems.
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Postby ceriux » Fri Mar 25, 2011 7:01 pm

The Menu function only prints the menu. the select function sets the menu number (page?) and assigns which menu to display using Menu(); never had to do what you suggested before. not even sure if what you suggested is even proper. you dont need multiplce functions to print different things. basically if menu == 1 print this, if menu == print this. maybe i need to do else if instead of just if? lemme try.

edit: nope that didnt help. i think the easiest (sloppiest way would be your way =/) i know for a fact i dont need to do it that way though, the menu can all be handled in one function..
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Nahuel » Fri Mar 25, 2011 7:33 pm

good, then you do two different selects and menus for the classes , :oops: :oops: :oops: :oops: forgive me but this menu turns out to be complex for me (extract your conclusions regarding what I can do in qc if that is like that).
I use menúes like those of http://www.inside3d.com/showtutorial.php?id=13
but I never had problems
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Postby Spike » Fri Mar 25, 2011 7:37 pm

the keyword you are missing is 'else'.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby ceriux » Fri Mar 25, 2011 7:38 pm

lol those seem to be a little complex for me.

I actually made this type of menu myself a while back, just because it was what i could understand. it works similar to those from what i can tell. but is handled differently.

Although when i made this menu i was fairly better at qc. after i was gone for 8 months at school i forgot a lot and i seem to be having problems now.

my menu is like a splice between your's and the one in the counterstrike clone tutorial.

Spike wrote:the keyword you are missing is 'else'.


i tried =(
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Nahuel » Fri Mar 25, 2011 7:42 pm

Spike wrote:the keyword you are missing is 'else'.
:D :D
Spike is right!
I do not know that it means "lol"
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Postby ceriux » Fri Mar 25, 2011 7:48 pm

doesnt work

Code: Select all
{
   if (!self.menu)
   {
   return;
   }
   else if (self.menu == 1)
   {
      centerprint(self,"Choose a Side\n1.Team 1\n 2.Team 2\n");
   }
   else if (self.menu == 2)
   {
      centerprint(self,"Choose a Class\n1. Class 1\n 2.Class 2\n 3.Class 3\n");
   }
};
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Nahuel » Fri Mar 25, 2011 8:10 pm

void() Menu2 =

{
if (!self.menu)// i do not know if this "if" is necesary
{
return;
}

if (self.menu == 2)
{
centerprint(self,"Choose a Class\n1. Class 1\n 2.Class 2\n 3.Class 3\n");
}

};


void() Menu =
{
if (self.menu < 1)
{
remove(self);
}
else if (self.menu == 1)
{
centerprint(self,"Choose a Side\n1.Team 1\n 2.Team 2\n");
Menu2 ();
}
};

this, cannot fail............ or perhaps can do it
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Postby Spike » Sat Mar 26, 2011 1:59 am

if menu = 1 then the lines executed are marked with a leading X.
(not gonna mark braces because they contain no actual statements)

Code: Select all
void(float inp) Select =
{
X  if (!self.menu) // if not in a menu do nothing.
     return;
X  if (self.menu == 1) // if the menu is on menu 1.
   {
X    if (inp == 1) // and if inp equals 1. do stuff.
     {
X     self.menu = 2;
     }
X    if (inp == 2)
     {
       self.menu =2;
     }
   
X    if (self.menu == 2) // if the menu is on menu 1.
   {
X    if (inp == 1) // and if inp equals 1. do stuff.
     {
X     self.menu = 0;
     }
X    if (inp == 2)
     {
       self.menu = 0;
     }
X    if (inp == 3)
     {
       self.menu = 0;
     }

   }
 
X  self.menutime = time + 0.2;
   }
 };



you read that right.
X self.menu = 0;
yeah, your menu is switched off.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby ceriux » Sat Mar 26, 2011 3:47 am

i think i see whats wrong. everythings checking if menu == 1 right? i didnt close it correctly.

okay mainly fixed it. my second menu now prints it's a little odd. for one it prints way too high. secondly weather or not you press a button to choose your option the menu disappears.

here's a pic to explain:

http://img88.imageshack.us/img88/2580/qcprobs.png


i just recoded it all for the select function any help/suggestions/ideas?

forgot to add my code. same setup more or less.

Code: Select all
void() Menu =
{
   if (!self.menu)
   
   return;
      
   if (self.menu == 1)
   {
      centerprint(self,"Choose a Side\n1.Team 1\n 2.Team 2\n");
   }
   
   if (self.menu == 2)
   {
      centerprint(self,"Choose a Class\n1. Class 1\n 2.Class 2\n 3.Class 3\n");
   }
};

void(float inp) Select =
{
   if (!self.menu)
   {
      return;
   }
   
   else if (self.menu == 1)
   {
      if (inp == 1)
      {
         self.menu = 2;
      }
      
      if (inp == 2)
      {
         self.menu = 2;
      }
   }
   
   else if (self.menu == 2)
   {
      if (inp == 1)
      {
         self.menu = 0;
      }
      
      if (inp == 2)
      {
         self.menu = 0;
      }
      
      if (inp  == 3)
      {
         self.menu = 0;
      }
   }
      
};
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Spike » Sat Mar 26, 2011 3:15 pm

self.impulse = 0; ?
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby ceriux » Sat Mar 26, 2011 6:01 pm

yep thanks spike. :oops: if it means anything im picking up a little quicker this time -.-
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest