Unlocking User's Cursor From Crosshair (Like Context Menu)
9 replies, posted
I want the user's cursor to stop being fixed on the crosshair, just like the Sandbox context menu does. The gui.EnableScreenClicker() method works to a certain extent but some other code is still bringing it to the center...
(Sorry for the black bars, something happened when rendering smh)
A serverside or clientside solution is fine but preferably clientside
gui.EnableScreenClicker() is what the context menu and DarkRP F3 use IIRC. Can you post a snippet of your code for context. (pun intended)
He’s referring to how in Sandbox if you hold C (or whatever your context menu button is) you can aim your gone at different things on the screen without having to physically look at them with your character. I’m also curious how this is implemented. It’s definitely just moving around the view model of the weapon to where the mouse is but idk how.
The context uses panel:MakePopup() and ply:SetWorldClicker(true)
https://wiki.garrysmod.com/page/Panel/MakePopup uses https://wiki.garrysmod.com/page/Panel/SetMouseInputEnabled internally, and this is what I'm going for, so I'll try that then.
I now realize that SetMouseInputEnabled requires a Panel, and I'm using surface.DrawRect in the full script.
I now will revise my whole script to use panels.
To be continued...
GOD DAMNIT, I didn't mean to accept your answer. RIP bounty, clicking it again doesn't work.
Anyways, now that I clicked the REPLY button, this is how it's called:
gui.EnableScreenClicker(isdguion)
/\ Inside of a think hook
The variable in the brackets is toggled by a net message.
That's necessary. Why not just disable/enable the screen clicker on the net message rather than constantly calling gui.EnableScreenClicker in a Think hook?
Even the stupidest irrational answer can earn me coins apparently. How many coins were that anyway?
It's a temporary and lazy solution, especially because the net message is only for starting up the GUI, it's canceled client-side because KEY enums don't work on server.
Will revise in the future.
Thanks for your help, manolis. You should have gotten those 5 coins...
/\ 5
I gave Manolis a coin emoji e.e
Sorry, you need to Log In to post a reply to this thread.