AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Use Key Command (https://forums.alliedmods.net/showthread.php?t=48626)

Minimum 12-16-2006 16:39

Use Key Command
 
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.

Emp` 12-16-2006 17:13

Re: Use Key Command
 
Code:

new buttons = get_user_button(id)
if(buttons&IN_USE){
  //do code
}

note that you'll probably do this in client_prethink

Minimum 12-16-2006 17:34

Re: Use Key Command
 
Thanks.

VEN 01-01-2007 21:39

Re: Use Key Command
 
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)

ebilschnitzel 04-11-2008 11:32

Re: Use Key Command
 
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*

Exolent[jNr] 04-11-2008 11:32

Re: Use Key Command
 
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".

ebilschnitzel 04-11-2008 11:34

Re: Use Key Command
 
So i could detect for example the "snapshot" key for this menu right?

Exolent[jNr] 04-11-2008 11:35

Re: Use Key Command
 
Yes, but not with pev(index, pev_button).
You will have to register the command.

ebilschnitzel 04-11-2008 11:37

Re: Use Key Command
 
Quote:

Originally Posted by X-olent (Post 609779)
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")*

Exolent[jNr] 04-11-2008 11:41

Re: Use Key Command
 
Just show them a menu when they join asking them if they want their [key] changed to [bind].
And if yes, change it.


All times are GMT -4. The time now is 06:54.

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