Question about Keybinds in CoD4

Have a question you need to ask? Need help? Ask here!

Moderator: Core Staff

Post Reply
jeffy
CJ Wannabe
CJ Wannabe
Posts: 3
Joined: March 15th, 2011, 8:34 pm
Gamertag: [USAN]Jeff

Question about Keybinds in CoD4

Post by jeffy » March 15th, 2011, 8:43 pm

I hope someone can answer my question:

I want to script keybinds, to make a gametype, that allows you, to perform special ways of movement by pressing the key, what was written to Config.

That means, if somebody holds the space bar for over 2 Secounds, he should perform a powerjump. If he did a Powerjump and presses C, he should make an "air punch"

Well, the problem is, there is no funktion like "if( self c_buttonpressed() )"

So, could you guys help me, to understand, how you made the Menuresponse, like a custom Votebutton (Works the same)



If you want to know, what i want do do: I want to make a gametype called Crysis 2 (cry2 as g_gametype tag), that allows you, to perform the same movement like in Crysis 2 Multiplayer. So, I'd like, if somebody can help me. Of corss I'll Write Credits to the animated Welcome Message.

Thanks for help, mates.

Oh, Btw: I'm new to CoD Jumper, so please forgive, if this isn't the correct board.

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Question about Keybinds in CoD4

Post by IzNoGoD » March 15th, 2011, 9:34 pm

menuresponses cant monitor prolonged keypresses (no "keeping pressed" possible)

Maybe cod4 allows for if(self buttonpressed("c")) or smthing, but i wouldnt count on it (if any, buttonpressed() is the way to go)
LMGTFY!

Its not a glitch... Its the future!

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Question about Keybinds in CoD4

Post by Drofder2004 » March 16th, 2011, 12:21 pm

Only in Single player and on consoles can keypresses be detected.
You can create a menu bind for detecting keypress, but not key held.

You could maybe time between two keypresses and create a function accordingly.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

jeffy
CJ Wannabe
CJ Wannabe
Posts: 3
Joined: March 15th, 2011, 8:34 pm
Gamertag: [USAN]Jeff

Re: Question about Keybinds in CoD4

Post by jeffy » March 16th, 2011, 10:30 pm

Well, that's relative good news, but how to do it on an example?

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Question about Keybinds in CoD4

Post by Rezil » March 16th, 2011, 10:37 pm

Code: Select all

checkKeyPress(key) {
	while(1) {
		if(self buttonPressed(key)) iprintln("You are pressing the button: " +key);
		wait 0.25;
      }
}
Call on level.player in SP. Keys are for example "BUTTON_A", "BUTTON_B", etc. Untested but should work.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

jeffy
CJ Wannabe
CJ Wannabe
Posts: 3
Joined: March 15th, 2011, 8:34 pm
Gamertag: [USAN]Jeff

Re: Question about Keybinds in CoD4

Post by jeffy » March 17th, 2011, 4:58 pm

Well, i would like to get help, how to do such a thing in Multiplayer. How to make an invisible menu with a Menuresponse?


Edit:

1 Thing i found out:

Code: Select all

		itemDef
		{
			name			"window"
			visible			0 // makes the text invisible.
			rect			16 20 0 0
			origin			ORIGIN_QUICKMESSAGEWINDOW
			forecolor		1 1 1 1
			textfont		UI_FONT_NORMAL
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textscale		TEXTSIZE_SMALL
			textaligny		8
			text			"Powerjump_eneble" // justt, that i know, for what it is
			decoration
		}
		execKey "1" { close quickmessage; open quickcommands }// this is my question - see above!

close quiclmessage.... --> well, could I also call a thread with this? that'd be perfect.

like:

execKey "3" { self thread lol::init() }


Well, please tell - even, if it's possible only at a different way.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Question about Keybinds in CoD4

Post by Drofder2004 » March 17th, 2011, 7:10 pm

you do not call function from the menu files, you call "menu responses" and they are detected by a function in CoD that is then parsed and given the correct functions.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests