• Why doesn't think work?
    5 replies, posted
I'd like to toggle what the left mouse button does, I started by doing this: [CODE]bind "mouse1" "lbutton" alias "lbutton" "+attack"[/CODE] When I press the LMB nothing happens.
The problem is if you replace a +/- command, you need to define the +/- function of it. ( + being the functionality when the button is held, - when the button is released ) bind mouse1 +lbutton alias +lbutton +attack alias -lbutton -attack But, an easier way would be to keep +attack as the primary binding, the use scroll-wheel to toggle through a scripted menu which rebinds mouse 1. I made a pretty compex cfg aliasing script that did this years ago which basically gave me information for key combos in HL1 game-modes with the option to bind that key combo to a key ( timed correctly and all ), but I took that feature out and left it as a basic informational display tool. So it could be done using CFG. You can't set up this in Lua ( In the way that you want to do it ) because alias is blocked, and bind is blocked. If you wanted to do it in Lua you need to hook into hook.Add("PlayerBindPress", "PlayerBindPressLocalID", function( Player, Bind, Pressed ) Then capture mouse inputs, return true to stop the normal action and replace it with yours.
Originally I wanted to use the scroll, but scrolling is uncertain so i wanted to have on-screen text appearing to prevent confusion (only on the script user's screen), but then I got told this can't be done in cfg scripting.
Use LUA, if you want to make a text appear when a player clicks then use: [LUA] function GM:PlayerBindPress( ply, bind, pressed ) if (bind == "+attack") then hook.Add("HUDPaint", "showText", function() draw.DrawText("You pressed it", "Default", ScrW() / 20.5, ScrH() / 2.63, Color(25, 255, 25, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT) end) end [/LUA]
As far as I know Lua is for making gamemodes, I don't want to make a gamemode, I'm just looking to make my life easier while playing on a server, I'm not even the admin.
Gamemodes and addons. Make a .lua file in autorun and put my code in you stupid orange.
Sorry, you need to Log In to post a reply to this thread.