MODSonline Subscriptions
View in iTunes
Please help us to raise in the ranks of podcasting and subscribe to our itunes feed using the link above.
The next MODSonair show will air LIVE on:
03/21/2010 12:03 EDT

Time remaining:
We Dontated to PixelEquity
"Modding refers to the act of modifying a piece of hardware or software or anything else for that matter, to perform a function not originally conceived or intended by the designer." 4
 
Site News   |   Aggregated News   |   Forums   |   Tutorials   |   Downloads   |   Projects   |   Weblinks
Latest Forum Threads 
CoD4 MP Mapping.. Posts: (2) Views: (41) by cskiller86
CoD4 Scripting.. Posts: (9) Views: (244) by DemonSeed
CoD2 MP Mapping.. Posts: (12) Views: (94) by StrYdeR
CoDUO Mapping.. Posts: (5) Views: (70) by sternkaa
MODSon-air.. Posts: (1) Views: (22) by foyleman
General Gaming.. Posts: (4) Views: (103) by techno2sl
Back to Home Page
MODSCON 2010 L4D2 Contest
Art of War Central
 
Forums
MODSonline.com 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, StrYdeR, techno2sl, batistablr, Welshy, Rasta, supersword, batistablr, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Restricted Access subscribe
Author Topic: Trigger Help!!!
hyper1234
General Member
Since: Mar 17, 2009
Posts: 129
Last: Mar 17, 2010
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Sunday, Jul. 5, 2009 02:35 pm
Hi there. I need some help with a script. I dont actually have a script yet but i was wondering if it is possible to exec a command with a trigger so that it opens a custom menu. Lets say that the custom menu was called weapon.menu Does anybody know the commands/script for this type of script?

Reminder: Trigger opens a menu ingame
DemonSeed
General Member
Since: Apr 30, 2009
Posts: 969
Last: Mar 19, 2010
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, Jul. 5, 2009 03:22 pm
Very basic, but this would do it:

Code:
init()
{
	trigger = getEnt( "triggername", "targetname" );
	trigger thread trigger_think();
}

trigger_think()
{
	for( ;; )
	{
		self waittill( "trigger", player );
		
		if( isPlayer( player ) )
		{
			while( isAlive( player ) && player isTouching( self ) )
			{
				if( player.pers["team"] == "allies" )
					player openMenu( game["menu_weapon_allies"] );
				else if( player.pers["team"] == "axis" )
					player openMenu( game["menu_weapon_axis"] );
			}
			
			wait 0.05;
		}
	
	}
}
hyper1234
General Member
Since: Mar 17, 2009
Posts: 129
Last: Mar 17, 2010
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Sunday, Jul. 5, 2009 05:13 pm
Thanks a lot mate. It worked but there was a problem. See...ive got this shop script, and what i want to happen is, u press the trigger and it opens up a custom menu, within that menu it has the gun and the amount mof money/points needed to purchase it. I can make the menu, i can exec the commands etc. thats easy stuff. But, lets say i made a menu called flicker.menu ok. In my map, what folder would i have to create, is it like modding, ui_mp and the scriptmenus and then put it there? or is it something else. When ive got it placed in the right folder lets say what i just said, would this be the command.

Quote:
init()
{
trigger = getEnt( "triggername", "targetname" );
trigger thread trigger_think();
}

trigger_think()
{
for( ;; )
{
self waittill( "trigger", player );

if( isPlayer( player ) )
{
while( isAlive( player ) && player isTouching( self ) )
{
if( player.pers["team"] == "allies" )
player openMenu( game["flicker_menu"] );
else if( player.pers["team"] == "axis" )
player openMenu( game["flicker_menu"] );
}

wait 0.05;
}

}
}


Please message back asap please. Thanks for the help.

ONE more thing...when i pressed it, i got a huge lag for like 3 seconds, then the menu opened, i chose the american weapon and then i respawned with it, i went back t press the button again and it wouldnt open the menu.

Hopefully you could help me with all of this, appreciate it if you can only help me alittle. Thanks again
clanhelio
General Member
Since: Aug 30, 2008
Posts: 113
Last: Feb 28, 2010
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Sunday, Jul. 5, 2009 06:10 pm
Code:
while( isAlive( player ) && player isTouching( self ) )
{
if( player.pers["team"] == "allies" )
player openMenu( game["flicker_menu"] );
else if( player.pers["team"] == "axis" )
player openMenu( game["flicker_menu"] );
}

Why are you telling it to open the menu while you're alive and touching the trigger? It's going to repeatedly tell the game for you to open the flicker menu over and over and over.
hyper1234
General Member
Since: Mar 17, 2009
Posts: 129
Last: Mar 17, 2010
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Sunday, Jul. 5, 2009 06:34 pm
because i am making a shop menu so that when you go to the trigger, i press the trigger and a menu comeds up (flicker_menu) and then in that menu are buttons and if u have the right aount of cash, u can buy a gun. then it will close once youve bought it.

When ive created my menu, do you know which folders i have to put it in for the command to work? thanks again
clanhelio
General Member
Since: Aug 30, 2008
Posts: 113
Last: Feb 28, 2010
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Monday, Jul. 6, 2009 04:00 pm
Um, this should do the trick ,you press the button and a menu opens. Not sure what the checking if the player was alive and touching the trigger was about, but I took that out.

Code:
init()
{
	trigger = getEnt( "triggername", "targetname" );
	trigger thread trigger_think();
}

trigger_think()
{
	for( ;; )
	{
		self waittill( "trigger", player );
				if( player.pers["team"] == "allies" )
					player openMenu( game["menu_weapon_allies"] );
				else if( player.pers["team"] == "axis" )
					player openMenu( game["menu_weapon_axis"] );
	}
}


edited on Jul. 6, 2009 04:01 pm by clanhelio
hyper1234
General Member
Since: Mar 17, 2009
Posts: 129
Last: Mar 17, 2010
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Tuesday, Jul. 7, 2009 03:19 am
thanks for the reply but,like ive said, i want to add a custom menu so, what is the command i would hsave to do...this?

Code:
init()
{
	trigger = getEnt( "triggername", "targetname" );
	trigger thread trigger_think();
}

trigger_think()
{
	for( ;; )
	{
		self waittill( "trigger", player );
				if( player.pers["team"] == "allies" )
					player openMenu( game["flicker"] );
				else if( player.pers["team"] == "axis" )
					player openMenu( game["flicker"] );
	}
}


If this is correct, where do i put the menu script in my iwd file so that the command executes the correct menu?

Thanks again [thumbs_up]
clanhelio
General Member
Since: Aug 30, 2008
Posts: 113
Last: Feb 28, 2010
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Tuesday, Jul. 7, 2009 02:54 pm
This should work, but I don't understand your second question...
The .menu files? ui_mp/scriptmenus/
Code:
init()
{
	game["flicker_menu"] = "flicker";
	precacheMenu(game["flicker_menu"]);
	
	trigger = getEnt( "triggername", "targetname" );
	trigger thread trigger_think();
}

trigger_think()
{
	for( ;; )
	{
		self waittill( "trigger", player );
		player openMenu( game["flicker_menu"] );
	}
}


edited on Jul. 7, 2009 02:55 pm by clanhelio
hyper1234
General Member
Since: Mar 17, 2009
Posts: 129
Last: Mar 17, 2010
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Wednesday, Jul. 8, 2009 08:46 am
what i mean by it is that, in my iwd file with all the mapping files, is there a folder i must put my flicker.menu inside for it to run eg. ui_mp/scriptmenus/here and then the script will load it from here?
clanhelio
General Member
Since: Aug 30, 2008
Posts: 113
Last: Feb 28, 2010
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Wednesday, Jul. 8, 2009 05:36 pm
yes, ui_mp/scriptmenus/menuhere
Restricted Access Restricted Access subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting