View Single Post
Cookies.net
Senior Member
Join Date: Jan 2011
Old 06-12-2011 , 13:58   Re: [SNIPPET] Detecting button presses (and releases)
Reply With Quote #4

I just noticed this thread and tried this method and it doesn't work properly (tried it myself instead of the way i currently do it), here's my explanation (it might not be the best, but i guess its fine)

e.g. if "button" in this case = "IN_JUMP" then it would check the current buttons if they contains "IN_JUMP" ("buttons & IN_JUMP") then it will proceed to "g_LastButtons[client] & ~IN_JUMP", here it will check if the last buttons contains anything else than IN_JUMP, so it will trigger if you held any other buttons than "IN_JUMP" the last frame. So psychonics snippet wont trigger when you jump, but it will trigger several times if you're e.g. walking forward and pressing your jump button.

what i did before and after i tried this would be something like this
PHP Code:
    if ((buttons button) && !(g_LastButtons[client] & button))
    {
        
OnButtonPress(clientbutton);
    }
        
    if ((
g_LastButtons[client] & button) && !(buttons button))
    {
        
OnButtonRelease(clientbutton);
    } 
which works just perfect
Cookies.net is offline