Mouse on screen

Hello,
So I am making a gamemode which requires the mouse to be on the screen, I need to make it so the mouse click on a spot moves you to that area. And I also need to make it so that WASD don’t function for the movement. If you can help me I would really appreciate it! Thanks!

For WASD blocking: http://wiki.garrysmod.com/page/GM/Move or http://wiki.garrysmod.com/page/GM/CreateMove

For mouse, http://wiki.garrysmod.com/page/gui/EnableScreenClicker

Thanks, I’ll see what I can do with this.

[editline]11th May 2014[/editline]

which file would I put the WASD blocking and the gui.EnableScreenClicker?

Any Clients side file. Also, I believe you can use gui.ScreenToVector to get the target world vector for other calculations.

what about clicking to move to a spot?

You expect us to give you finished solutions, don’t you?

No i don’t. I just need advice.

If I remember correctly, in the CreateMove hook you can make the player face the target vector and then force the player to move forward by adding the command tab (or whatever it’s called).

So I’ve been trying to do it but I haven’t quite been able to crack it, i think I need a bit more help. This is what I’ve done so far


gui.EnableScreenClicker( true )
function GM:Move( ply, mv )
	input.WasMousePressed( MOUSE_LEFT )
		if return true
			local tr = util.QuickTrace(LocalPlayer():GetShootPos(), gui.ScreenToVector( gui.MousePos() ),LocalPlayer() ) ---will do a trace from mouse pos to world.
			print( tr.HitPos )
		end
		else return false
		end
end

It worries me that you are trying to make a full blown Runescape remake when you don’t have a good understanding of lua/Glua

If you are new to this I suggest starting with something a little easier or you are going to be disheartened when you fail.

I’d rather do something that I could work on over a long period of time, its how I learn best. What would you suggest I start out doing though?

The CreateMove hook should provide enough functionality. It even properly returns mouse-scroll.

I don’t know why I find this task so difficult. But if I ask for anymore help everyone just goes “You just want us to do it for you”.

[editline]13th May 2014[/editline]

Proof that I’m trying :confused: http://pastebin.com/XCBmRGpw

do something simpler

I would suggest reading this:
http://www.facepunch.com/showthread.php?t=1337945

Then trying doing some HUDs, chat commands, panels, sweps, entities.
Learn the language, learn how clientside vs serverside stuff works, then you can try doing fancy complicated stuff.

Don’t overwrite a GM function with your hook.Add.

Do a
[lua]hook.Add( “CreateMove”, “unique name”, function( … )
// code
end );[/lua]