while loops in qc?
Moderator: InsideQC Admins
5 posts
• Page 1 of 1
while loops in qc?
hey i was writing a function that basically says if the user shoots 3 continious shots and continues to then change the punchangle and the accuracy. when i tested it out i got an error when i tried shooting in dakrplaces but when i changed the while to an if it was fine.
thanks
- Code: Select all
void () W_FireM9 =
{
local .float shots_fired;
self.shots_fired = 15 - self.exam_m9;
local vector dir;
sound (self, CHAN_WEAPON, "weapons/m9.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
self.currentammo = self.exam_m9 = self.exam_m9 -1;
dir = aim (self,100000);
FireBullets (1,dir, '0.03 0.04 0');
while (self.shots_fired = self.shots_fired -3)
{
self.punchangle_x = -5;
FireBullets (1, dir, '0.05 0.06 0');
}
};
thanks
- sniperz227
- Posts: 112
- Joined: Sat Apr 09, 2011 3:19 am
Re: while loops in qc?
sniperz227 wrote:
- Code: Select all
while (self.shots_fired = self.shots_fired -3)
That should be ==, not =. = is assignment, == is comparison.
Leave others their otherness.
http://quakeforge.net/
http://quakeforge.net/
- taniwha
- Posts: 399
- Joined: Thu Jan 14, 2010 7:11 am
Re: while loops in qc?
it worked like it doesnt crash anymore but the code doesnt work 
- sniperz227
- Posts: 112
- Joined: Sat Apr 09, 2011 3:19 am
Re: while loops in qc?
sniperz227 wrote:it worked like it doesnt crash anymore but the code doesnt work
Actually, I noticed what you were trying to do. This is the right way:
- Code: Select all
while (self.shots_fired >= 3) {
...
self.shots_fired = self.shots_fired -3;
}
Leave others their otherness.
http://quakeforge.net/
http://quakeforge.net/
- taniwha
- Posts: 399
- Joined: Thu Jan 14, 2010 7:11 am
Re: while loops in qc?
you just don't see the results cause the entire while loop is done in one frame...
-

Error - InsideQC Staff
- Posts: 865
- Joined: Fri Nov 05, 2004 5:15 am
- Location: VA, USA
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest