Page 1 of 1

Get Key Pressed

Posted: May 23rd, 2008, 11:22 pm
by Nightmare
Is there a function of some sort which can read in what button a player has pressed?
Mainly looking just for W,A,S,D . I know use and melee is possible, but those are functions for themselves.

Re: Get Key Pressed

Posted: May 24th, 2008, 8:17 pm
by Dizzy
Wow now is my chance to help NM


Here you go...

Here is levs code:

Code: Select all

_UseKey()
{
	self endon("end_saveposition_threads");

	for(;;)
	{
		if(self useButtonPressed())
		{
			catch_next = false;

			for(i=0; i<=0.30; i+=0.01)
			{
				if(catch_next && self useButtonPressed())
				{
					self thread checksave();
					wait 1;
					break;
				}
				else if(!(self useButtonPressed()))
					catch_next = true;

				wait 0.01;
			}
		}

		wait 0.05;
	}
}
Obviously UserButtonPressed(); is a function, so there is probably one for +forward because the cod makers use that function for the killcam you know when you push F to skip killcam...


There is probably one for walk and such or you can probably make your own using

+forward
+backwards
+moveleft
+moveright

Those are what your WASD keys are bound to...

Re: Get Key Pressed

Posted: May 24th, 2008, 8:49 pm
by Nightmare
Well Dizzy, that doesn't really help at all since I said I already knew about the use and melee.
I'll try the function KS gave in a bit.

Re: Get Key Pressed

Posted: May 25th, 2008, 6:28 am
by Nightmare
Ok KS, that didn't work, says it was an unknown function, so I am guessing that is only going to work in CoD4.
Anyone have any other ideas?

Re: Get Key Pressed

Posted: May 25th, 2008, 3:21 pm
by Drofder2004
No, you cannot detect key press other than Use, Melee and Attack.

Re: Get Key Pressed

Posted: May 25th, 2008, 3:30 pm
by Drofder2004
KillerSam wrote:It would seem an obvious thing to add - /moans
Detect Keypress has obvious flaws and would allow the creation of a pointless keylogger, most things can be detected in other ways.

Scripts have been made to detect leaning, you can detect mantle and climbing now, you can detect whena grenade is thrown, stance, aim-down-sight...

Re: Get Key Pressed

Posted: May 25th, 2008, 6:34 pm
by Nightmare
PM coming your way drof.