EDIT: To start with a side-note, I
think that you can only add menu-files into a mod, not into a custom map (somebody please correct me If I'm wrong on this) since they have to be compiled into the mod. And in your case you're making a custom map I believe. Either way I'll try and do an explanation.
Okay, so whilst I'm not sure if this is the actual correct way to monitor a key press, this is my theoretical method of how it will work. (You should be able to find some menu files in ui_mp/scriptmenus in the mod tools to see the example layout and such).
Basically you create a menu that is not visible, and doesn't stop any of the player's inputs (mouse/movement etc). So for the player, even though this menu is open, their game still looks and plays exactly the same. However in the `invisible menu` there is an option for pressing mouse1, and hence when they attack (by pressing mouse1) it will trigger this menu option. See the code below.
Code: Select all
itemDef
{
name "window"
group ingamebox
type ITEM_TYPE_TEXT
visible 1
rect 16 20 0 0
origin ORIGIN_QUICKMESSAGEWINDOW
forecolor 1 1 1 1
textfont UI_FONT_NORMAL
textscale .24
textaligny 8
text "^21. Drop a Mine"
decoration
}
execKey "1" { scriptMenuResponse "special1"; close hunters_mod_menu; }
This is an example of something I had in a previous mod (for Black Ops, note - so everything may not be the same for CoD4). You would want to have execKey "mouse1" and then scriptMenuRespone "define_this_in_your_script". And then depending on the situation, if you still want to monitor them pressing the attack key you wouldn't close the menu, if you don't need to after, then you can close the menu as seen above.
Depending on when you want to monitor the key press, you place a line similar to this somewhere in your script.
Code: Select all
game[ "huntersmenu" ] = "hunters_mod_menu"; // these two lines at beginning of gsc
precacheMenu( game[ "huntersmenu" ] );
...
self openMenu( game["huntersmenu"] ); // this line wherever you want, eg. onPlayerSpawned if you want to monitor the key press as soon as a player spawns.
And finally, once the key press has been monitored, you make the player do whatever you want like so:
Code: Select all
onMenuResponse()
{
self endon( "death" );
self endon( "disconnect" );
while( true )
{
self waittill( "menuresponse", menu, response );
if( response == "special1" )
{
if(self.team == "axis")
self thread scare();
else
self thread dropmine();
}
}
}
Hopefully this kind of explains some stuff to you. Note that if the person didn't use mouse1 as their way of attacking it would not work (but I assume nearly everybody uses mouse1), so just keep this in mind.