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

Members Online

»
0 Active | 50 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: Disable the button for a score
Moczulak
General Member
Since: Mar 30, 2009
Posts: 77
Last: Apr 8, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Tuesday, May. 1, 2012 09:59 pm
Hey all [wave]

I am trying to create a button that will be blocked, which will be visible but will be gray and will not action after mouse click.

Only when the 5 rank and button unlocks.
Look in my script:

Ps. Below script im save in format .gsc and im add thread in file zom.gsc to Callback_StartGameType()

Code:

init()
{
	for(;;)
	{
		level waittill("connected",player);
		player thread playerconnected();
	}
}
playerconnected()
{
	self endon("disconnect");
	
	self thread files\hud\hud_rank::hudLogo();
	self thread files\hud\hud_rank::hudText();
	self thread files\hud\hud_propertiesplayer::hudLogo();
	self thread files\hud\hud_propertiesplayer::hudText();
	
	for(;;)
	{
		wait 0.5;
		if(isDefined(self.rank) && self.rank <= 5)
		{
			self setClientCvar("ui_allow_crossbow", "1");
		}
		else
		{
			self setClientCvar("ui_allow_crossbow", "2");
		}
	}
}


And some weapon_american.menu:

Code:
		itemDef 
		{
			name			"button_crossbow"
			visible			1
			rect			0 0 170 18
			origin			ORIGIN_CHOICE1
			forecolor		NORMAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@MPUI_1_CROSSBOW"
			textfont		UI_FONT_NORMAL
			textscale		.28
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textalignx		5
			textaligny		14
			dvar			"ui_allow_crossbow"
			showDvar		{ "1" }

			action
			{
				play "mouse_click";

				scriptmenuresponse "crossbow_mp";
			}
			onFocus
			{
				hide m1carbine_info;

				play "mouse_over";

				show crossbow_info;
			}
		}
		itemDef 
		{
			name			"button_crossbow"
			visible			1
			rect			0 0 170 18
			origin			ORIGIN_CHOICE1
			forecolor		GLOBAL_DISABLED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@MPUI_1_CROSSBOW"
			textfont		UI_FONT_NORMAL
			textscale		.28
			textalignx		5
			textaligny		14
			dvar			"ui_allow_crossbow"
			showDvar		{ "2" }

			onFocus
			{
				hide m1carbine_info;

				play "mouse_over";

				show crossbow_info;
			}
		}


My problem is the appearance of the two buttons at one time in one place...
Then I gather that this script .gsc is not working properly... [banghead]

edited on May. 1, 2012 02:59 pm by Moczulak

edited on May. 1, 2012 03:00 pm by Moczulak

edited on May. 1, 2012 03:00 pm by Moczulak
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Tuesday, May. 1, 2012 10:24 pm
replace "dvar" in your menu file with "dvartest" for both items.

edited on May. 1, 2012 03:24 pm by IzNoGoD

Edit: for the rest of your script, try not to do this in a loop. It takes unneccesary resources (setclientdvars can cause errors if used extensively), but instead set it each time a user levels up and on connect.

Also, check in your script at the menuresponse if a user has the required rank before processing. Wouldnt be the first time a menu will be exploited in such a way.

edited on May. 1, 2012 03:26 pm by IzNoGoD



Edit2: you might find that lvl 5 does not yet unlock the button. Replace the <=5 with <5 in your script to fix this

edited on May. 1, 2012 03:27 pm by IzNoGoD

Edit3: if you use it this way, the button will also unlock if the level of the user is undefined. replace the && in your if with || to fix this.



edited on May. 1, 2012 03:28 pm by IzNoGoD

Edit4: now i have more edits in this post than you have. :P
Share |
Moczulak
General Member
Since: Mar 30, 2009
Posts: 77
Last: Apr 8, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Tuesday, May. 1, 2012 10:42 pm
Look.. again not works... please somebody help me...
I can not write good scripts based on cvarach so I ask you for help.
Code:

init()
{
	for(;;)
	{
		level waittill("connected",player);
		player thread playerconnected();
	}
}

playerconnected()
{
	self endon("disconnect");
	
	self thread files\hud\hud_rank::hudLogo();
	self thread files\hud\hud_rank::hudText();

	self thread files\hud\hud_propertiesplayer::hudLogo();
	self thread files\hud\hud_propertiesplayer::hudText();
		
	if(isDefined(self.rank) && self.rank < 5)
	{
		self setClientCvar("ui_allow_crossbow", "1");
	}
	else
	{
		self setClientCvar("ui_allow_crossbow", "2");
	}
}
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. 1, 2012 11:04 pm
to me it seems like we have been helping you out on way to many easy scripts and its time for you to LEARN [eek]. scary word i know. but by looking at your code you dont even know the basics of operators!?!? and what you are to lazy to look into stock menu files and figure out how they made it so you cant select Axis team after you already picked the Axis team... come on. all the resources are right there in your face! open up iw_06.iwd and go threw the menus and figure out how they did it. its really not so hard i mean if you can "understand" these tough scripts you have already why cant you do the basics? ... just give it a shot.
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Wednesday, May. 2, 2012 05:58 am
IT IS IN THE .MENU FILE, NOT IN THE SCRIPT FILE!

READ MY POST AGAIN!
Share |
Moczulak
General Member
Since: Mar 30, 2009
Posts: 77
Last: Apr 8, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Wednesday, May. 2, 2012 04:57 pm
Look.. again not works :(
Code:
	itemDef 
		{
			name			"button_crossbow"
			visible			1
			rect			0 0 170 18
			origin			ORIGIN_CHOICE1
			forecolor		NORMAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@MPUI_1_CROSSBOW"
			textfont		UI_FONT_NORMAL
			textscale		.28
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textalignx		5
			textaligny		14
			dvartest		"scr_allow_crossbow"
			showDvar		{ "1" }<br />
<br />
			action
			{
				play "mouse_click";<br />
<br />
				scriptmenuresponse "crossbow_mp";
			}
			onFocus
			{
				hide m1carbine_info;<br />
<br />
				play "mouse_over";<br />
<br />
				show crossbow_info;
			}
		}
		itemDef 
		{
			name			"button_crossbow"
			visible			1
			rect			0 0 170 18
			origin			ORIGIN_CHOICE1
			forecolor		GLOBAL_DISABLED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@MPUI_1_CROSSBOW"
			textfont		UI_FONT_NORMAL
			textscale		.28
			textalignx		5
			textaligny		14
			dvartest		"scr_allow_crossbow"
			showDvar		{ "2" }<br />
<br />
			onFocus
			{
				hide m1carbine_info;<br />
<br />
				play "mouse_over";<br />
<br />
				show crossbow_info;
			}
		}


Code:
init()
{
	for(;;)
	{
		level waittill("connected",player);
		player thread playerconnected();
	}
}
playerconnected()
{
	self endon("disconnect");
	
	self thread files\hud\hud_rank::hudLogo();
	self thread files\hud\hud_rank::hudText();
	self thread files\hud\hud_propertiesplayer::hudLogo();
	self thread files\hud\hud_propertiesplayer::hudText();
	
	for(;;)
	{
		wait 0.5;
		
		if(isDefined(self.rank) && self.rank < 5)
		{
			self setClientCvar("scr_allow_crossbow", "1");
		}
		else
		{
			self setClientCvar("scr_allow_crossbow", "2");
		}
	}
}
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Wednesday, May. 2, 2012 06:18 pm
Try this:

Code:
		itemDef 
		{
			name			"button_crossbow"
			visible			1
			rect			0 0 170 18
			origin			ORIGIN_CHOICE1
			forecolor		NORMAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@MPUI_1_CROSSBOW"
			textfont		UI_FONT_NORMAL
			textscale		.28
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textalignx		5
			textaligny		14
			dvartest		"scr_allow_crossbow"
			showDvar		{ "1" }
			action
			{
				play "mouse_click";
				scriptmenuresponse "crossbow_mp";
			}
			onFocus
			{
				hide m1carbine_info;
				play "mouse_over";
				show crossbow_info;
			}
		}
		itemDef 
		{
			name			"button_crossbow"
			visible			1
			rect			0 0 170 18
			origin			ORIGIN_CHOICE1
			forecolor		GLOBAL_DISABLED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@MPUI_1_CROSSBOW"
			textfont		UI_FONT_NORMAL
			textscale		.28
			textalignx		5
			textaligny		14
			dvartest		"scr_allow_crossbow"
			hideDvar		{ "1" }
			onFocus
			{
				hide m1carbine_info;
				play "mouse_over";
				show crossbow_info;
			}
		}


Code:
init()
{
	level thread onPlayerConnect();
}<br />
<br />
onPlayerConnect()
{
	for(;;)
	{
		level waittill( "connected",player );
		
		player thread onJoinedTeam();
	}
}<br />
<br />
onJoinedTeam()
{
	self endon( "disconnect" );
	
	for(;;)
	{
		self waittill( "joined_team" );<br />
<br />
		self thread files\hud\hud_rank::hudLogo();
		self thread files\hud\hud_rank::hudText();
		self thread files\hud\hud_propertiesplayer::hudLogo();
		self thread files\hud\hud_propertiesplayer::hudText();
		
		if( isDefined(self.rank) && self.rank < 5 )
			self setClientCvar( "scr_allow_crossbow", "1" );
		else
			self setClientCvar( "scr_allow_crossbow", "0" );
	}
}
Share |
Moczulak
General Member
Since: Mar 30, 2009
Posts: 77
Last: Apr 8, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Thursday, May. 3, 2012 01:22 pm
Thanks Tally.. :P very thanks ;>
Share |
Moczulak
General Member
Since: Mar 30, 2009
Posts: 77
Last: Apr 8, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Sunday, May. 6, 2012 04:52 pm
My server does not hold a large amount cvars and off ..

how to fix this in the menu? otherwise you can manage to do these buttons to rank? or remedy the script?
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Sunday, May. 6, 2012 10:18 pm
IzNoGoD writes...
Quote:


Edit: for the rest of your script, try not to do this in a loop. It takes unneccesary resources (setclientdvars can cause errors if used extensively), but instead set it each time a user levels up and on connect.


Please read everything that gets posted in this thread. People might not take kindly to being ignored.
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

»