Raised This Month: $ Target: $400
 0% 

Solved Check Button Pressed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hey
Member
Join Date: Dec 2017
Old 01-18-2018 , 10:20   Check Button Pressed
Reply With Quote #1

Hi i am trying to check if player is holding N button but i can't find how i can make the check, anyone have any idea ?

EDIT:
here is the solution

Last edited by Hey; 01-19-2018 at 21:01. Reason: Solution Found
Hey is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 01-18-2018 , 10:35   Re: Check Button Pressed
Reply With Quote #2

You can`t directly check if player has pressed the button. You can only hook the commands these buttons trigger. such as nightvision in your case.
__________________
retired chump
DjSoftero is offline
Hey
Member
Join Date: Dec 2017
Old 01-18-2018 , 13:11   Re: Check Button Pressed
Reply With Quote #3

yeah i know but how can i do that, i need a example code.

like i know this:
PHP Code:
if(get_user_button(id) & IN_*) // what's the nightvision button called ??
{
     
// something

Hey is offline
Old 01-18-2018, 13:27
raizo11
This message has been deleted by raizo11.
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-18-2018 , 13:34   Re: Check Button Pressed
Reply With Quote #4

There is no nightvision button. Register the "nightvision" command as you would register any other client command.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Hey
Member
Join Date: Dec 2017
Old 01-18-2018 , 14:22   Re: Check Button Pressed
Reply With Quote #5

i can't really check if a player is holding the "Nightvision" N Command/Button ?
So i can only hook it and do something when press it, like this code:
PHP Code:
public plugin_init()
{
     
register_clcmd("nightvision""hook_command");
}
public 
hook_command(id)
{
    
// do something

Hey is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-18-2018 , 14:51   Re: Check Button Pressed
Reply With Quote #6

That's how you hook it. I don't think you can do something to detect if he's holding the command or simply pressing it.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Hey
Member
Join Date: Dec 2017
Old 01-18-2018 , 18:00   Re: Check Button Pressed
Reply With Quote #7

Oh well... :/ Thanks anyway guys.
Hey is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 01-19-2018 , 14:29   Re: Check Button Pressed
Reply With Quote #8

You can check 'hold' only at the IN_* buttons.
__________________
My English is A0
E1_531G is offline
Hey
Member
Join Date: Dec 2017
Old 01-19-2018 , 16:35   Re: Check Button Pressed
Reply With Quote #9

yeah i figured it out.. it would be much better if AMXX had a functions for checking like(OnButtonPressed, OnButtonReleased...) with all buttons supported, like it wouldn't hurt anyone :/.
Hey is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-19-2018 , 20:08   Re: Check Button Pressed
Reply With Quote #10

It is completely unnecessary to know what key board buttons are being pressed. The server only needs to know which commands are being sent.

IIRC, there are commands that indicate "OnButtonPressed" and "OnButtonRelease" and these are the + and - commands. If I bind a key to "+cmd" then you should be able to register both "+cmd" and "-cmd" as client commands (with register_clcmd()) and they will be called when the button is pressed and released, respectively. Try it out and see if it works for you.
__________________
fysiks 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 23:59.


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