AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Any way to hook +use?. (https://forums.alliedmods.net/showthread.php?t=163776)

Korxu 08-03-2011 06:57

[SOLVED] Any way to hook +use?.
 
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.

Arkshine 08-03-2011 07:31

Re: Any way to hook +use?.
 
Hook Ham_ObjectCaps.

Diegorkable 08-03-2011 09:18

Re: Any way to hook +use?.
 
try

PHP Code:

register_clcmd("+use""MyFunction"


Arkshine 08-03-2011 09:27

Re: Any way to hook +use?.
 
No.

Korxu 08-03-2011 09:32

Re: Any way to hook +use?.
 
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 (Post 1524822)
try

PHP Code:

register_clcmd("+use""MyFunction"


:nono:, but thanks ;).

Arkshine 08-03-2011 09:35

Re: Any way to hook +use?.
 
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.

Korxu 08-03-2011 09:50

Re: Any way to hook +use?.
 
Quote:

Originally Posted by Arkshine (Post 1524833)
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?.

shivek 08-03-2011 10:05

Re: Any way to hook +use?.
 
Hey, this metod is good to hook other gamefunctions like slot6 or +jump?

Korxu 08-03-2011 10:08

Re: Any way to hook +use?.
 
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")
     
//...



shivek 08-03-2011 10:10

Re: Any way to hook +use?.
 
thanks for fast reply, i will test it later :)
@Edit:
Quote:

Originally Posted by Korxu (Post 1524852)
PHP Code:

public plugin_init() {
     
register_concmd("slot6""slot_hooked")
     
//...



not working ;/


All times are GMT -4. The time now is 03:23.

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