Author Topic: Getting players current ammo in menu file  (Read 731 times)

Offline gixslayer

  • Rank: Private
  • *
  • Posts: 9
Getting players current ammo in menu file
« on: November 26, 2010, 07:20:33 am »
Hey,

I'm trying to make a custom hud (editing the hud.menu file).
I'm trying to replace the graphical ammo counter with a plain text one.

Code: [Select]
itemDef
{
name "clipGraphic"
rect (WEAPINFO_X - 68) (WEAPINFO_Y + 34) 1 1//(WEAPINFO_X - 30) (WEAPINFO_Y + 32 -6) 1 1
forecolor 1 1 1 HUD_ALPHA
exp text ()//( dvarString( "___probot_ammoclip" ) + " | " + dvarString( "___probot_ammostock") )
textalign ITEM_ALIGN_LEFT
textscale TEXTSIZE_SMALL
textstyle ITEM_TEXTSTYLE_SHADOWED
textfont UI_FONT_OBJECTIVE
forecolor 1 1 1 HUD_FOREGROUND_ALPHA
//ownerdraw CG_PLAYER_WEAPON_AMMO_CLIP_GRAPHIC
visible 1
decoration
}

Here is the bit of code, note: was trying to workaround it using dvars, but was having trouble getting them set correctly everytime when player shoots/reloads/switches etc...
Is the a smart command like 'player( currentammoclip )' or something similar?
Or does anyone have another suggestion?

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: Getting players current ammo in menu file
« Reply #1 on: November 26, 2010, 05:26:26 pm »
weapon = self getCurrentWeapon();
clipAmmo = self GetWeaponAmmoClip( weapon );

Offline gixslayer

  • Rank: Private
  • *
  • Posts: 9
Re: Getting players current ammo in menu file
« Reply #2 on: November 26, 2010, 07:06:18 pm »
Yea I know that, but that doesn't work in a .menu file.
My whole question is how to do it in a .menu file.

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: Getting players current ammo in menu file
« Reply #3 on: November 26, 2010, 07:18:15 pm »
I don't think you can. You can display a dvar set by an ammo monitor running in server code, but that may be too slow in updating. That's probably why they set that stuff using ownerdraw in the first place.

Offline gixslayer

  • Rank: Private
  • *
  • Posts: 9
Re: Getting players current ammo in menu file
« Reply #4 on: November 27, 2010, 04:49:29 am »


Like that, it is possible, and they don't use dvars.
But yea I guess I'll stick to the normal ammo counter then.

BTW:

Code: [Select]
#define CG_PLAYER_WEAPON_AMMO_CLIP_GRAPHIC 117Is defined in ui/menudefenition.h which says this at the top:

Code: [Select]
// Update menudefinition.h in the code source if you change this file.We probably don't have access to that source code i guess.

OK WAIT
Code: [Select]
#define CG_PLAYER_AMMO_VALUE 5
#define CG_PLAYER_AMMO_BACKDROP 6

That might be what I need.

Thanks anyway :D