Raised This Month: $ Target: $400
 0% 

[SOLVED] Any way to hook +use?.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Korxu
Senior Member
Join Date: Sep 2010
Old 08-03-2011 , 06:57   [SOLVED] Any way to hook +use?.
Reply With Quote #1

Hi again.

I'm searching for a way to hook +use (E key) to do something. Actually, I'm using the forward "FM_CmdStart" but it's called many times and I only need when the player press +use key, I think that it isn't optimized, or am I wrong?. Another way to hook +use more optimized?.

Thanks guys, bye.
Korxu is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-03-2011 , 07:31   Re: Any way to hook +use?.
Reply With Quote #2

Hook Ham_ObjectCaps.
__________________
Arkshine is offline
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 08-03-2011 , 09:18   Re: Any way to hook +use?.
Reply With Quote #3

try

PHP Code:
register_clcmd("+use""MyFunction"
Diegorkable is offline
Korxu
Senior Member
Join Date: Sep 2010
Old 08-03-2011 , 09:32   Re: Any way to hook +use?.
Reply With Quote #4

Thanks Arshine. But if I leave the key pressed the funtion is execute a lot of times. How I can do to execute the funtion one time only when the key is pressed and don't execute more until the player press again the key?

Quote:
Originally Posted by Diegorkable View Post
try

PHP Code:
register_clcmd("+use""MyFunction"
, but thanks ;).
Korxu is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-03-2011 , 09:27   Re: Any way to hook +use?.
Reply With Quote #5

No.
__________________
Arkshine is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-03-2011 , 09:35   Re: Any way to hook +use?.
Reply With Quote #6

Just make a var. Set to 1 when the first +use is called, and make a check at the start if this var is set to 0.
__________________
Arkshine is offline
Korxu
Senior Member
Join Date: Sep 2010
Old 08-03-2011 , 09:50   Re: Any way to hook +use?.
Reply With Quote #7

Quote:
Originally Posted by Arkshine View Post
Just make a var. Set to 1 when the first +use is called, and make a check at the start if this var is set to 0.
But with it the player only can execute the funtion one time, the next is blocked by the var, no?.
Korxu is offline
shivek
Junior Member
Join Date: Aug 2011
Old 08-03-2011 , 10:05   Re: Any way to hook +use?.
Reply With Quote #8

Hey, this metod is good to hook other gamefunctions like slot6 or +jump?
shivek is offline
Korxu
Senior Member
Join Date: Sep 2010
Old 08-03-2011 , 10:08   Re: Any way to hook +use?.
Reply With Quote #9

To "slot6" you can use ->
PHP Code:
public plugin_init() {
     
register_concmd("slot6""slot_hooked")
     
//...

And for jump use ->
PHP Code:
public plugin_init() {
     
RegisterHam(Ham_Player_Jump"player""fw_user_jump")
     
//...

Korxu is offline
shivek
Junior Member
Join Date: Aug 2011
Old 08-03-2011 , 10:10   Re: Any way to hook +use?.
Reply With Quote #10

thanks for fast reply, i will test it later
@Edit:
Quote:
Originally Posted by Korxu View Post
PHP Code:
public plugin_init() {
     
register_concmd("slot6""slot_hooked")
     
//...

not working ;/

Last edited by shivek; 08-03-2011 at 11:01.
shivek is offline
Reply



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 03:23.


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