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

Members Online

»
1 Active | 49 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: Ingame HUD
r00t_
General Member
Since: Dec 15, 2010
Posts: 51
Last: May 16, 2011
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Wednesday, Jan. 12, 2011 07:21 pm
Hi there,
I've recently noticed on a few well-modded cod2 servers that it is possible to add text and content to the HUD ingame. I believe this is done with .gsc files, but I'm not really sure (because I used to think it was done with .menu files). I believe all this is done with things called "shaders". But again, I'm not really sure.

If there's anyone that can shed some light on the topic, that would be great!
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Jan. 12, 2011 11:14 pm
yes you could put a shader for a hud, but diffrent for a text.

Code:
level.texthud = newHudElem();
		level.texthud.x = 267;
		level.texthud.y = 100;
		level.texthud setText(game["text"]);


that will make a hud in the middle of your screen basicly with a text, but not done yet notice game["text"], you now have to make that hold a string.

Code:
game["text"] = &"Hello I Am Your Text!";
	precacheString(game["text"]);


now this would be different if you wanted a shader instead of, setText. you want setShader somthing like this

setShader("black", 640, 480);

the first perimeter is the Material Name the 2nd is Width and the 3rd is Height

but sadly does not end there yet for shaders, just like you had to do with the game["text"], you have to precache it. IMPORTANT: REMEMBER TO PRECACHE everything in your main function. so before any of your scripts basicly you want to precache it or else you will get an error.

now moving on the way to precache a shader is doing this.

precacheShader("black");

now keep in mind that White and Black are default shaders, but there are also plenty of default shaders but White and Black are used frequently and most the time already precached for you already.
Share |
clanhelio
General Member
Since: Aug 30, 2008
Posts: 223
Last: Mar 24, 2011
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Friday, Jan. 14, 2011 10:47 am
look through the mod or docs [ohwell]
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Friday, Jan. 14, 2011 11:04 am
Unprecached text can be shown too, but requires a lot more effort. Im gonna try that in the future :D for some cod4 style intro text :D
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Jan. 14, 2011 01:27 pm
well mr "i like to take the easy route" lol [thumbs_up] its best if they get use to precaching somthing because i use to do the same thing and at first no errors. but then after a while id get errors. so its good to know about precaching before you start taking the easy way out.
Share |
r00t_
General Member
Since: Dec 15, 2010
Posts: 51
Last: May 16, 2011
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Tuesday, Jan. 18, 2011 12:03 am
If i have a dynamic text i want to display, do i have to precache it everytime i change what the text is?

And, if i want to display the value of a variable in the text, how would i do it?

Like this?
Code:
game["text"] = &"Money = " + self.money; 
precacheString(game["text"]);


Or like this?
Code:
game["text"] = &"Money = ", self.money; 
precacheString(game["text"]);
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Tuesday, Jan. 18, 2011 12:57 am
r00t_ writes...
Quote:
If i have a dynamic text i want to display, do i have to precache it everytime i change what the text is?

And, if i want to display the value of a variable in the text, how would i do it?

Like this?
Code:
game["text"] = &"Money = " + self.money; 
precacheString(game["text"]);


Or like this?
Code:
game["text"] = &"Money = ", self.money; 
precacheString(game["text"]);

Neither.
game["text"]=&"Money";
hud.label=game["money"];
hud.value=self.money;
(maybe it was setvalue... im not sure)
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Tuesday, Jan. 18, 2011 01:54 am
setValue(self.money);

actually wondering my self right now, what is the difference of having & and no &. like this game["text"]=&"Money"; what if i didnt have the &. but anyways there are documents on what to use for huds you should start using it. its in your Doc folder in your Call of Duty 2 folder.
Share |
r00t_
General Member
Since: Dec 15, 2010
Posts: 51
Last: May 16, 2011
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Tuesday, Jan. 18, 2011 02:52 am
IzNoGoD writes...
Quote:

Neither.
game["text"]=&"Money";
hud.label=game["money"];
hud.value=self.money;
(maybe it was setvalue... im not sure)


I don't understand this at all.
All i want to do is make this appear on screen (somewhere in the lower left corner, for example):
YOU'RE MONEY: $500

And obviously have the 500 change when the player get's more money or loses money (the 500 would be a variable, obviously). If you already knew all this, then my bad, i just don't understand this explanation.. [crazy]
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Tuesday, Jan. 18, 2011 07:08 am
well first think... what is a hud? hud = heads up display. now what game modes that are in my reach that have huds? well all the gametype files have a hud, but for this instance you could look at the sd.gsc. now

Code:
level.clock = newHudElem();
	level.clock.horzAlign = "left";
	level.clock.vertAlign = "top";
	level.clock.x = 8;
	level.clock.y = 2;
	level.clock.font = "default";
	level.clock.fontscale = 2;
	level.clock setTimer(level.roundlength * 60);


that is what a hud looks like, this what shows the time limit on SD at the top left of your screen. now what iznogod showed you

Code:
game["text"]=&"Money";
hud.label=game["text"];


now what you can do with that is.

Code:
level.clock = newHudElem();
	level.clock.horzAlign = "left";
	level.clock.vertAlign = "top";
	level.clock.x = 8;
	level.clock.y = 2;
	level.clock.font = "default";
	level.clock.fontscale = 2;
        level.label=game["text"]
	level.clock setTimer(level.roundlength * 60);


and ofc
Code:
game["text"]=&"Money";
will go in your main() func. but what that code above will do is print the round length and a text saying Money. but you dont want setTimer you want to set an integer, wich self.money = int. so what you do is level.clock setValue(self.money); that way it will print how much money you have. but as well you want to look out for is

Code:
level.clock = newHudElem();


ofc you want it to print what SELF has not level... so you want to change level.clock to self.clock (ps: you dont need to have it as clock you can change that to w.e) anyways that solves 1 problem to that. notice it says newHudElem(); that is only for level. for self. you want newClientHudElem(self); i hope this clears a few things up for you about huds.
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

»