AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hook button release (https://forums.alliedmods.net/showthread.php?t=241248)

ezio_auditore 05-30-2014 22:10

Hook button release
 
How can i hook the frame in which a user released a button.
For instance, i was holding +use, i want to hook that frame in which i released the +use key.

fysiks 05-31-2014 01:24

Re: Hook button release
 
Check for IN_USE button and see when it stops being used.

ezio_auditore 05-31-2014 02:19

Re: Hook button release
 
Quote:

Originally Posted by fysiks (Post 2144683)
Check for IN_USE button and see when it stops being used.

exactly... I was not able to see when it was released so i asked

Backstabnoob 05-31-2014 05:35

Re: Hook button release
 
I'm sure there's a pdata offset for this. Checking if button & pev_oldbuttons && !(button & pev_button) is another way though.

DavidJr 05-31-2014 06:10

Re: Hook button release
 
I've one, but it will be checked every frame

PHP Code:

const m_afButtonReleased 247;

static 
iButton iButton get_pdata_int(iIndexm_afButtonReleased5);

if (
iButton IN_USE


ezio_auditore 05-31-2014 06:41

Re: Hook button release
 
ok...
and what is the difference b/w FM_CmdStart and FM_CmdEnd

Backstabnoob 05-31-2014 09:58

Re: Hook button release
 
I've never seen anyone use FM_CmdEnd, but I'd definitely give it a shot at least.

Black Rose 05-31-2014 13:48

Re: Hook button release
 
The difference is that they occur at different positions in time. The pre commands are used to block things. I don't have an official list of what happens but here's an example of how it could look:
Code:

CmdStart
CmdEnd
PreThink
AddToFullPack
PostThink

Or perhaps:
Code:

PreThink
CmdStart
AddToFullPack
CmdEnd
PostThink

In between those different engine functions there could be various things occurring making one better than the other to use in some occasions.

klippy 05-31-2014 13:48

Re: Hook button release
 
From HLSDK:
Quote:

CmdStart

We're about to run this usercmd for the specified player. We can set up groupinfo and masking here, etc.
This is the time to examine the usercmd for anything extra. This call happens even if think does not.
Quote:

CmdEnd

Each cmdstart is exactly matched with a cmd end, clean up any group trace flags, etc. here
So i believe CmdStart is to UserCmd stuff(and probably other movement-related stuff), and CmdEnd follows it, freeing memory and such?

fysiks 05-31-2014 23:38

Re: Hook button release
 
Quote:

Originally Posted by Backstabnoob (Post 2144729)
Checking if button & pev_oldbuttons && !(button & pev_button) is another way though.

Checking current and old buttons is what I was referring to.


All times are GMT -4. The time now is 09:47.

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