Forrest Posted February 12, 2013 Posted February 12, 2013 Right, I'm a little bit of a noob to scripting, though I am learning as much and as fast as I can. Right now, I'm trying to make a script for toggle-able semi-auto/auto firearms, and I'm completely stumped as to how I could do it! Does anyone have say, an example, or an idea of how I could do it? Thanks, much appreciated!
DNL291 Posted February 12, 2013 Posted February 12, 2013 You can use these functions: bindKey setControlState( thePlayer, "fire", state ) getControlState( thePlayer, "fire" ) Please do not PM me with scripting related question nor support, use the forums instead.
Moderators IIYAMA Posted February 14, 2013 Moderators Posted February 14, 2013 CLIENT function setWeaponFire (key, keyState) if keyState == "down" then setControlState(getLocalPlayer(), "fire", true ) elseif keyState == "up" then setControlState(getLocalPlayer(), "fire", false ) end end addEventHandler ( "onClientResourceStart", resourceRoot, function () bindKey ("mouse1", "both",setWeaponFire) bindKey ("lctrl", "both",setWeaponFire) toggleControl ("fire", false ) end) OR server ( not recommended when high ping) function setWeaponFire (key, keyState) if keyState == "down" then setControlState(source, "fire", true ) elseif keyState == "up" then setControlState(source, "fire", false ) end addEventHandler ( "onResourceStart", resourceRoot, function () for _, player in pairs ( getElementsByType 'player' ) do bindKey (player,"mouse1", "both",setWeaponFire) bindKey (player,"lctrl", "both",setWeaponFire) toggleControl ( player, "fire", false ) end end) addEventHandler ( "onPlayerJoin", getRootElement( ), function () bindKey (source,"mouse1", "both",setWeaponFire) bindKey (source,"lctrl", "both",setWeaponFire) toggleControl ( source, "fire", false ) end) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now