move custom code from fesiug utilities into their own folders

This commit is contained in:
edshot99 2024-12-18 22:57:06 -06:00
parent 9243870286
commit 683a435234
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,52 @@
hook.Add("PlayerDeath", "edshot_AmmoReservesOnPlayerKill", function(victim, inflictor, attacker)
if attacker:IsValid() and !attacker:IsNextBot() and !attacker:IsNPC() and attacker:IsPlayer() then
local wep = attacker:GetActiveWeapon()
if IsValid(wep) then
local wepAmmoType1 = wep:GetPrimaryAmmoType()
local wepAmmoType2 = wep:GetSecondaryAmmoType()
if wepAmmoType1 ~= -1 then
attacker:SetAmmo( 999, wepAmmoType1 )
end
if wepAmmoType2 ~= -1 then
attacker:SetAmmo( 99, wepAmmoType2 )
end
end
end
end)
hook.Add("OnNPCKilled", "edshot_AmmoReservesOnNPCKill", function(npc, attacker, inflictor)
if attacker:IsValid() and !attacker:IsNextBot() and !attacker:IsNPC() and attacker:IsPlayer() then
local wep = attacker:GetActiveWeapon()
if IsValid(wep) then
local wepAmmoType1 = wep:GetPrimaryAmmoType()
local wepAmmoType2 = wep:GetSecondaryAmmoType()
if wepAmmoType1 ~= -1 then
attacker:SetAmmo( 999, wepAmmoType1 )
end
if wepAmmoType2 ~= -1 then
attacker:SetAmmo( 99, wepAmmoType2 )
end
end
end
end)
hook.Add("WeaponEquip", "edshot_AmmoReservesOnEquip", function(weapon, owner)
if owner:IsValid() and !owner:IsNextBot() and !owner:IsNPC() and owner:IsPlayer() then
if IsValid(weapon) then
local wepAmmoType1 = weapon:GetPrimaryAmmoType()
local wepAmmoType2 = weapon:GetSecondaryAmmoType()
if wepAmmoType1 ~= -1 then
owner:SetAmmo( 999, wepAmmoType1 )
end
if wepAmmoType2 ~= -1 then
owner:SetAmmo( 99, wepAmmoType2 )
end
end
end
end)

View File

@ -0,0 +1,16 @@
hook.Add("PlayerDeath", "edshot_HealthAndArmorFromPlayer", function(victim, inflictor, attacker)
if attacker:IsValid() and !attacker:IsNextBot() and !attacker:IsNPC() and attacker:IsPlayer() then
if attacker ~= victim then
attacker:SetHealth( attacker:GetMaxHealth() )
attacker:SetArmor( attacker:GetMaxArmor() )
end
end
end)
hook.Add("OnNPCKilled", "edshot_HealthAndArmorFromNPC", function(npc, attacker, inflictor)
if attacker:IsValid() and !attacker:IsNextBot() and !attacker:IsNPC() and attacker:IsPlayer() then
attacker:SetHealth( attacker:GetMaxHealth() )
attacker:SetArmor( attacker:GetMaxArmor() )
end
end)