Q? extern float from progs.dat

Discuss CSQC related programming.
Post Reply
Rikku2000
Posts: 49
Joined: Wed Oct 20, 2010 6:33 pm
Location: Germany
Contact:

Q? extern float from progs.dat

Post by Rikku2000 »

Hello guys i am asking you guys is it posible to get an extern float from the progs.dat

Coz in my progs.dat i add the Flashlight and give them an 10sec interval then turn it off

i build with csqc an new Hud so i Need a extern Float from the Progs.dat

here an Image of my new Hud for my Mod.

Image


This code i use at Moment in "hud.qc->drawHud ()":

Code: Select all

hud_size = '56 11 0';
	if (time > self.flash_time)
		drawpic (hud_pos, "progs/csqc/hud/flashlight/flashlight0.tga", hud_size, '1 1 1', .6, 0);
	else {
		if (time > self.flash_time - 1)
			drawpic (hud_pos, "progs/csqc/hud/flashlight/flashlight0.tga", hud_size, '1 1 1', .6, 0);
		else if (time > self.flash_time - 2)
			drawpic (hud_pos, "progs/csqc/hud/flashlight/flashlight1.tga", hud_size, '1 1 1', .6, 0);
		else if (time > self.flash_time - 3)
			drawpic (hud_pos, "progs/csqc/hud/flashlight/flashlight2.tga", hud_size, '1 1 1', .6, 0);
		else if (time > self.flash_time - 4)
			drawpic (hud_pos, "progs/csqc/hud/flashlight/flashlight3.tga", hud_size, '1 1 1', .6, 0);
		else if (time > self.flash_time - 5)
			drawpic (hud_pos, "progs/csqc/hud/flashlight/flashlight4.tga", hud_size, '1 1 1', .6, 0);
		else if (time > self.flash_time - 6)
			drawpic (hud_pos, "progs/csqc/hud/flashlight/flashlight5.tga", hud_size, '1 1 1', .6, 0);
		else if (time > self.flash_time - 7)
			drawpic (hud_pos, "progs/csqc/hud/flashlight/flashlight6.tga", hud_size, '1 1 1', .6, 0);
		else if (time > self.flash_time - 8)
			drawpic (hud_pos, "progs/csqc/hud/flashlight/flashlight7.tga", hud_size, '1 1 1', .6, 0);
		else if (time > self.flash_time - 9)
			drawpic (hud_pos, "progs/csqc/hud/flashlight/flashlight8.tga", hud_size, '1 1 1', .6, 0);
	}
I am sorry for my English...
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Q? extern float from progs.dat

Post by Spike »

look up clientstat/addstat and getstatf
gnounc
Posts: 428
Joined: Mon Apr 06, 2009 6:26 am

Re: Q? extern float from progs.dat

Post by gnounc »

http://forums.inside3d.com/viewtopic.php?f=16&t=5194

that covers addstat.

also here, you can save some space in your code if you'd like.

Code: Select all

      hud_size = '56 11 0';
      for(n = 0; n < 8 ;n++)
      {
         if(time > self.flash_time - n)
         {
            drawpic(hud_pos, strcat("progs/csqc/hud/flashlight/flashlight",ftos(n)), hud_size, '1 1 1', 0.6, 0);
            break;
         }
      }
you'll need to drop the numbers by 1 in your filenames if you want to use that loop though.
with 1 being a copy of 0.

Nice hud by the way ;)
Rikku2000
Posts: 49
Joined: Wed Oct 20, 2010 6:33 pm
Location: Germany
Contact:

Re: Q? extern float from progs.dat

Post by Rikku2000 »

Yes but the float is not an Quake Default float...

its an new float for Flashlight time.

thats the code for my hud now:

Code: Select all

void drawHud () {
	local float health, armor, ammo, weapon;
	local float i;

	hud_pos_x = 8; // Health
	hud_pos_y = screen_size_y - 45;
	hud_size_x = 236 / 2;
	hud_size_y = 50 / 2;
	drawpic (hud_pos, "progs/csqc/hud/hud1.tga", hud_size, '1 1 1', .6, 0);

	i = 0;
	health = getstatbits (STAT_HEALTH);
	hud_pos_x = 18;
	hud_pos_y = screen_size_y - 39;
	hud_size_x = 193 / 2;
	hud_size_y = 24 / 2;
	for (i = 20; i > 0; i--) {
		if (health > -3 + (i * 5)) {
			drawpic (hud_pos, sprintf ("progs/csqc/hud/health/health%d.tga", 20 - i), hud_size, '1 1 1', .5, 0);
			break;
		}
	}

	hud_pos_x = 12; // Armor
	hud_pos_y = screen_size_y - 20;
	hud_size_x = 220 / 2;
	hud_size_y = 32 / 2;
	drawpic (hud_pos, "progs/csqc/hud/hud2.tga", hud_size, '1 1 1', .6, 0);

	i = 0;
	armor = getstatbits (STAT_ARMOR);
	hud_pos_x = 18;
	hud_pos_y = screen_size_y - 14;
	hud_size_x = 193 / 2;
	hud_size_y = 8 / 2;
	for (i = 20; i > 0; i--) {
		if (armor > -3 + (i * 5)) {
			drawpic (hud_pos, sprintf ("progs/csqc/hud/armor/armor%d.tga", 20 - i), hud_size, '1 1 1', .5, 0);
			break;
		}
	}

	hud_pos_x = screen_size_x - 124; // Ammo
	hud_pos_y = screen_size_y - 58;
	hud_size_x = 240 / 2;
	hud_size_y = 84 / 2;
	drawpic (hud_pos, "progs/csqc/hud/hud3.tga", hud_size, '1 1 1', .6, 0);

	weapon = getstatbits (STAT_AMMO);
	hud_pos_x = screen_size_x - 121; // Ammo
	hud_pos_y = screen_size_y - 43;
	hud_size_x = 138 / 2;
	hud_size_y = 22 / 2;
	if (weapon == 0) { // Axe
		drawpic (hud_pos, "progs/csqc/hud/ammo/ammo0.tga", hud_size, '1 1 1', .6, 0);
	} else {
		i = 0;
		ammo = getstatbits (STAT_AMMO);
	for (i = 20; i > 0; i--) {
			if (ammo > -5 + (i * 5)) {
				drawpic (hud_pos, sprintf ("progs/csqc/hud/ammo/ammo%d.tga", 20 - i), hud_size, '1 1 1', .5, 0);
				break;
			}
		}
	}

	hud_pos_x = screen_size_x - 140; // Flashlight
	hud_pos_y = screen_size_y - 27;
	hud_size_x = 148 / 2;
	hud_size_y = 38 / 2;
	drawpic (hud_pos, "progs/csqc/hud/hud4.tga", hud_size, '1 1 1', .6, 0);

	hud_pos_x = screen_size_x - 140;
	hud_pos_y = screen_size_y - 27;
	hud_size_x = 112 / 2;
	hud_size_y = 22 / 2;
	for (i = 0; i < 8; i++) {
		if (time > self.flash_time - i) {
			drawpic (hud_pos, sprintf ("progs/csqc/hud/flashlight/flashlight%d.tga", i), hud_size, '1 1 1', .5, 0);
			break;
		}
	}
}
@gnounc: thanks for this code example. :)



maybe there is something like: extern .float flash_time;

that i can get it from progs.dat
I am sorry for my English...
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Q? extern float from progs.dat

Post by Spike »

ssqc defs:
void(float num, float type, .__variant fld) clientstat = #232;
float EV_FLOAT = 2;
.float flash_time;

ssqc worldspawn:
clientstat(32, EV_FLOAT, flash_time);

ssqc anywhere you want:
self.flash_time = time;

csqc code somewhere:
float myflashtime = getstatf(32);
print(sprintf("player.flash_time = %g\n", myflashtime));
Rikku2000
Posts: 49
Joined: Wed Oct 20, 2010 6:33 pm
Location: Germany
Contact:

Re: Q? extern float from progs.dat

Post by Rikku2000 »

You Guys are so nice thank you so much for helping me. :)

So here the result: It works :)
Image
I am sorry for my English...
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Q? extern float from progs.dat

Post by ceriux »

very nice hud =3
Post Reply