AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to write the code Press button E twice? (https://forums.alliedmods.net/showthread.php?t=143787)

Jacob 11-24-2010 20:58

how to write the code Press button E twice?
 
look title.
thx in advance.

fysiks 11-24-2010 21:32

Re: how to write the code Press button E twice?
 
in prethink forward you would have to look for a patter like this:

Code:

(new_buttons & IN_USE) && !(old_buttons & IN_USE)
!(new_buttons & IN_USE) && (old_buttons & IN_USE)
(new_buttons & IN_USE) && !(old_buttons & IN_USE)
!(new_buttons & IN_USE) && (old_buttons & IN_USE)

Search the scripting forum for code that shows you how to detect the +use button then modify it. You will need to put in a time check to see if the two button presses were close together (in time).

Exolent[jNr] 11-24-2010 21:34

Re: how to write the code Press button E twice?
 
Quote:

Originally Posted by fysiks (Post 1356122)
in prethink forward you would have to look for a patter like this:

Code:

(new_buttons & IN_USE) && !(old_buttons & IN_USE)
!(new_buttons & IN_USE) && (old_buttons & IN_USE)
(new_buttons & IN_USE) && !(old_buttons & IN_USE)
!(new_buttons & IN_USE) && (old_buttons & IN_USE)

Search the scripting forum for code that shows you how to detect the +use button then modify it. You will need to put in a time check to see if the two button presses were close together (in time).

Terrible method.

You should hook Ham_ObjectCaps to detect when use key was pressed.
To check if player pressed use key twice, save the gametime of when the player presses the button and compare that to the current gametime to see how long ago it was when player pressed use key.

fysiks 11-24-2010 22:39

Re: how to write the code Press button E twice?
 
Quote:

Originally Posted by Exolent[jNr] (Post 1356125)
Terrible method.

You should hook Ham_ObjectCaps to detect when use key was pressed.
To check if player pressed use key twice, save the gametime of when the player presses the button and compare that to the current gametime to see how long ago it was when player pressed use key.

lol, That's what I've seen used all the time. Never seen anyone suggest Ham_ObjectCaps when people ask for 'hooking' +use.

Jacob 11-24-2010 23:26

Re: how to write the code Press button E twice?
 
Quote:

Originally Posted by Exolent[jNr] (Post 1356125)
Terrible method.

You should hook Ham_ObjectCaps to detect when use key was pressed.
To check if player pressed use key twice, save the gametime of when the player presses the button and compare that to the current gametime to see how long ago it was when player pressed use key.

Exolent,help me to write the complele code,please.

Exolent[jNr] 11-24-2010 23:36

Re: how to write the code Press button E twice?
 
Quote:

Originally Posted by fysiks (Post 1356147)
lol, That's what I've seen used all the time. Never seen anyone suggest Ham_ObjectCaps when people ask for 'hooking' +use.

It's nothing new or anything.
https://forums.alliedmods.net/search...Ham_ObjectCaps

Quote:

Originally Posted by Jacob (Post 1356154)
Exolent,help me to write the complele code,please.

I will not give the code to copy&paste.
I have told you what to do and since you are in Scripting Help then you are expected to make it yourself.
It's not like I'm telling you how to do something complicated.

Jacob 11-25-2010 03:12

Re: how to write the code Press button E twice?
 
thank you a lot!!


All times are GMT -4. The time now is 11:20.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.