Raised This Month: $ Target: $400
 0% 

Does AddCommandListener(OnUse, "+use"); work?


Post New Thread Reply   
 
Thread Tools Display Modes
Miu
Veteran Member
Join Date: Nov 2013
Old 06-08-2015 , 14:17   Re: Does AddCommandListener(OnUse, "+use"); work?
Reply With Quote #11

The command isn't sent to the server. The IN_USE flag will be there for every tick the key is held. Use Powerlord's code to check when the user first presses it.
Miu is offline
Mehis
Senior Member
Join Date: Mar 2013
Location: basement
Old 06-08-2015 , 14:20   Re: Does AddCommandListener(OnUse, "+use"); work?
Reply With Quote #12

I don't understand what's the problem in using OnPlayerRunCmd.

This works for me:
PHP Code:
public Action OnPlayerRunCmdint clientint &buttons )
{
    if ( 
buttons IN_USE && !( GetEntPropclientProp_Data"m_nOldButtons" ) & IN_USE ) )
    {
        
PrintToServer"Use key pressed." );
    }


Last edited by Mehis; 06-08-2015 at 14:20.
Mehis is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 06-08-2015 , 14:47   Re: Does AddCommandListener(OnUse, "+use"); work?
Reply With Quote #13

No, "use" also don't work.
Mitchell, i don't know what it only server-side, but RegConsoleCmd("+use", ConCmd); also not work.
Powerlord, ok, i don't understand in the first time what you want to say (language barrier), will try your code. thx.

Last edited by Kailo; 06-08-2015 at 14:58.
Kailo is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-08-2015 , 16:35   Re: Does AddCommandListener(OnUse, "+use"); work?
Reply With Quote #14

Quote:
Originally Posted by Mehis View Post
I don't understand what's the problem in using OnPlayerRunCmd.

This works for me:
PHP Code:
public Action OnPlayerRunCmdint clientint &buttons )
{
    if ( 
buttons IN_USE && !( GetEntPropclientProp_Data"m_nOldButtons" ) & IN_USE ) )
    {
        
PrintToServer"Use key pressed." );
    }

Hmm, I wasn't aware players had an m_nOldButtons. The More You Know!
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
psychonic

BAFFLED
Join Date: May 2008
Old 06-08-2015 , 17:13   Re: Does AddCommandListener(OnUse, "+use"); work?
Reply With Quote #15

If you're already doing logic in OnPlayerRunCmd, it's cheaper and cleaner to just store your own "oldbuttons".
psychonic is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 06-08-2015 , 17:24   Re: Does AddCommandListener(OnUse, "+use"); work?
Reply With Quote #16

tl;dr this topic, but I remember this nice tut, which might help you out.
KissLick is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 06-08-2015 , 18:32   Re: Does AddCommandListener(OnUse, "+use"); work?
Reply With Quote #17

Solved. I done that i want, thx to Powerlord.
Kailo is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 06-08-2015 , 19:18   Re: Does AddCommandListener(OnUse, "+use"); work?
Reply With Quote #18

Quote:
Originally Posted by KissLick View Post
tl;dr this topic, but I remember this nice tut, which might help you out.
Already suggested @ #2:

Quote:
Originally Posted by arne1288 View Post
And this one seem to have something useful too, including some examples.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL 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 15:46.


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