Skip to content

Commit

Permalink
Testing alarm update
Browse files Browse the repository at this point in the history
Added alarm sound file.
Added damage hook.
Now using default fallbacks for some GetNWBools.
  • Loading branch information
viral32111 committed Apr 28, 2018
1 parent eb1f364 commit b5076d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lua/autorun/server/sv_carkeys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ hook.Add( "PlayerUse", "CarKeysUseVehicle", function( ply, ent )
if ( table.HasValue( CarKeysVehicles, ent:GetClass() ) ) then
if ( ply:GetPos():Distance( ply:GetEyeTrace().Entity:GetPos() ) >= 150 ) then return false end

if ( ent:GetNWBool( "CarKeysVehicleLocked", false ) ) then
if ( ent:GetNWBool( "CarKeysVehicleLocked" ) ) then
return false
else
return true
Expand Down Expand Up @@ -117,3 +117,21 @@ if ( engine.ActiveGamemode() == "darkrp" ) then
else
print( "[Car Keys] Set vehicle price chat command has been disabled." )
end

--[[-------------------------------------------------------------------------
When damage is taken
---------------------------------------------------------------------------]]
hook.Add("EntityTakeDamage", "CarKeysOnVehicleDamaged", function( target, dmg )
if ( target:GetClass() == "gmod_sent_vehicle_fphysics_wheel" ) then return false end

if ( table.HasValue( CarKeysVehicles, target:GetClass() ) and target:GetNWBool("CarKeysVehicleLocked") ) then
if ( timer.Exists( "CarKeysDamageTimer" ) ) then
timer.Adjust( "CarKeysDamageTimer", 8, 1, function() end )
return
else
timer.Create( "CarKeysDamageTimer", 8, 1, function() end )
end

target:EmitSound("carkeys/alarm.wav")
end
end )
Binary file added sound/carkeys/alarm.wav
Binary file not shown.

0 comments on commit b5076d0

Please sign in to comment.