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

Members Online

»
0 Active | 78 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 subscribe
Author Topic: HUD infront of Menu
Brokzor
General Member
Since: Feb 27, 2009
Posts: 22
Last: Jan 4, 2011
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Saturday, Dec. 18, 2010 12:49 pm
Heey,
i was wondering if it is possible to set the hud infront of a menu? So i created a text which should display in the menu. (I took my name).

As an example. I created a new menu which shows different infos about myself. But i created those infos with settext etc. and as soon as i pen up the menu, the text and all that other stuff dissappears. I want it to be on the menu.

Thx
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Saturday, Dec. 18, 2010 01:16 pm
No it isn't possible, menus always overlay the HUD, even if it isn't fullscreen.

Simply apply the text you want to display to the menu files and package them with your mod instead.

If the text is dynamic (it changes) then use cvars to set up the menu data.
Share |
Brokzor
General Member
Since: Feb 27, 2009
Posts: 22
Last: Jan 4, 2011
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Saturday, Dec. 18, 2010 01:28 pm
could you give me an example of the new menu file? And yeah the text is dynamic.
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Saturday, Dec. 18, 2010 03:58 pm
You need to add a new itemdef to the menu and position it as you want. Here is an example from serverinfo_sd.menu:

Code:
// MESSAGE OF THE DAY
itemDef
{
   name			"text_motd"
   visible			1
   rect			0 0 480 150
   origin			80 267
   forecolor		1 1 1 1
   autowrapped
   dvar			"ui_motd"
   textfont		UI_FONT_NORMAL
   textscale		0.25
   textstyle		ITEM_TEXTSTYLE_SHADOWED
   textaligny		16
   decoration
}


You can see that there is a parameter called 'dvar'. This specifies the dvar that provides the text for the element.

Using the above example (but obviously create your own dvar name) use something like the following in your script:

player setClientCvar("your_new_dvar_name","Text to Display");

When the menu is visible the text "Text to Display" will appear at the location specified for the dvar "your_new_dvar_name".

As for positioning, the origin sets the coordinate point where the element starts on the screen. The rect parameter sets the element position relative to the origin and then the height and width of the element, i.e.

rect xpos,ypos,width,height

Hope that helps.
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Saturday, Dec. 18, 2010 04:06 pm
You might use this thread to "type" text to the menu file.
Just wrote it for someone, think it might come in handy here :D

call it as a self thread with text being a string
cvar being a string that is a cvar
speed being a float/int, being characters per second
charsound being a string of a soundfile, which is played every time a character is typed.

so:
self thread writetexttocvar("Welcome to this server","ui_motd",5,"none");
Code:

writetexttocvar(text,cvar,speed,charsound)
{
	//call with "none" in charsound for silent typing
	self endon("disconnect");
	//self endon("killed_player");
	self endon("stop_typing_message");

	if(isdefined(text)&&isdefined(speed)&&isdefined(cvar)&&isdefined(charsound))
	{
		if(text.size>0)
		{
			waittime=int(20/speed)/20;
			if(waittime<=0)
				waittime=0.05;
			for(i=1;i<text.size;i++)
			{
				tempstr=getsubstr(text,0,i);
				if(text.size>i+2)
				{
					tmp=getsubstr(text,i,i+2);
					if(tmp=="^1"||tmp=="^2"||tmp=="^3"||tmp=="^4"||tmp=="^5"||tmp=="^6"||tmp=="^7"||tmp=="^8"||tmp=="^9"||tmp=="^0")
					{
						i+=2;
						continue;
					}
				}
				if(charsound!="none")
					self playlocalsound(charsound);
				self setclientcvar("cvar",tempstr);
				wait waittime;
			}
		}
	}
}
Share |
Brokzor
General Member
Since: Feb 27, 2009
Posts: 22
Last: Jan 4, 2011
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Saturday, Dec. 18, 2010 06:57 pm
how does getsubstr wrk? i mean what does this command do?
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Saturday, Dec. 18, 2010 07:34 pm
lets let var be a string with "Welcome" in it.
Then, getsubstr(var,0,2) will return "We"
getsubstr(var,2,3) will return "l"
getsubstr(var,0,var.size) will just return "Welcome"

gl with it
Share |
Brokzor
General Member
Since: Feb 27, 2009
Posts: 22
Last: Jan 4, 2011
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Saturday, Dec. 18, 2010 07:41 pm
ahh thank you, i think i got that!
Share |
Restricted Access Topic is Locked 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

»