Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 93 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: Hud images at a menu file
zerker
General Member
Since: Nov 15, 2007
Posts: 8
Last: Mar 18, 2013
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Saturday, Mar. 2, 2013 02:44 pm
Hello,

I'am not sure this is possible in CoD2 but it worth the try, is there anyway I can create a changeable-by-script image in a menu file such as ingame menu?

To be more clear, I want something other than just a background, like the dvar which can be edited from a gsc file but it's only text, I need for images.

It's about CoD2 Multiplayer.

Thanks for any help,
Zerker
Share |
zerker
General Member
Since: Nov 15, 2007
Posts: 8
Last: Mar 18, 2013
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Friday, Mar. 15, 2013 03:32 pm
Anyone? is it even possible?
Share |
Ni3ls
General Member
Since: Nov 7, 2008
Posts: 256
Last: Sep 9, 2017
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Friday, Mar. 15, 2013 05:47 pm
I dont think its possible. Maybe make a HUD that overwrite some things of the menu and then change the images
Share |
PatmanSan
General Member
Since: Jul 3, 2009
Posts: 8
Last: Feb 6, 2014
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Saturday, Mar. 16, 2013 01:18 am
Yes you can. Just use a "dvartest" in your itemDef:

Code:
		itemDef
		{
			name		"whatever"
			visible		0
			rect		0 0 224 112
			origin		ORIGIN_IMAGE
			style		WINDOW_STYLE_SHADER
			background	"image1"
			dvartest	"ui_image"
			showDvar	{ "";"1" }
			visible		1
			decoration
		}
		itemDef
		{
			name		"whatever"
			visible		0
			rect		0 0 224 112
			origin		ORIGIN_IMAGE
			style		WINDOW_STYLE_SHADER
			background	"image2"
			dvartest	"ui_image"
			showDvar	{ "2" }
			visible		1
			decoration
		}

In the example above image1 will show if cvar ui_image is either empty or 1, and image2 will show (same location) if cvar ui_image is set to 2.

You can control cvar ui_image from the server by using

self setClientCvar("ui_image", "1");
or
self setClientCvar("ui_image", "2");

Where "self" refers to the player's entity. It can be a different entity name, depending on how you script it.

Note that image1 and image2 are material names; not the actual shaders.
ORIGIN_IMAGE is a predefined variable, somewhere at the top of you menu file.

edited on Mar. 15, 2013 06:19 pm by PatmanSan

edited on Mar. 15, 2013 06:20 pm by PatmanSan
Share |
zerker
General Member
Since: Nov 15, 2007
Posts: 8
Last: Mar 18, 2013
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Saturday, Mar. 16, 2013 10:51 am
Thanks alot PatmanSan,

But I have already tried this method and it didn't work because I have lots of images that I want to put in one menu, and after I made itemDef for each one, the menu didn't load in game.

Do you think there is a maximum number of itemDef in CoD2?

Thanks,
Zerker
Share |
PatmanSan
General Member
Since: Jul 3, 2009
Posts: 8
Last: Feb 6, 2014
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Saturday, Mar. 16, 2013 12:09 pm
Yes there is a maximum for everything in COD. Numbers of menus, number of ItemDef, number of precached shaders, etc. I have a menu with 240 ItemDef blocks (no images), and it loads without problems.
The method does work, but only if you stay within the limits of course.

edited on Mar. 16, 2013 05:10 am by PatmanSan
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Saturday, Mar. 16, 2013 01:23 pm
try using macros!
less code, less errors!
ill give you a short example menu, cant test it by now, but this can be ur part ;)

Code:
#include "ui/menudef.h"

//vars are case-sensitive!
//you have to place a backslash \ after every row, except for the last one!
//you CANT use operators in menu files! (no +-*/) afaik || and && will work
//you can use multiple macros in a macro, but not in the menuDef itself!
//you can do any itemdef in here, buttons, text, frames...
//have fun, serthy

#define DRAW_DVARSHADER( _name , _rect , _dvar ) \
	itemDef \
	{ \
		name 			_name \
		rect 			_rect \
		style			WINDOW_STYLE_DVAR_SHADER \
		visible 		1 \
		decoration \
		dvar  			_dvar \
		dvartest  		_dvar \
		hideDvar \
		{  \
			""; \
		} \
	}

{
	menuDef 
	{
		name 						"testmenu"
		fullScreen 					0
		rect 						0 0 640 480
		focusColor 					GLOBAL_FOCUSED_COLOR
		
		onEsc
		{
			close testmenu;
		}

		DRAW_DVARSHADER( "image_1" , 10 80 64 64 , "ui_image_1" )
		DRAW_DVARSHADER( "image_2" , 70 80 64 64 , "ui_image_2" )
		DRAW_DVARSHADER( "image_3" , 130 80 64 64 , "ui_image_3" )
		DRAW_DVARSHADER( "image_4" , 190 80 64 64 , "ui_image_4" )
	}
}


Share |
zerker
General Member
Since: Nov 15, 2007
Posts: 8
Last: Mar 18, 2013
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Saturday, Mar. 16, 2013 03:16 pm
Yeah PatmanSan, it worked fine when I first used it, but after adding more itemDef's the menu didn't load, so it gotta be the annoying maximum number :/

Thanks Serthy, will give it a try and tell you the result :)
Share |
zerker
General Member
Since: Nov 15, 2007
Posts: 8
Last: Mar 18, 2013
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Saturday, Mar. 16, 2013 07:37 pm
Unfortunately, it didn't work too, same problem with maximum number of itemDef's (it's the same method, just less lines of code).

Is there anyway to disable the maximum number of itemDef's possible?
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Saturday, Mar. 16, 2013 07:41 pm
how many itemDef's are you using?
keep in mind if ther is only ONE syntax error, the whole menu wont be showed!
so trial'n'error every single menu, start with an almost empty menu and add step by step your items to it

if you exceeded the max itemDef's, just simple create another menuDef and add them there too
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»