• Hook Adding Help?
    7 replies, posted
Im extremely new to Lua, but at least I am trying... Im attempting to "unlock" the mouse permanently, but then "re-lock" the mouse when you press the right mouse button (Or I should say hold down the right mouse button) Any ideas or help? No I'm not asking for free code, I actually have some for you! I feel like im really close, im just missing something, thats probably really obvious to advanced people. [CODE]hook.Add("GUIMousePressed", "ShouldNotDrawMouse", function( mouseCode ) if mouseCode == 108 then gui.EnableScreenClicker( false ) end end) hook.Add("GUIMouseReleased", "ShouldDrawMouse", function( mouseCode ) if mouseCode == 108 then gui.EnableScreenClicker( true ) end end)[/CODE] Thanks in advance! (Edited to have latest "version") Still not working >_>
Bump?
Wait, so what do you want to happen, again (sorry, I got confused)? Could you be a bit more detailed? Do you mean by 'permanently unlocking the mouse' that you want it to be visible all the time and movable around the screen, but when you press right-click it goes back to being hidden, and you control the player's viewpoint instead like normal?
Well first of all, there's no need to call the hook twice, if you're gonna run different if statements on both times, just call it once Secondly, where do you define Should(Not)DrawMouse ?
[QUOTE=MPan1;48611944]Wait, so what do you want to happen, again (sorry, I got confused)? Could you be a bit more detailed? Do you mean by 'permanently unlocking the mouse' that you want it to be visible all the time and movable around the screen, but when you press right-click it goes back to being hidden, and you control the player's viewpoint instead like normal?[/QUOTE] Yes exactly that. [editline]4th September 2015[/editline] [QUOTE=JasonMan34;48612470]Well first of all, there's no need to call the hook twice, if you're gonna run different if statements on both times, just call it once Secondly, where do you define Should(Not)DrawMouse ?[/QUOTE] On line one? I dont really understand >.< [editline]4th September 2015[/editline] I got it a bit closer, but its still not working: here it is [CODE]hook.Add("GUIMousePressed", "ShouldNotDrawMouse", function( mouseCode ) if mouseCode == 108 then gui.EnableScreenClicker( false ) end end) hook.Add("GUIMouseReleased", "ShouldDrawMouse", function( mouseCode ) if mouseCode == 108 then gui.EnableScreenClicker( true ) end end)[/CODE]
Bump
with "on one line" he means dont call the hook 2 times, only once, by making an if + elseif statement. [editline]5th September 2015[/editline] And is your code server or client sided?
[QUOTE=whitestar;48616679]with "on one line" he means dont call the hook 2 times, only once, by making an if + elseif statement. [editline]5th September 2015[/editline] And is your code server or client sided?[/QUOTE] Doesnt matter, just solved with: [CODE]hook.Add("Think", "RightMouse", function() if input.IsMouseDown( MOUSE_RIGHT ) then gui.EnableScreenClicker( false )) else gui.EnableScreenClicker( true ) end end)[/CODE] Thanks anyways.
Sorry, you need to Log In to post a reply to this thread.