How to preven gmod to changing the weapon via mouse wheel when E is pressed

So, here am I forum coding a better way of implementing the selection of the active point ID for the track assembly tool.

I am doing this because I can select a piece faster when I first insert it in the database and then Use: ( Default E ) and the mouse scroll to select point ID, which is rather easier than going trough all of them via a right click. You can find the main code for this in my DEV branch here:

The thing is when I press E everything works as expected besides changing of the weapon, which selects let’s say … physgun and everything become pointless and you cannot left-click to spawn a track.
So, how can I tell gmod not to switch the weapon when E is pressed ?

Thanks !

Is anyone here :smiley:

I believe Wiremod wiring tool has something similiar
You take a tool, and with mouse scroll wheel you can select what to wire
And I think wire is on github, so you can find something helpful there

Hi, I saw how are they using it but I doubt that there is a a “Scroll” method supported by the TOOL class

Best bet is:

Edit: Dummy me, I didn’t read wiki fully, and missed this “Runs when a bind has been pressed. Allows to block commands.”… So did you try it yet? Does it work?

Sadly I did not have time to try it past evening. Today I will try to see that it will work :wink:

Though is it possible to call in the hook’s function and is the bind key going to be different then, because I only need to disable scrolling when E is pressed?

I am currently using:

Tested PlayerBindPress and it worked with invnext and invprev
I could do function with scroll wheel, and weapon selection didn’t appear
So I guess you should make PlayerBindPress to check if your tool is active, and E is holden down, if both true then check if invnext or invprev is pressed, and do the function you need and return true(returning true will block default command)
And if tool and E are not true, weapon selection would be a thing still.
I can be wrong tho, because my Lua knowledge is shit. Just trying to drop some ideas.

Time to test this when I get home:

Good luck, inform me how it goes

Astonishing success! Just as I want it … Thought now When I hit E + some button nothing happens when the hook function returns true at the end. Left click is dead too Maybe because the function is over-ridden
and other buttons are not set. The player can’t even move properly as it returns true generally…

Judging by the log

    36 >> CLIENT > TRACKASSEMBLY [LUA] POINT_SELECT(invnext): Success
    38 >> CLIENT > TRACKASSEMBLY [LUA] POINT_SELECT(+attack2): Skipped

For all others it must return false, because they must not be overloaded

Notice the if statement

 if((oBind == "invnext") or (oBind == "invprev")) then 

which returns true at the end