Raised This Month: $ Target: $400
 0% 

Detect +USE key


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
travo
Senior Member
Join Date: Aug 2006
Old 11-09-2007 , 19:04   Detect +USE key
Reply With Quote #1

is there a way to detect if the +USE "e" key is press in the plugin_init()?

what i want to do is, have a function called if anyone press the use key. Is there are way to do this in the init with an event or do i have to do it through client_PreThink?

It is only used to trigger my function so i dont need to know if its held and it isnt going to be pressed over and over, so i dont want it to be check excessively.

thanks
travo is offline
remix.cc
New Member
Join Date: May 2007
Old 11-10-2007 , 05:03   Re: Detect +USE key
Reply With Quote #2

PHP Code:
get_user_button(id)&IN_USE {
        
//code
    

maybe this will help...
remix.cc is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 11-10-2007 , 05:39   Re: Detect +USE key
Reply With Quote #3

plugin_init() is called when the plugin is initiallyzed, so no players on server then ! lol...
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 11-10-2007 , 09:58   Re: Detect +USE key
Reply With Quote #4

Quote:
Originally Posted by travo View Post
is there a way to detect if the +USE "e" key is press in the plugin_init()?

what i want to do is, have a function called if anyone press the use key. Is there are way to do this in the init with an event or do i have to do it through client_PreThink?

It is only used to trigger my function so i dont need to know if its held and it isnt going to be pressed over and over, so i dont want it to be check excessively.

thanks
You need to hook:
register_forward( FM_CmdStart, "CmdStart" )
Code:
public CmdStart( const id, const uc_handle, random_seed ) {     if ( !is_user_alive( id ) )         return FMRES_IGNORED     static buttons     buttons = get_uc( uc_handle, UC_Buttons )     if ( buttons & IN_USE )         // Do something here         buttons &= ~IN_USE // Block them from using perhaps?     set_uc( uc_handle, UC_Buttons, buttons ) // Update buttons then supercede     return FMRES_SUPERCEDE }
The above method activates when a user actually presses a button and other things.
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd
Orangutanz is offline
travo
Senior Member
Join Date: Aug 2006
Old 11-10-2007 , 11:58   Re: Detect +USE key
Reply With Quote #5

ohhh, thanks Orangutanz, exactly what i needed
travo is offline
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 11-10-2007 , 18:43   Re: Detect +USE key
Reply With Quote #6

k now, big question
FM_PreThink Vs. FM_CmdStart

Whats the diff? You can use both right? But when does FM_CmdStart get called compaired to PreThink ( All the time before you do something )
Styles is offline
Send a message via AIM to Styles
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 11-10-2007 , 18:56   Re: Detect +USE key
Reply With Quote #7

Fm_CmdStart is called when a command is issued by player.
PreThink is called on every player frame, that means MANY times per second.

Code:
UserCmd Constants 

 // Interpolation time on client
	UC_LerpMsec,		// short
	// Duration in ms of command
	UC_Msec,		// byte
	// Command view angles
	UC_ViewAngles,		// float array[3]
	
	// Intended velocities
	// Forward velocity
	UC_ForwardMove,		// float
	// Sideways velocity
	UC_SideMove,		// float
	// Upward velocity
	UC_UpMove,		// float
	// Light level at spot where we are standing
	UC_LightLevel,		// byte
	// Attack buttons
	UC_Buttons,		// unsigned short
	// Impulse command issued
	UC_Impulse,		// byte
	// Current weapon id
	UC_WeaponSelect,	// byte
	
	// Experimental player impact stuff
	UC_ImpactIndex,		// int
	UC_ImpactPosition	// float array[3]
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 11-13-2007 , 17:08   Re: Detect +USE key
Reply With Quote #8

Quote:
Originally Posted by Alka View Post
Fm_CmdStart is called when a command is issued by player.
PreThink is called on every player frame, that means MANY times per second.

Code:
UserCmd Constants 

 // Interpolation time on client
	UC_LerpMsec,		// short
	// Duration in ms of command
	UC_Msec,		// byte
	// Command view angles
	UC_ViewAngles,		// float array[3]
	
	// Intended velocities
	// Forward velocity
	UC_ForwardMove,		// float
	// Sideways velocity
	UC_SideMove,		// float
	// Upward velocity
	UC_UpMove,		// float
	// Light level at spot where we are standing
	UC_LightLevel,		// byte
	// Attack buttons
	UC_Buttons,		// unsigned short
	// Impulse command issued
	UC_Impulse,		// byte
	// Current weapon id
	UC_WeaponSelect,	// byte
	
	// Experimental player impact stuff
	UC_ImpactIndex,		// int
	UC_ImpactPosition	// float array[3]
Am I the only one who thinks that this is not actually right? Just having something writing into the console every cmdstart showed, that this thing is called as many times as pre/post thinks. Any suggestions?
__________________
alien is offline
Send a message via ICQ to alien
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 11-13-2007 , 19:48   Re: Detect +USE key
Reply With Quote #9

Quote:
Originally Posted by alien View Post
Am I the only one who thinks that this is not actually right? Just having something writing into the console every cmdstart showed, that this thing is called as many times as pre/post thinks. Any suggestions?
It more than likely is called near enough as pre/post think however this is called upon execution which gives you greater control and flexability with controls etc. Which you cannot get with pre/post.
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd
Orangutanz is offline
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 11-13-2007 , 20:16   Re: Detect +USE key
Reply With Quote #10

Thank you Orangutanz. May I have a couple of questions?

What are these?

#define FMRES_HANDLED 2 // Probably to block forward into the engine?
#define FMRES_SUPERCEDE 4 // To pass forward into the engine?
#define FMRES_IGNORED 1 // To ... well.
#define FMRES_OVERRIDE 3 // To lol. No idea!

And what's random_seed parameter?
__________________
alien is offline
Send a message via ICQ to alien
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:13.


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