AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   HELPME setting a key 4 any cmd (https://forums.alliedmods.net/showthread.php?t=237209)

Viveks326 03-20-2014 01:35

HELPME setting a key 4 any cmd
 
I wanna ask if for instance i have to set a key for a command like sentry_build so hw can i do so ?

DavidJr 03-20-2014 01:41

Re: HELPME setting a key 4 any cmd
 
With +Use button?

PHP Code:

public client_PreThink(iIndex)
{
       new 
iButton get_user_button(iIndex);
       
       if (
iButton == IN_USEclient_cmd(iIndex"sentry_build");



Baws 03-20-2014 22:11

Re: HELPME setting a key 4 any cmd
 
client_cmd don't work anymore i think.

Kiske 03-20-2014 23:32

Re: HELPME setting a key 4 any cmd
 
Quote:

Originally Posted by baws (Post 2114047)
client_cmd don't work anymore i think.

https://developer.valvesoftware.com/...in_Slowhacking

hornet 03-21-2014 06:25

Re: HELPME setting a key 4 any cmd
 
Quote:

Originally Posted by Viveks326 (Post 2113716)
I wanna ask if for instance i have to set a key for a command like sentry_build so hw can i do so ?

You can't choose a key as such, you can choose a command that is sent to the server.

Quote:

Originally Posted by DavidJr (Post 2113718)
With +Use button?

PHP Code:

public client_PreThink(iIndex)
{
       new 
iButton get_user_button(iIndex);
       
       if (
iButton == IN_USEclient_cmd(iIndex"sentry_build");



A poor method. Also in most cases bitwise ops should be & not == , because your checking for a certain key press, not that key by alone ( with no others present ).

Quote:

Originally Posted by baws (Post 2114047)
client_cmd don't work anymore i think.

It still works.

DavidJr 03-21-2014 09:37

Re: HELPME setting a key 4 any cmd
 
hornet, what about this? :3

PHP Code:

#define m_afButtonPressed 246
#define m_afButtonReleased 247 

public client_PreThink(iIndex)
{
    new 
iButtonPressediButtonReleased;
    
iButtonPressed get_pdata_int(iJndexm_afButtonPressedXO_PLAYER);
    
iButtonReleased get_pdata_int(iIndexm_afButtonReleasedXO_PLAYER);
    
    if (
iButtonPressed IN_SCORE)
    {
        
//button pressed
    
}
    else if (
iButtonReleased IN_SCORE)
    {
        
//button released
    
}



Baws 03-21-2014 17:16

Re: HELPME setting a key 4 any cmd
 
Off topic: Damn i always thought they removed it. Thanks for letting me know!

hornet 03-22-2014 02:05

Re: HELPME setting a key 4 any cmd
 
Quote:

Originally Posted by DavidJr (Post 2114171)
hornet, what about this? :3

PHP Code:

#define m_afButtonPressed 246
#define m_afButtonReleased 247 

public client_PreThink(iIndex)
{
    new 
iButtonPressediButtonReleased;
    
iButtonPressed get_pdata_int(iJndexm_afButtonPressedXO_PLAYER);
    
iButtonReleased get_pdata_int(iIndexm_afButtonReleasedXO_PLAYER);
    
    if (
iButtonPressed IN_SCORE)
    {
        
//button pressed
    
}
    else if (
iButtonReleased IN_SCORE)
    {
        
//button released
    
}



Essentially it is the same as your first post. The problem here is that using the PreThink forward just to check for a button is a waste of cpu, when there are other methods that can be used ( and you can't unregister the forward with engine module ). Not to mention that also the thread author did not specifically say what key / command he wants to hook.

DavidJr 03-22-2014 09:26

Re: HELPME setting a key 4 any cmd
 
So, what's a good method to detect button?

hornet 03-22-2014 11:49

Re: HELPME setting a key 4 any cmd
 
Quote:

Originally Posted by DavidJr (Post 2114472)
So, what's a good method to detect button?

Depends on what button.


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

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