[SOLVED] make a cvar client side for ammobar

Locked
3xistence
Posts: 90
Joined: Sun May 13, 2012 3:02 pm

[SOLVED] make a cvar client side for ammobar

Post by 3xistence »

so everything happend on cgame directory
on cg_local.h i added

Code: Select all

extern	vmCvar_t		cg_AmmoBarStyle;
on cg_main.c

Code: Select all

{ &cg_AmmoBarStyle, "cg_AmmoBarStyle", "1", CVAR_ARCHIVE},
the main modification's inside the cg_weapons.c
i modified the Draw WeaponSelect

Code: Select all

void CG_DrawWeaponSelect( void ) {
	int		i;
	int		bits;
	int		count;
	int		x, y, w;
	char	*name;
	float	*color;
//adding the cvar reading
if ( cg.ammobarstyle.intege != 1 ) {
etc etc etc....
}
else if  ( cg.ammobarstyle.intege != 2 ) {
etc. etc. etc...
}
else if ( cg.ammobarstyle.intege != 0 ) {
etc etc etc...
}}
but something goes wrong because when i try to set cg_ammobarstyle X by ingame console all the game Crash to desktop without any error window or console log.

Any clue?
Last edited by 3xistence on Mon May 21, 2012 8:23 pm, edited 1 time in total.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: only client Cvars for visual graphics

Post by ^misantropia^ »

You need to actually define cg_AmmoBarStyle somewhere. You have an extern declaration but all that tells the compiler is that it's defined somewhere else.
3xistence
Posts: 90
Joined: Sun May 13, 2012 3:02 pm

Re: only client Cvars for visual graphics

Post by 3xistence »

thanks ^misantropia^

can i do it by just adding in cg_local?

#define cg_AmmoBarStyle 1

this will set the default value of ammobarstyle if i'm correct
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: only client Cvars for visual graphics

Post by ^misantropia^ »

Hah, not quite. Declare it extern in cg_local.h and define it in cg_main.c.
3xistence
Posts: 90
Joined: Sun May 13, 2012 3:02 pm

Re: [SOLVED] make a cvar client side for ammobar

Post by 3xistence »

thanks to ^misantropia^ i resolved this whole thing so i will post here the code i make
the next step (i'm working on it but suggetions are very welcome) is about:
put the client owned ammunitions next to the weapon select bar.

this is my code in order to have (using only console cvars ... hopefully later implemented inside the ui) a selectable classic, left side or right side weapon bar:

STEP ONE
mod cg_local.h inside cgame directory and add

Code: Select all

extern	vmCvar_t		cg_AmmoBarStyle;
STEP TWO
mod cg_main.c ever inside cgame directory and add

Code: Select all

vmCvar_t	cg_AmmoBarStyle;
	{ &cg_AmmoBarStyle, "cg_AmmoBarStyle", "0", CVAR_ARCHIVE}
so the default value for cvar cg_AmmoBarStyle will be 0 (classic quake 3 Arena ammo bar)

STEP THREE
let's open your cg_weapons.c ever in cgame directory (clientside because this "mods" will affects only the client and not the server or what other players will se)
that's my code:

Code: Select all

===================
CG_DrawWeaponSelect
===================
*/
void CG_DrawWeaponSelect( void ) {
	int		i;
	int		bits;
	int		count;
	int		x, y, w;
	char	*name;
	float	*color;

	// don't display if dead
	if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) {
		return;
		}
	if (cg_AmmoBarStyle.integer <= 0) {		//3X CODE classic bar only half size icons
		color = CG_FadeColor( cg.weaponSelectTime, WEAPON_SELECT_TIME );
		if ( !color ) {
			return;
			}
		trap_R_SetColor( color );

	// showing weapon select clears pickup item display, but not the blend blob
		cg.itemPickupTime = 0;

	// count the number of weapons owned
		bits = cg.snap->ps.stats[ STAT_WEAPONS ];
		count = 0;
		for ( i = 1 ; i < 16 ; i++ ) {
			if ( bits & ( 1 << i ) ) {
				count++;
				}
			}

		x = 320 - count * 20;
		y = 380;

		for ( i = 1 ; i < 16 ; i++ ) {
			if ( !( bits & ( 1 << i ) ) ) {
				continue;
				}

			CG_RegisterWeapon( i );

		// draw weapon icon
			CG_DrawPic( x, y, 32/2, 32/2, cg_weapons[i].weaponIcon );

		// draw selection marker
			if ( i == cg.weaponSelect ) {
				CG_DrawPic( x-2, y-2, 40/2, 40/2, cgs.media.selectShader );	//3X CODE mod from -4 to -2 for half size icons
				}

		// no ammo cross on top
			if ( !cg.snap->ps.ammo[ i ] ) {
				CG_DrawPic( x, y, 32/2, 32/2, cgs.media.noammoShader );
				}

			x += 40/2;
			}

	// draw the selected name
		if ( cg_weapons[ cg.weaponSelect ].item ) {
			name = cg_weapons[ cg.weaponSelect ].item->pickup_name;
			if ( name ) {
				w = CG_DrawStrlen( name ) * BIGCHAR_WIDTH;
				x = ( SCREEN_WIDTH - w ) / 2;
				CG_DrawBigStringColor(x, y - 22, name, color);
				}
			}

		trap_R_SetColor( NULL );
		}

	else if (cg_AmmoBarStyle.integer == 1) {		//3X CODE left side modern bar
		bits = cg.snap->ps.stats[ STAT_WEAPONS ];
		count = 0;
		for ( i = 1 ; i < 16 ; i++ ) {
			if ( bits & ( 1 << i ) ) {
				count++;
				}
			}

		x = 4;		//3X CODE put the x coordinate at 4 for the bar
		y = 80;		//3X CODE put the bar at 1/6 of y screeb resolution 640x480

		for ( i = 1 ; i < 16 ; i++ ) {
			if ( !( bits & ( 1 << i ) ) ) {
				continue;
				}

			CG_RegisterWeapon( i );
			// 3X CODE modify half size icons for modern display resolutions
			CG_DrawPic( x, y, 32/2, 32/2, cg_weapons[i].weaponIcon );

		// draw selection marker 3X CODE Modify for a more modern display halfsize
			if ( i == cg.weaponSelect ) {
				CG_DrawPic( x-4/2, y-4/2, 40/2, 40/2, cgs.media.selectShader );
				}

		// remove the no ammo cross because is useless if i add ammo owned for all weapons			
			y += 40/2;	// 3X CODE halfsize for icons and use y axis for vertical ammo display
			}

	// draw the selected name 3X CODE remove this because is useless for old gamers of Q3A

		trap_R_SetColor( NULL );
		}		
	else if (cg_AmmoBarStyle.integer >= 2) {		//3X CODE right side modern bar
		bits = cg.snap->ps.stats[ STAT_WEAPONS ];
		count = 0;
		for ( i = 1 ; i < 16 ; i++ ) {
			if ( bits & ( 1 << i ) ) {
				count++;
				}
			}

		x = 640-20;		//3X CODE put the x coordinate at right side less the icon size for the bar
		y = 80;		//3X CODE put the bar at 1/6 of y screeb resolution 640x480

		for ( i = 1 ; i < 16 ; i++ ) {
			if ( !( bits & ( 1 << i ) ) ) {
				continue;
				}

			CG_RegisterWeapon( i );
			// 3X CODE modify half size icons for modern display resolutions
			CG_DrawPic( x, y, 32/2, 32/2, cg_weapons[i].weaponIcon );

		// draw selection marker 3X CODE Modify for a more modern display halfsize
			if ( i == cg.weaponSelect ) {
				CG_DrawPic( x-4/2, y-4/2, 40/2, 40/2, cgs.media.selectShader );
				}

		// remove the no ammo cross because is useless if i add ammo owned for all weapons			
			y += 40/2;	// 3X CODE halfsize for icons and use y axis for vertical ammo display
			}

	// draw the selected name 3X CODE remove this because is useless for old gamers of Q3A

		trap_R_SetColor( NULL );
		}		
	}
what you obtain:
a new cvar cg_AmmoBarStyle (you can assign the value by console "cg_AmmoBarStyle 0 / 1 /2" one of these
with a cvar value integer 0 or less you will have the classic quake 3 arena ammo bar, icons will be half size i need to adjust some other things
with a cvar value equals 1 you will have left side bar(for now without ammo display, i'm trying to understand how to make it)
and a cvar 2 or more a right side ammo bar.

I usually don't post my code here, put sometimes the "big" problems are only made by a lack of accuracy.
Hope to help somebody else and also myself for my project

still thanks ^misantropia^ for his attention.

If somebody can help me with "all owned weapon ammo count" it will appreciated.
and hope to help somebody else.

Thanks
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: [SOLVED] make a cvar client side for ammobar

Post by ^misantropia^ »

If somebody can help me with "all owned weapon ammo count" it will appreciated.
I'm not 100% sure what you mean but the ammo count is in cg.snap->ps.ammo[0..MAX_WEAPONS-1].
3xistence
Posts: 90
Joined: Sun May 13, 2012 3:02 pm

Re: [SOLVED] make a cvar client side for ammobar

Post by 3xistence »

^misantropia^ wrote:
If somebody can help me with "all owned weapon ammo count" it will appreciated.
I'm not 100% sure what you mean but the ammo count is in cg.snap->ps.ammo[0..MAX_WEAPONS-1].
But cg.snap->ps.ammo[0..MAX_WEAPONS-1] is the ammo count for the equipped weapon?

Basically I want to add the ammo count for all the weapons a character have
and put the various count sside the weapons bar.
graphically it will be something like:

[icon_weapon1] [n° of ammo for weapon1]
[icon_weapon2] [n° of ammo for weapon2]
[icon_weapon3] [n° of ammo for weapon3]
etc...
User avatar
Eraser
Posts: 19177
Joined: Fri Dec 01, 2000 8:00 am

Re: [SOLVED] make a cvar client side for ammobar

Post by Eraser »

Look up the WP_ constants like WP_MACHINEGUN and WP_SHOTGUN that are defined in the weapon_t enum (in bg_public.h). You can use those constants to access their respective ammo counts in the ps.ammo array, like this:

Code: Select all

Com_Printf("%i\n", cg.snap->ps.ammo[WP_SHOTGUN]);

That code prints the ammo count for the shotgun to the console. Basically just replace WP_SHOTGUN with any of the other WP_ constants and you get the ammo count for that weapon.
3xistence
Posts: 90
Joined: Sun May 13, 2012 3:02 pm

Re: [SOLVED] make a cvar client side for ammobar

Post by 3xistence »

Thank you Eraser!
it's exactly cg.snap->ps.ammo[WP_ETCETC] what i was searching!
need probably to create a new cg_draw function in order to display integer numbers of ammunitions or maybe convert integer to char and use a cg_drawTinyString function?
3xistence
Posts: 90
Joined: Sun May 13, 2012 3:02 pm

Re: [SOLVED] make a cvar client side for ammobar

Post by 3xistence »

sorry for my questions:
in order to recognize the icon for the correct weapon the code use

Code: Select all

cg_weapons[i].weaponIcon
where int i 's the number of the weapon i suppose, but how he understand the correct order of the icons?
i mean if you start with weapon 1 and 2 and you take weapon 5 you will se the weapons icon in this order

[1] [2] [5]

when you take weapon 3 the game will bring it between 2 and 5

[1] [2] [3] [5]

how it recognize how to do it?

cg.snap->ps.stats[ STAT_WEAPONS ] function what does?

sorry but i'm trying to think how to do the same thing with ammunitions:
in my mind i thinked something about this cg_weapons with my custom cg_draw function like:

if (i == 1) {
cg_drawEXammo ( x+delta, y, 1, cg.snap->ps.ammo[ WP_MACHINEGUN ];
}
if (i == 2) cg_drawEXammo (x+delta, y, 1, cg.snap->ps.ammo[ WP_SHOTGUN ];

etc...

but obviously it doesn't work in the right way.

somebody can give me an advice?
User avatar
Eraser
Posts: 19177
Joined: Fri Dec 01, 2000 8:00 am

Re: [SOLVED] make a cvar client side for ammobar

Post by Eraser »

3xistence wrote:Thank you Eraser!
it's exactly cg.snap->ps.ammo[WP_ETCETC] what i was searching!
need probably to create a new cg_draw function in order to display integer numbers of ammunitions or maybe convert integer to char and use a cg_drawTinyString function?
In think you could do something like this:

Code: Select all

void CG_DrawAmmo(int x, int y, int weapon) {
char    ammo[1024];

Com_sprintf( ammo, sizeof(ammo), "%i", cg.snap->ps.ammo[weapon]);
CG_DrawSmallString(x, y, ammo, 0);
}
There's also CG_DrawSmallStringColor for drawing colored text.
User avatar
Eraser
Posts: 19177
Joined: Fri Dec 01, 2000 8:00 am

Re: [SOLVED] make a cvar client side for ammobar

Post by Eraser »

3xistence wrote:sorry for my questions:
in order to recognize the icon for the correct weapon the code use

Code: Select all

cg_weapons[i].weaponIcon
where int i 's the number of the weapon i suppose, but how he understand the correct order of the icons?

i mean if you start with weapon 1 and 2 and you take weapon 5 you will se the weapons icon in this order

[1] [2] [5]

when you take weapon 3 the game will bring it between 2 and 5

[1] [2] [3] [5]

how it recognize how to do it?

cg.snap->ps.stats[ STAT_WEAPONS ] function what does?

sorry but i'm trying to think how to do the same thing with ammunitions:
in my mind i thinked something about this cg_weapons with my custom cg_draw function like:

if (i == 1) {
cg_drawEXammo ( x+delta, y, 1, cg.snap->ps.ammo[ WP_MACHINEGUN ];
}
if (i == 2) cg_drawEXammo (x+delta, y, 1, cg.snap->ps.ammo[ WP_SHOTGUN ];

etc...

but obviously it doesn't work in the right way.

somebody can give me an advice?


Ok, you've probably been looking at the CG_DrawWeaponSelect() function in cg_weapons.c

cg.snap->ps.stats is an array of integers that contains information about the player like amount of health, armor but also which weapons the player has. The STAT_WEAPON is the index at which this number is stored. The number stored here is a bitmask where each bit represents a weapon and the index of the bit is in accordance to the WP_ enum values (gauntlet being the least significiant bit, machinegun the next, then shotgun, etc). You can simply test each bit to see if it's set to 1 or 0 and in that way determine which weapons the player has.

As for your original question, the WP_ enum determines the order of the weapons and if you draw your weapon icons in that order then it's always correct.
3xistence
Posts: 90
Joined: Sun May 13, 2012 3:02 pm

Re: [SOLVED] make a cvar client side for ammobar

Post by 3xistence »

really thanks eraser, i'm also watching your webiste with your tutorials
but this kind of thing about correct order of ammo count is a little bit difficult...
...also because i need to tell inside the code to "print" or draw the player ammunition for every weapons he own in the correct order (like the source code manage the icons) and right about now i'm stuck!

right about now i'm working on a total rewrite of cg_draw because i need to code if ( statusbarstyle >= 1 ) don't draw at all 3d icons stuff or 2d but draw my status bar, isn't complicated but ID code works with a draw before a 3d and after make the 2d, so now i'm adding a lot of if (statusbarstyle <= 0) make the things of ID (i'm trying to preserve the old code) but if statusbarstyle >= 1 cg_ExistenceDraw my things.

lot of work...right about now i managed to take away the id code for armor and ammo in the original status bar, for head is a little bit tricky because i'm trying to add the less code possible and i'm thinking about what i can do...
..(stucked because the same code for 3dhead status bar is also used for scoreboard).

actual trouble's:
i replaced the client head icon (talking about original code) with my custom (and same for all clients) icon...
...this actually doesn't work for scoreboard...need to find where to put the if (statusbarstyle == 1) doesn't show at all the headmodel or my custom "head" icon

do you know any trick about the color table code?
i talked in a previous post also: i want to expand the color1 possibilities of a players and extend the colors, but right about now it seems quite impossible...i'm thinking to add an SDL or allegro header....any clues?

thanks
themuffinman
Posts: 384
Joined: Fri Mar 05, 2010 5:29 pm

Re: [SOLVED] make a cvar client side for ammobar

Post by themuffinman »

Well since you seem properly stuck on this, my QL weapon bar code should help set you on the right track...

Code: Select all

/*
===================
CG_DrawWeaponBar
===================
*/
void CG_DrawWeaponBar( void ) {

	int		i, j;			// count
	int		bits, count;	// weapons list
	int		x, y, w, h;		// coordinates


	char	*num;			// ammo value char
	int		ammoValue;		// integral ammo value

	int		ammoState[ WP_NUM_WEAPONS ];	// ammo level states
	float	*txtCol[ WP_NUM_WEAPONS ];

	playerState_t	*ps;
	
	int		iconSize = 16;
	int		tileWidth = 52;
	int		tileHeight = 20;
	int		tileSpace = 2;
	int		ammoSpace = 26;
	int		startY = 92;

	float	*color;		// fading out
	float	scale = 0.24f;
	float	bigScale = 0.35f;

	x = y = w = h = 0;

	ps = &cg.snap->ps;

	if ( !cg_weaponBar.integer ) return;

	// don't display if dead
	if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) return;

	if ( cg_weaponBar.integer >= 4 ) {
		color = CG_FadeColor( cg.weaponSelectTime, WEAPON_SELECT_TIME );
		if ( !color ) return;
	} else {
		color = colorWhite;
	}

	trap_R_SetColor( color );

	// set bits
	if ( cg_drawFullWeaponBar.integer && cg_weaponBar.integer < 4 ) {
		// bits = weapons registered on level start
		bits = cgs.mapweapons;
	} else {
		// bits = weapons owned
		bits = cg.snap->ps.stats[ STAT_WEAPONS ];
	}

	// get the number of weapons to display
	count = 0;
	for ( i = WP_MACHINEGUN ; i < MAX_WEAPONS ; i++ ) {
		if ( cg_drawFullWeaponBar.integer ) {
			j = i + 1;
			if ( bits & ( 1 << j ) ) count++;
		} else {
			if ( bits & ( 1 << i ) ) count++;
		}
	}

	// ========================================
	// left
	// ========================================
	if ( cg_weaponBar.integer == 1 ) {

		x = 0;
		y = startY;

		for ( i = WP_MACHINEGUN ; i < MAX_WEAPONS ; i++ ) {
			if ( cg_drawFullWeaponBar.integer ) {
				j = i + 1;
				if ( !( bits & ( 1 << j ) ) ) continue;
			} else {
				if ( !( bits & ( 1 << i ) ) ) continue;
			}

			CG_RegisterWeapon( i );

			ammoValue = ps->ammo[ i ];
			num = va("%i", ammoValue);

			// set ammo states + color
			ammoState[ i ] = GetAmmoState( i );

			if ( ammoState[ i ] == 0 && cg_lowAmmoWeaponBarWarning.integer )
				txtCol[ i ] = colorRed;
			else if ( ammoState[ i ] == 1 && cg_lowAmmoWeaponBarWarning.integer > 1 )
				txtCol[ i ] = colorYellow;
			else
				txtCol[ i ] = colorWhite;

			trap_R_SetColor( txtCol[ i ] );

			// draw selection marker
			if ( i == cg.weaponSelect ) {
				CG_DrawPic( x, y, tileWidth, tileHeight, cgs.media.weapLitShader );
			}

			// draw weapon icon
			CG_DrawPic( x + 4, y + 2, iconSize, iconSize, cg_weapons[ i ].weaponIcon );

			// ammo value
			if ( ammoValue < AMMO_INFINITE && ammoValue > -1 ) {
				int	textX;
				int	textY;

				h = CG_Text_Height( num, scale, 0 );
				textX = x + tileSpace + ammoSpace;
				textY = y + tileSpace + ( tileHeight + h )/2;

				CG_Text_Paint( textX, textY, scale, txtCol[ i ], num, 0, 0, 0 );
			}
			y += tileHeight + (tileSpace * 2);
		}

	// ========================================
	// right
	// ========================================
	} else if ( cg_weaponBar.integer == 2 ) {
		x = SCREEN_WIDTH - ( tileWidth + tileSpace * 2 );
		y = startY;

		for ( i = WP_MACHINEGUN ; i < MAX_WEAPONS ; i++ ) {
			if ( !( bits & ( 1 << i ) ) ) continue;

			CG_RegisterWeapon( i );

			ammoValue = ps->ammo[ i ];
			num = va("%i", ammoValue);

			// set ammo states + color
			ammoState[ i ] = GetAmmoState( i );

			if ( ammoState[ i ] == 0 && cg_lowAmmoWeaponBarWarning.integer )
				txtCol[ i ] = colorRed;
			else if ( ammoState[ i ] == 1 && cg_lowAmmoWeaponBarWarning.integer > 1 )
				txtCol[ i ] = colorYellow;
			else
				txtCol[ i ] = colorWhite;

			trap_R_SetColor( txtCol[ i ] );

			// draw selection marker
			if ( i == cg.weaponSelect ) {
				CG_DrawPic( SCREEN_WIDTH - tileWidth - tileSpace, y, tileWidth, tileHeight, cgs.media.weapLitShader );
			}

			// draw weapon icon
			CG_DrawPic( SCREEN_WIDTH - tileSpace - 4 - iconSize, y + 2, iconSize, iconSize, cg_weapons[ i ].weaponIcon );

			// ammo value
			if ( ammoValue < AMMO_INFINITE && ammoValue > -1 ) {
				int	textX;
				int	textY;

				h = CG_Text_Height( num, scale, 0 );
				w = CG_Text_Width( num, scale, 0 );
				textX = SCREEN_WIDTH - ammoSpace - w;
				textY = y + tileSpace + ( tileHeight + h )/2;

				CG_Text_Paint( textX, textY, scale, txtCol[ i ], num, 0, 0, 0 );
			}

			y += tileHeight + (tileSpace * 2);
		}

	// ========================================
	// center
	// ========================================
	} else if ( cg_weaponBar.integer == 3 ) {

		x = 320 - ( ( count * ( tileWidth + tileSpace + tileSpace ) ) / 2 );
		y = 412;

		for ( i = WP_MACHINEGUN ; i < MAX_WEAPONS ; i++ ) {
			if ( !( bits & ( 1 << i ) ) ) continue;

			CG_RegisterWeapon( i );

			ammoValue = ps->ammo[ i ];
			num = va("%i", ammoValue);

			// set ammo states + color
			ammoState[ i ] = GetAmmoState( i );

			if ( ammoState[ i ] == 0 && cg_lowAmmoWeaponBarWarning.integer )
				txtCol[ i ] = colorRed;
			else if ( ammoState[ i ] == 1 && cg_lowAmmoWeaponBarWarning.integer > 1 )
				txtCol[ i ] = colorYellow;
			else
				txtCol[ i ] = colorWhite;

			trap_R_SetColor( txtCol[ i ] );

			// draw selection marker
			if ( i == cg.weaponSelect ) {
				CG_DrawPic( x + tileSpace, y, tileWidth, tileHeight, cgs.media.weapLitShader );
			}

			// draw weapon icon
			CG_DrawPic( x + tileSpace + 4, y + 2, iconSize, iconSize, cg_weapons[ i ].weaponIcon );

			// ammo value
			if ( ammoValue != AMMO_INFINITE ) {
				int	low;
				int max = ps->maxAmmo[ i ];

				float	textX;
				float	textY;
				low = max * cg_lowAmmoWarningPercentile.value;
				
				h = CG_Text_Height( num, scale, 0 );
				textX = x + tileSpace + ammoSpace;
				textY = y + tileSpace + ( tileHeight + h )/2;
				
				CG_Text_Paint( textX, textY, scale, txtCol[ i ], num, 0, 0, 0 );

			} else {
				float	icX;
				float	icY;

				icX = x + tileSpace + ammoSpace;
				icY = y + tileSpace;

				CG_DrawPic( icX, icY, iconSize, iconSize, cgs.media.infiniteShader );
			}

			x += tileWidth + (tileSpace * 2);
		}

	// ========================================
	// legacy
	// ========================================
	} else {
		// showing weapon select clears pickup item display, but not the blend blob
		x = 320 - count * 20;
		y = 380;

		for ( i = WP_MACHINEGUN ; i < MAX_WEAPONS ; i++ ) {
			if ( !( bits & ( 1 << i ) ) ) continue;

			CG_RegisterWeapon( i );

			// draw weapon icon
			CG_DrawPic( x, y, 32, 32, cg_weapons[ i ].weaponIcon );

			// draw selection marker
			if ( i == cg.weaponSelect ) {
				CG_DrawPic( x-4, y-4, 40, 40, cgs.media.selectShader );
			}

			// no ammo cross on top
			if ( !cg.snap->ps.ammo[ i ] ) {
				CG_DrawPic( x, y, 32, 32, cgs.media.noammoShader );
			}

			x += 40;
		}

		// draw the selected name
		if ( cg_weapons[ cg.weaponSelect ].item ) {
			float	alpha = *color;
			char	*name = cg_weapons[ cg.weaponSelect ].item->pickup_name;		// weapon name

			if ( name ) {
				w = CG_Text_Width(name, bigScale, 0);
				CG_Text_Paint_Float(320 - w / 2, y - 8, bigScale, colorWhite, name, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE, alpha);
			}
		}

		trap_R_SetColor( NULL );
		// ========================================
	}
}
The 3 weapon bars are quite similar so they could be merged.
3xistence
Posts: 90
Joined: Sun May 13, 2012 3:02 pm

Re: [SOLVED] make a cvar client side for ammobar

Post by 3xistence »

Thanks muffinman!
you solved my problem with this:

Code: Select all

int ammoValue;

ammoValue = ps->ammo[ i ];

	playerState_t	*ps;
	
	ps = &cg.snap->ps;

CG_Draw3Xammo( x - 2, y + 4, 1.0, ammoValue);
all seems to works now!
need just to align text (probably i miss something in my cg_draw3Xammo)
really thanks, you are great!

what are you working right now? ever physics?
Locked