function MinigunRapidFire(_, activator) if not activator then return end local activeWeapon = activator:GetPlayerItemBySlot(0) local fireRateNumber = 1 local ReloadTime = 4 local primaryMaxClipSize = activator.m_iAmmo[2] IsClipNotMax = false function ReloadMinigun() if not IsValid(activator) or not activator:IsAlive() or not IsValid(activeWeapon) then return end local getCurAmmo = activeWeapon:GetAttributeValue("maxammo primary increased") if getCurAmmo == nil then getCurAmmo = 1 end ReloadTime = ReloadTime - 1 activator:WeaponSwitchSlot(0) activator:SetAttributeValue("disable weapon switch", 1) activator:AcceptInput("$DisplayTextCenter", "Reloading..."..ReloadTime, activator) if ReloadTime == 0 then activator.m_iAmmo[2] = primaryMaxClipSize * getCurAmmo ReloadTime = 4 activator:SetAttributeValue("disable weapon switch", nil) end end function AddMinigunFireRate() if not IsValid(activator) or not activator:IsAlive() or not IsValid(activeWeapon) then return end --print(fireRateNumber) fireRateNumber = fireRateNumber - 0.0012758 activator:SetAttributeValue("fire rate bonus", fireRateNumber) if fireRateNumber <= 0.4 then fireRateNumber = 0.4 else return end end MinigunTimerChecker = timer.Create(1, function () if not IsValid(activator) or not activator:IsAlive() or not IsValid(activeWeapon) then return end local primaryClipSize = activator.m_iAmmo[2] if primaryMaxClipSize == primaryClipSize then IsClipNotMax = true else IsClipNotMax = false end if primaryClipSize == 0 then ReloadMinigun() end if activeWeapon.m_iWeaponState ~= 2 then -- causing issues on wave restart? fireRateNumber = 1 activator:SetAttributeValue("fire rate bonus", nil) else MinigunTimerChecker = nil end end, 0) MinigunTimerFireRate = timer.Create(0.015, function () if not IsValid(activator) or not activator:IsAlive() or not IsValid(activeWeapon) then return end if activeWeapon.m_iWeaponState == 2 then -- causing issues on wave restart? AddMinigunFireRate() end end, 0) local MinigunReloadCallback = activator:AddCallback(ON_KEY_RELEASED, function(user2, key2) if not IsValid(activator) or key2 ~= IN_RELOAD or not user2:IsAlive() or not activator:IsAlive() or not IsValid(activeWeapon) then return end if activator.m_hActiveWeapon ~= activeWeapon then return end if key2 == IN_RELOAD and IsClipNotMax == false then activator.m_iAmmo[2] = 0 end end) end function OnWaveInit(wave) IsClipNotMax = false ReloadTime = 4 pcall(timer.Stop, MinigunTimerChecker) pcall(timer.Stop, MinigunTimerFireRate) MinigunTimerChecker = nil MinigunTimerFireRate = nil for _, player in pairs(ents.GetAllPlayers()) do --print(player) if player:IsRealPlayer() then player:SetAttributeValue("fire rate bonus hidden", nil) end end end