Fist Posted March 17, 2017 Share Posted March 17, 2017 (edited) is it possible to make rifle reload slower? Otherwise it instantly reloads next bullet in so fast. I want to have it like 1-2 second delay between each bullet. Edited March 17, 2017 by Fist Link to comment
NeXuS™ Posted March 17, 2017 Share Posted March 17, 2017 I think you have to do a trick about it. Maybe setting his ammo to 0 and then after the delay setting it to 1, and saving his total ammo in a element data? Link to comment
Fist Posted March 17, 2017 Author Share Posted March 17, 2017 Ok, gonna try that ty for idea. Link to comment
Gordon_G Posted March 17, 2017 Share Posted March 17, 2017 (edited) Or disable the "fire" when he try to shut during the dalay You'll need these functions : event : "onPlayerWeaponFire" -- when a player shoots setTimer() -- to set a delay (1000 for 1 seconde) setControlState() -- to disable the fire when he shoots setElementData() getElementData() event : "onPedWeaponSwitch" -- Like this, the player can shoot with others weapons during the delay -- Don't forget to set back off the control state when he re-switch to the rifle Good luck Edited March 17, 2017 by Gordon_G Link to comment
Fist Posted March 17, 2017 Author Share Posted March 17, 2017 (edited) 19 minutes ago, Gordon_G said: Or disable the "fire" when he try to shut during the dalay You'll need these functions : event : "onPlayerWeaponFire" -- when a player shoots setTimer() -- to set a delay (1000 for 1 seconde) setControlState() -- to disable the fire when he shoots setElementData() getElementData() event : "onPedWeaponSwitch" -- Like this, the player can shoot with others weapons during the delay -- Don't forget to set back off the control state when he re-switch to the rifle Good luck yeah ik that be actually easier, but it doesn't look that good 'cause it will show in hud that it reloaded but you still can't shoot. By the way, you know how i can add fake bullet into gun when he runs out of ammo ? That fake bullet wouldn't be possible to shoot but just for that you still could hold empty gun in your hands. @NeXuS™ @Gordon_G i tried like this but it gives me warning that it expected element at first argument of setWeaponAmmo. Weird... addEventHandler("onPlayerWeaponFire", root, function(weapon) if (weapon == 33) then if isTimer(delay_timer) then killTimer(delay_timer) end local o_ammo = getPedTotalAmmo(source,33); local delay_timer = setTimer(function(source) setWeaponAmmo(source,33,o_ammo,0); end,500,0); setTimer(function(source) if isTimer(delay_timer) then killTimer(delay_timer) end end,1000,1); end end); Edited March 17, 2017 by Fist Link to comment
Gordon_G Posted March 17, 2017 Share Posted March 17, 2017 Hum... The only way I see is to create a new HUD Link to comment
Fist Posted March 17, 2017 Author Share Posted March 17, 2017 1 minute ago, Gordon_G said: Hum... The only way I see is to create a new HUD i updated comment, check it out. Link to comment
Gordon_G Posted March 17, 2017 Share Posted March 17, 2017 (edited) Oh, i'm so stupid. Do it client-sided, it will be easier I think because no need to killTimer... "onClientPlayerWeaponFire" "onClientPlayerWeaponSwitch" Edited March 17, 2017 by Gordon_G Link to comment
Fist Posted March 17, 2017 Author Share Posted March 17, 2017 5 minutes ago, Gordon_G said: Oh, i'm so stupid. Do it client-sided, it will be easier I think because no need to killTimer... "onClientPlayerWeaponFire" "onClientPlayerWeaponSwitch" i tried both sides, almost same problem. I can't set ammo it says i'm giving invalid source or weapon. Link to comment
Gordon_G Posted March 17, 2017 Share Posted March 17, 2017 (edited) function rifleReloadCheck(_,weapon) if weapon ~= 33 then toggleControl ( "fire", true ) else toggleControl ( "fire", false ) end -- check if the player have a rifle in hands during the reloading, if it's not, enable the control state, else, disable end function rifleReloadTime(weapon,ammo) if weapon == 33 then -- Check player's weapon toggleControl ( "fire", false ) -- disable the shoot addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(),rifleReloadCheck) -- add a check to avoid the player can't shot with other weapon during reloading setTimer(function(source) -- Timer to disable the check, and toggle back the fire control toggleControl ( "fire", true ) removeEventHandler( "onClientPlayerWeaponFire", getLocalPlayer(), rifleReloadCheck) end,1000,1,source) end end addEventHandler("onClientPlayerWeaponFire", getlocalPlayer(), rifleReloadTime) I did'nt try but, I think it's correct @Fist Edited March 17, 2017 by Gordon_G Link to comment
Fist Posted March 17, 2017 Author Share Posted March 17, 2017 37 minutes ago, Gordon_G said: function rifleReloadCheck(_,weapon) if weapon ~= 33 then toggleControl ( "fire", true ) else toggleControl ( "fire", false ) end -- check if the player have a rifle in hands during the reloading, if it's not, enable the control state, else, disable end function rifleReloadTime(weapon,ammo) if weapon == 33 then -- Check player's weapon toggleControl ( "fire", false ) -- disable the shoot addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(),rifleReloadCheck) -- add a check to avoid the player can't shot with other weapon during reloading setTimer(function(source) -- Timer to disable the check, and toggle back the fire control toggleControl ( "fire", true ) removeEventHandler( "onClientPlayerWeaponFire", getLocalPlayer(), rifleReloadCheck) end,1000,1,source) end end addEventHandler("onClientPlayerWeaponFire", getlocalPlayer(), rifleReloadTime) I did'nt try but, I think it's correct @Fist ehh ok, this will do ok for 1sec delay you can't notice anyway that it does actually load ammo. Thanks! 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