Raised This Month: $ Target: $400
 0% 

How to bind a key to a function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pantheon
Member
Join Date: Jan 2011
Old 01-12-2011 , 13:30   How to bind a key to a function
Reply With Quote #1

How do you do this?

I want it to be like in SH where you bind keys to power1 etc.
Pantheon is offline
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 01-12-2011 , 13:33   Re: How to bind a key to a function
Reply With Quote #2

Code:
register_clcmd("+bind", "FuncHolding") register_clcmd("-bind", "FuncReleased")
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
Pantheon
Member
Join Date: Jan 2011
Old 01-12-2011 , 18:49   Re: How to bind a key to a function
Reply With Quote #3

Quote:
Originally Posted by DarkGod View Post
Code:
register_clcmd("+bind", "FuncHolding") register_clcmd("-bind", "FuncReleased")
Could you explain usage on that command? Ingame and in code.
Pantheon is offline
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 01-12-2011 , 20:19   Re: How to bind a key to a function
Reply With Quote #4

... That's nothing specific.

When you hold down the key you have bound to +bind the function "FuncHolding" is called. When you release the key the function "FuncReleased" is called.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
Pantheon
Member
Join Date: Jan 2011
Old 01-12-2011 , 21:22   Re: How to bind a key to a function
Reply With Quote #5

Quote:
Originally Posted by DarkGod View Post
... That's nothing specific.

When you hold down the key you have bound to +bind the function "FuncHolding" is called. When you release the key the function "FuncReleased" is called.
PHP Code:
#include <amxmodx>

public plugin_init() {
    
register_clcmd("+bind""FuncHolding")
    
register_clcmd("-bind""FuncReleased")
}

public 
FuncHolding() 
    
client_print(0print_chat"Holding down key..")

public 
FuncReleased() 
    
client_print(0print_chat"Key released.."
So in theory, this would work?
Pantheon is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-12-2011 , 21:54   Re: How to bind a key to a function
Reply With Quote #6

Yes. However, that method does not work for detecting existing commands such as +jump or +use.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 01:56.


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