Advertisement
NSKuber

Untitled

Jun 11th, 2020
893
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. local isBurstFireRunning = false
  2. local HandlePistolBurstFiring = function(player,weapon,path)
  3.   RunAsync(function()
  4.    
  5.     if isBurstFireRunning then return end
  6.     isBurstFireRunning = true
  7.    
  8.     Wait(CustomEvent("OnStep"))
  9.    
  10.     local burstFiring = false
  11.    
  12.     RunHandled(function()
  13.       while not IsDeleted(weapon) do
  14.         Wait(CustomEvent("OnStep"))
  15.       end
  16.       isBurstFireRunning = false
  17.     end,
  18.    
  19.     OnEvery(CustomEvent(weapon,"Fired")),
  20.     function()
  21.       if (worldGlobals.AltFireCurrentFiringModes[weapon] == 2) and not burstFiring then
  22.         burstFiring = true
  23.         local ammoInClip = weapon:GetAmmoInClip()
  24.         player:FireButtonPressed(0)
  25.         while not IsDeleted(weapon) and not IsDeleted(player) and (ammoInClip - weapon:GetAmmoInClip() < 2) and burstFiring do
  26.           if (ammoInClip - weapon:GetAmmoInClip() == 1) then weapon:SetRateOfFireMultiplier(0.6) end
  27.           player:FireButtonPressed(0)
  28.           Wait(CustomEvent("OnStep"))
  29.         end
  30.         player:FireButtonReleased(0)
  31.         if not burstFiring then return end
  32.         weapon:SetRateOfFireMultiplier(2)
  33.         Wait(CustomEvent("OnStep"))
  34.         burstFiring = false    
  35.       end
  36.     end,
  37.    
  38.     OnEvery(CustomEvent(weapon,"Reloaded")),
  39.     function()
  40.       burstFiring = false
  41.       if (worldGlobals.AltFireCurrentFiringModes[weapon] == 2) then
  42.         weapon:SetRateOfFireMultiplier(2)
  43.       end
  44.     end
  45.     )
  46.   end)
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement