peane Posted July 7, 2011 Share Posted July 7, 2011 Hi i am beginner in scripting so pls be patient with me... I need to reduce vehicle fire rate to one time per second. I have studied wiki but without success. https://wiki.multitheftauto.com/wiki/OnVehicleWeaponFire, https://wiki.multitheftauto.com/wiki/CancelEvent, etc... thx for help Link to comment
H5N1 Posted July 7, 2011 Share Posted July 7, 2011 CancelEvent doesnt work on every event. To cancel fire use toogleControl (). Link to comment
peane Posted July 7, 2011 Author Share Posted July 7, 2011 I made this. But there is a problem... I have to push fire key really frequently and my Hunter fire jtst sometimes.... (not regulary after one second...) Am I doing something wrong? colored code: http://pastebin.com/b4WJ1TBU local firetime = 1000 local canfire = true function reloadVehicleGuns() if (canfire == false) then outputChatBox ( "Primary gun reloaded!") end canfire = true toggleControl ( "vehicle_fire", true ) end local myTimer = setTimer (reloadVehicleGuns, firetime, 0 ) function vehicleWeaponFire(key, keyState) local vehModel = getElementModel(getPedOccupiedVehicle(getLocalPlayer())) if (vehModel == 425) then if (canfire == true) then canfire = false outputChatBox ( "Primary weapon released!") resetTimer(myTimer) toggleControl ( "vehicle_fire", false ) end end end bindKey("vehicle_fire", "down", vehicleWeaponFire) Link to comment
SDK Posted July 7, 2011 Share Posted July 7, 2011 Not tested (use [lua] for colored code) local firetime = 1000 local canfire = true local myTimer function reloadVehicleGuns() if (canfire == false) then outputChatBox ( "Primary gun reloaded!") end canfire = true toggleControl ( "vehicle_fire", true ) end function vehicleWeaponFire(key, keyState) local vehModel = getElementModel(getPedOccupiedVehicle(getLocalPlayer())) if (vehModel == 425) then if (canfire == true) then canfire = false outputChatBox ( "Primary weapon released!") myTimer = setTimer (reloadVehicleGuns, firetime, 1 ) toggleControl ( "vehicle_fire", false ) end end end bindKey("vehicle_fire", "down", vehicleWeaponFire) Link to comment
peane Posted July 7, 2011 Author Share Posted July 7, 2011 THX for all replies issue is now fixed... It was all about bindKey..... instead of DOWN I have to use UP..... Link to comment
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