Add notification for attackers

This commit is contained in:
thecraftianman 2023-06-19 12:32:01 -04:00
parent 1df0462a21
commit d5048b289e
2 changed files with 35 additions and 7 deletions

View File

@ -0,0 +1,11 @@
net.Receive( "ACF_BuildmodeNotif", function()
local isACF, dmgType = net.ReadBool(), ""
if isACF then
dmgType = "ACF"
else
dmgType = "DakTank"
end
surface.PlaySound( "buttons/button10.wav" )
notification.AddLegacy( "You are in buildmode and cannot deal " .. dmgType .. " damage!" )
end )

View File

@ -1,7 +1,8 @@
local hook_Add = hook.Add
local IsValid = IsValid
hook_Add( "ACF_PreDamageEntity", "ACF_BuildmodeIntegration", function( entity, dmgResult, dmgInfo )
util.AddNetworkString( "ACF_BuildmodeNotif" )
hook.Add( "ACF_PreDamageEntity", "ACF_BuildmodeIntegration", function( entity, _, dmgInfo )
if not IsValid( entity ) then return end
local entOwner = entity:CPPIGetOwner()
@ -10,7 +11,15 @@ hook_Add( "ACF_PreDamageEntity", "ACF_BuildmodeIntegration", function( entity, d
local entOwnerBuild = entOwner:GetNWBool( "_Kyle_Buildmode", false )
local attackerBuild = attacker:GetNWBool( "_Kyle_Buildmode", false )
if entOwnerBuild or attackerBuild then return false end
if entOwnerBuild then return false end
if attackerBuild then
net.Start( "ACF_BuildmodeNotif" )
net.WriteBool( true )
net.Send( attacker )
return false
end
end )
local function preventExplosions( entity )
@ -20,10 +29,10 @@ local function preventExplosions( entity )
local entOwnerBuild = entOwner:GetNWBool( "_Kyle_Buildmode", false )
if entOwnerBuild then return false end
end
hook_Add( "ACF_AmmoExplode", "ACF_BuildmodeIntegration_BuilderAmmo", preventExplosions )
hook_Add( "ACF_FuelExplode", "ACF_BuildmodeIntegration_BuilderFuel", preventExplosions )
hook.Add( "ACF_AmmoExplode", "ACF_BuildmodeIntegration_BuilderAmmo", preventExplosions )
hook.Add( "ACF_FuelExplode", "ACF_BuildmodeIntegration_BuilderFuel", preventExplosions )
hook_Add( "DakTankDamageCheck", "DakTank_BuildmodeIntegration", function( hitEnt, shellOwner, shell )
hook.Add( "DakTankDamageCheck", "DakTank_BuildmodeIntegration", function( hitEnt, shellOwner, shell )
if not IsValid( hitEnt and shellOwner and shell ) then return end
local entOwner = hitEnt:CPPIGetOwner()
@ -31,5 +40,13 @@ hook_Add( "DakTankDamageCheck", "DakTank_BuildmodeIntegration", function( hitEnt
local entOwnerBuild = entOwner:GetNWBool( "_Kyle_Buildmode", false )
local attackerBuild = shellOwner:GetNWBool( "_Kyle_Buildmode", false )
if entOwnerBuild or attackerBuild then return false end
if entOwnerBuild then return false end
if attackerBuild then
net.Start( "ACF_BuildmodeNotif" )
net.WriteBool( false )
net.Send( attacker )
return false
end
end )