mirror of
https://github.com/Valen-Sandbox/acf-daktank-buildmode.git
synced 2025-03-04 03:03:17 -05:00
Add notification for attackers
This commit is contained in:
parent
1df0462a21
commit
d5048b289e
11
lua/autorun/client/acf_daktank_buildmode.lua
Normal file
11
lua/autorun/client/acf_daktank_buildmode.lua
Normal 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 )
|
@ -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 )
|
Loading…
Reference in New Issue
Block a user