• How to preven gmod to changing the weapon via mouse wheel when E is pressed
    9 replies, posted
So, here am I forum coding a better way of implementing the selection of the active point ID for the track assembly tool. [url]https://steamcommunity.com/sharedfiles/filedetails/?id=287012681[/url] 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: [url]https://github.com/dvdvideo1234/TrackAssemblyTool/blob/dev/lua/weapons/gmod_tool/stools/trackassembly.lua#L1149-L1168[/url] 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 :D
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
[QUOTE=Trixas;50888830]I believe Wiremod wiring tool has something similar 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[/QUOTE] Hi, I saw how are they using it but I doubt that there is a a "Scroll" method supported by the TOOL class [url]https://wiki.garrysmod.com/page/Category:TOOL[/url] [url]https://github.com/wiremod/wire/blob/master/lua/weapons/gmod_tool/stools/wire_adv.lua#L617-L653[/url] Best bet is: [url]https://wiki.garrysmod.com/page/GM/PlayerBindPress[/url]
[QUOTE=dvd_video;50889335]Hi, I saw how are they using it but I doubt that there is a a "Scroll" method supported by the TOOL class [url]https://wiki.garrysmod.com/page/Category:TOOL[/url] [url]https://github.com/wiremod/wire/blob/master/lua/weapons/gmod_tool/stools/wire_adv.lua#L617-L653[/url] Best bet is: [url]https://wiki.garrysmod.com/page/GM/PlayerBindPress[/url][/QUOTE] -snip- 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?
[QUOTE=Trixas;50890202] So did you try it yet? Does it work?[/QUOTE] Sadly I did not have time to try it past evening. Today I will try to see that it will work ;) Though is it possible to call [url]https://wiki.garrysmod.com/page/input/IsKeyDown[/url] 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: [url]https://github.com/dvdvideo1234/TrackAssemblyTool/commit/e35229aff53a47c1d8b8e086c2f945d1ababe674[/url]
[QUOTE=dvd_video;50893624]Sadly I did not have time to try it past evening. Today I will try to see that it will work ;) Though is it possible to call [url]https://wiki.garrysmod.com/page/input/IsKeyDown[/url] 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: [url]https://github.com/dvdvideo1234/TrackAssemblyTool/commit/e35229aff53a47c1d8b8e086c2f945d1ababe674[/url][/QUOTE] 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.
[QUOTE=Trixas;50893951]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.[/QUOTE] Time to test this when I get home: [url]https://github.com/dvdvideo1234/TrackAssemblyTool/blob/dev/lua/autorun/trackassembly_init.lua#L102-L127[/url]
[QUOTE=dvd_video;50894042]Time to test this when I get home: [url]https://github.com/dvdvideo1234/TrackAssemblyTool/blob/dev/lua/autorun/trackassembly_init.lua#L102-L127[/url][/QUOTE] Good luck, inform me how it goes
[QUOTE=Trixas;50894262]Good luck, inform me how it goes[/QUOTE] 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... [url]https://github.com/dvdvideo1234/TrackAssemblyTool/blob/dev/lua/autorun/trackassembly_init.lua#L102-L131[/url] Judging by the log [code] 36 >> CLIENT > TRACKASSEMBLY [LUA] POINT_SELECT(invnext): Success 37 >> CLIENT > TRACKASSEMBLY [LUA] POINT_SELECT(+use): Skipped 38 >> CLIENT > TRACKASSEMBLY [LUA] POINT_SELECT(+attack2): Skipped [/code] For all others it must return false, because they must not be overloaded Notice the if statement [code] if((oBind == "invnext") or (oBind == "invprev")) then [/code] which returns true at the end
Sorry, you need to Log In to post a reply to this thread.