• Making the mouse click.
    26 replies, posted
Hi, I am currently making a mod so that i can use my wired xbox 360 contoller in gmod. I have already made it do that i can move the mouse in the spawnmenu using the left thumbstick but now i need to know how to make it actually click. I was thinking of finding out what panel you where hovering over and then just calling the DoClick function, but i can't figure out how to get the panel i am hovering over. Any help? Also if anyone knows a way to freeze the player client side that would also be much appreciated at the moment i am doing it sever side but i would like to be able to use it on any server. Player:Freeze() does not work even though it says it is shared on the wiki.
What happens if you run +attack? Also, for freeze, you could maybe do something with [url=http://wiki.garrysmod.com/?title=Clientside_Lua#CUserCmd]User Commands and CreateMove[/url] mixed with PlayerBindPressed. Unsure how you would actually go about it, though.
The player attacks but it does not click the mouse
[QUOTE=Carnag3;16286271]...Wired xbox controller...[/QUOTE] You mean made with Wire or Normal joystick? Oo If you mean real joystick, I think about this: Get the key command from the joystick and then bind it to +attack1
If i just bind it to attack then it does what it says on the tin it attacks it does not click the mouse on the vgui panel.
it would be better if u just made a module
I know a friend wanted to click in menus with lua (for an assmod autoclicker, hp spammer) and ended up making a c# programm... not very optimistic but hey maybey you get it to work.
errm cant you just map the buttons with the controller software?
I don't know c++ or c# so I can't make a module. If someone would be so kind as to do it for me :) I would be very grateful.
Sorry to bump after only 6 hours but i really need an answer to this.
Well You could check the Active Panel somehow. And then check if youre under it. But I really dont know how. xD
Yea I wish there was a function to get what panel the mouse is hovering over. I was trying to see how tooltips do it but I could not figure it out.
[lua] /*--------------------------------------------------------- Name: gamemode:GUIMouseReleased( mousecode ) Desc: The mouse has been released on the game screen ---------------------------------------------------------*/ function GM:GUIMouseReleased( mousecode, AimVector ) hook.Call( "CallScreenClickHook", GAMEMODE, false, mousecode, AimVector ) end /*--------------------------------------------------------- Name: gamemode:GUIMouseReleased( mousecode ) Desc: The mouse was double clicked ---------------------------------------------------------*/ function GM:GUIMouseDoublePressed( mousecode, AimVector ) // We don't capture double clicks by default, // We just treat them as regular presses GAMEMODE:GUIMousePressed( mousecode, AimVector ) end[/lua] from base/gamemode/cl_init.lua
[QUOTE=cyber_cam34;16324111][lua] /*--------------------------------------------------------- Name: gamemode:GUIMouseReleased( mousecode ) Desc: The mouse has been released on the game screen ---------------------------------------------------------*/ function GM:GUIMouseReleased( mousecode, AimVector ) hook.Call( "CallScreenClickHook", GAMEMODE, false, mousecode, AimVector ) end /*--------------------------------------------------------- Name: gamemode:GUIMouseReleased( mousecode ) Desc: The mouse was double clicked ---------------------------------------------------------*/ function GM:GUIMouseDoublePressed( mousecode, AimVector ) // We don't capture double clicks by default, // We just treat them as regular presses GAMEMODE:GUIMousePressed( mousecode, AimVector ) end[/lua] from base/gamemode/cl_init.lua[/QUOTE] Does this really emulate a click? For me, it just looks like calling hooks.
[QUOTE=aVoN;16324703]Does this really emulate a click? For me, it just looks like calling hooks.[/QUOTE] He was just showing the code inside the file: [url]http://luabin.foszor.com/code/gamemodes/base/gamemode/cl_init.lua#146[/url]
well i've been mucking about with it and if i do: [lua] GAMEMODE:GUIMousePressed( 107, LocalPlayer():GetCursorAimVector() ) [/lua] It clicks but it does not click on the open vgui. I can tell because when i have the toolgun out and press a it is shooting the toolgun where i have clicked on the screen. As it would if you have the context menu open.
[QUOTE=lonewolf2;16287509]You mean made with Wire or Normal joystick? Oo If you mean real joystick, I think about this: Get the key command from the joystick and then bind it to +attack1[/QUOTE] Just to answer to this person: He means an xbox controller that has a wire.
Yea sorry about any confusion there.
I Still need help if anyone can.
[QUOTE=Carnag3;16390911]I Still need help if anyone can.[/QUOTE] I'll try to slap together a module for you. [editline]04:45PM[/editline] Almost done. Testing...
thanks
Sorry for taking so long. I accidentally did override an already existing global, MOUSE_LEFT and thus broke the spawnmenu. Got me puzzled a while there. Going to do a final test then I'll upload it.
Are you writing a module with mouse_event( )?
[url]http://filebox.me/files/d5twcjp7e_gmcl_mouseclick.zip[/url] [B]Mouse Codes:[/B] [code] MOUSE_LEFT MOUSE_RIGHT MOUSE_MIDDLE [/code] [B]Functions:[/B] [code] mouse.Click(MouseCode) mouse.Press(MouseCode) mouse.Release(MouseCode) [/code] Put gmcl_mouseclick.dll in lua/includes/modules [B]Example:[/B] [lua] require "mouseclick" mouse.Click(MOUSE_MIDDLE) [/lua] When this code is run, the middle mouse button will be clicked. mouse.Press holds the button until mouse.Release is called. [editline]05:26PM[/editline] [QUOTE=Overv;16395311]Are you writing a module with mouse_event( )?[/QUOTE] Yes
Thanks very much. Now i can play gmod without the need of a keyboard or mouse :)
[QUOTE=Carnag3;16395540]Thanks very much. Now i can play gmod without the need of a keyboard or mouse :)[/QUOTE] How do you plan on typing? I don't think it would be fun typing a big sentence the same way you would choose your name in an xbox game.
I'm using it more for single player than multiplayer. But it's quite good what I have done for the keypad. I basically have 2 different sets of keys bound and they are toggled by a button. So if you press the button you go into numpad mode press it again and you go back to normal mode. Also in normal mode you can use the dpad as the 8 6 2 and 4 keypad buttons so you don't always have to keep switching.
Sorry, you need to Log In to post a reply to this thread.