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

Members Online

»
0 Active | 61 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: working with menus
kimistatheone
General Member
Since: Mar 1, 2012
Posts: 47
Last: May 2, 2013
[view latest posts]
Level 2
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Monday, May. 21, 2012 02:47 pm
Hello. I started working with menus for the first time.

i want to show the players' name in the menu. how can i do this? for now i can only show simple texts
Code:

		itemDef 
		{
			name tittle_text
			text "settings"
			type ITEM_TYPE_TEXT
			textstyle ITEM_TEXTSTYLE_SHADOWED
			textscale 		0.4
			rect			0 0 50 24
			forecolor		GLOBAL_UNFOCUSED_COLOR
			origin			0 0
			visible		1
			textfont	UI_FONT_NORMAL
			textaligny		20
					 			
                 }


thx 4 helping
Share |
kimistatheone
General Member
Since: Mar 1, 2012
Posts: 47
Last: May 2, 2013
[view latest posts]
Level 2
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Monday, May. 21, 2012 07:19 pm
anyone?
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, May. 22, 2012 12:31 am
not so easy as you may expect. kinda long and annoying from my experience. you want to change that boring text though? instead of having text "settings" change text to dvar and sure keep it at "settings" but thats not your text anymore. its going to look for a dvar named "settings" and in there you could print your deaths if wanted to. or perhaps your NAME!? =O! getting interesting now huh? and to make this better for you to understand lets make your new menu branch off the ingame.menu. easyer to understand and follow along. so you understand the basics of making a button inside a menu? you need to make a button inside your ingame.menu that will open your new menu. BUT instead of simple...

EXAMPLE:
Code:
itemDef 
		{
			name			"button_leavegame"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICE5
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"5. Leave Game"
			textfont		UI_FONT_NORMAL
			textscale		GLOBAL_TEXT_SIZE
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
				close ingame;
				open leavegame; // <---- SIMPLE THAT!
			}
			onFocus
			{
				play "mouse_over";
			}
		}


going to replace it with a scriptmenuresponse! are you lost? dont worry i made a lame tutorial a while ago that somewhat will explain what a scriptmenuresponse does.

http://modsonline.com/Tutorials-read-762.html

so if you followed my tutorial you will see all i did was print out a text... instead of that you can open your new menu. BUT why not just open it the simple and plain boring way? well because when you open that menu we can the check "oh well is this new menu open? if so lets print out that COOL dvar i was talking about earlyer!" instead of putting a constant loop checking... is the menu open yet? now? yes? maybe? hopefully? no... this will save alot of memory this way. so when you check if your button was clicked to open your new menu INSIDE your _menus.gsc you want something similar to this.

Code:
if(response == "button") //example obv.
		{
			self closeMenu();
			self closeInGameMenu();
			self openMenu(game["menu_newmenu"]); //again its an example...
            self checkNewMenu(menu); // passing the argument "menu" so the new function knows what menu is.
		}
		
checkNewMenu(menu)
{
	if(menu == game["menu_newmenu"]) // this checks are you in your new menu yet? which you are ofc.
	{
		self setclientcvar("settings", self.name); // this looks for the dvar "settings" that i explained earlyer and prints out your name. 
	}
}


still does not answer your question fully BUT HEY!!! we learned something!? [thumbs_up]

im now tired from typing this out and ill try to complete your question in a next post in about 15 mins maybe.
Share |
kimistatheone
General Member
Since: Mar 1, 2012
Posts: 47
Last: May 2, 2013
[view latest posts]
Level 2
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Tuesday, May. 22, 2012 01:54 pm
okay, i can make a new menu, but how can i print a dcvar (for example the "settings")
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, May. 22, 2012 02:07 pm
so a dvar can do alot of things. atm you have
Code:
text "settings"


so lets say you changed it to
Code:
dvar "settings"


lets say you just saved that put it in your mod started up your game opened your menu. you wouldnt see a text saying "settings" like you would if you used
Code:
text "settings"


with a dvar you now need to fill in the blank. you now have a dvar NAMED "settings". you could put this dvar anywhere if you really wanted to. like when a player connects put the dvar as

Code:
self setclientcvar("settings", "RAWR!");


what that will do is set the dvar "settings" with a string saying "RAWR!". so when the player opens the menu he will see the text "RAWR!". PM me if you have anymore questions
Share |
kimistatheone
General Member
Since: Mar 1, 2012
Posts: 47
Last: May 2, 2013
[view latest posts]
Level 2
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Tuesday, May. 22, 2012 04:58 pm
good, thx, but i have a problem

i use
Code:
dvar "playername0" 


if i start a home server, it shows the names.
but if i upload the mod to ftp to my rented server, its not shows.
i tryed also
Code:
cvar "playername0"

but still not shows the names.

Share |
kimistatheone
General Member
Since: Mar 1, 2012
Posts: 47
Last: May 2, 2013
[view latest posts]
Level 2
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Tuesday, May. 22, 2012 10:05 pm
problem solved.

setcvar("playername0", "Peter") vs. self setclientcvar("playername0", "Peter")
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

»