Raised This Month: $ Target: $400
 0% 

Use Key Command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Minimum
Senior Member
Join Date: Jun 2006
Old 12-16-2006 , 16:39   Use Key Command
Reply With Quote #1

I want to make so when a player presses their use key or E then it executes a function like a normal command. The problem is when I registered +use as a command it wouldn't work. I know there is a way around this because I have seen it done on multiple servers. I don't care if it does it with +use or when the player presses the E key. I just want to know how.
Minimum is offline
Send a message via AIM to Minimum Send a message via MSN to Minimum
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 12-16-2006 , 17:13   Re: Use Key Command
Reply With Quote #2

Code:
new buttons = get_user_button(id)
if(buttons&IN_USE){
  //do code
}
note that you'll probably do this in client_prethink
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Minimum
Senior Member
Join Date: Jun 2006
Old 12-16-2006 , 17:34   Re: Use Key Command
Reply With Quote #3

Thanks.
Minimum is offline
Send a message via AIM to Minimum Send a message via MSN to Minimum
VEN
Veteran Member
Join Date: Jan 2005
Old 01-01-2007 , 21:39   Re: Use Key Command
Reply With Quote #4

Actually it's necessary to check oldbuttons too:
Quote:
(entity_get_int(id, EV_INT_button) & IN_USE) && !(entity_get_int(id, EV_INT_oldbuttons) & IN_USE)
VEN is offline
Old 04-11-2008, 11:28
ebilschnitzel
This message has been deleted by ebilschnitzel. Reason: doublepost ><
ebilschnitzel
Junior Member
Join Date: Apr 2008
Old 04-11-2008 , 11:32   Re: Use Key Command
Reply With Quote #5

Hi there,

im working on an updated Diablomod and want to know how and if its possible to put a "menu" to a Key like Use.

I want to set F1 or F2...and so on as menu key, i hope you understand.

Here's a little bit of the code in client_prethink:

Code:
 
 //USE Button actives USEMAGIC
 if (pev(id,pev_button) & IN_USE )
 Use_Spell(id)
Use is used for magic...

Code:
 
 //F?? Button actives Menu
 if (pev(id,pev_button) & ??? )
 showmenu(id)
"F12" doesnt work and the search on the forums didnt help...

Can you guys help me please? Thanks in advance ^^

Regards*
ebilschnitzel is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-11-2008 , 11:32   Re: Use Key Command
Reply With Quote #6

You can't detect the key that a player is pressing, only the bind that it is bound to.
So, you aren't really detecting the pressing of the use key, you are detecting the execution of "+use".
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
ebilschnitzel
Junior Member
Join Date: Apr 2008
Old 04-11-2008 , 11:34   Re: Use Key Command
Reply With Quote #7

So i could detect for example the "snapshot" key for this menu right?
ebilschnitzel is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-11-2008 , 11:35   Re: Use Key Command
Reply With Quote #8

Yes, but not with pev(index, pev_button).
You will have to register the command.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
ebilschnitzel
Junior Member
Join Date: Apr 2008
Old 04-11-2008 , 11:37   Re: Use Key Command
Reply With Quote #9

Quote:
Originally Posted by X-olent View Post
Yes, but not with pev(index, pev_button).
You will have to register the command.
Thats the problem, many people on my / our server dont know how to bind this stuff and so on they dont read the messages / or dont understand what "type /menu in chat" means...

What keys / actions from the client could i use that arent used often in cs but bound to a key?

I hope you understand what i mean...

BTW its already registered thats not the problem ^^


*register_clcmd("menu","showmenu")*

Last edited by ebilschnitzel; 04-11-2008 at 11:39.
ebilschnitzel is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-11-2008 , 11:41   Re: Use Key Command
Reply With Quote #10

Just show them a menu when they join asking them if they want their [key] changed to [bind].
And if yes, change it.
__________________
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 06:54.


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