Guest User

Time Bomb Watch

a guest
Apr 17th, 2023
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.19 KB | None | 0 0
  1.  
  2. AddCSLuaFile( "shared.lua" )
  3.  
  4. SWEP.Author         = "Hoff"
  5. SWEP.Instructions   = ""
  6.  
  7. SWEP.Category = "CoD Zombies"
  8. SWEP.Spawnable          = true
  9. SWEP.AdminSpawnable     = true
  10.  
  11. SWEP.ViewModel          = "models/hoff/weapons/timebomb/c_timebomb.mdl"
  12. SWEP.WorldModel         = "models/hoff/weapons/timebomb/w_timebomb.mdl"
  13. SWEP.ViewModelFOV = 64
  14.  
  15. SWEP.Primary.ClipSize       = -1
  16. SWEP.Primary.DefaultClip    = 1
  17. SWEP.Primary.Automatic      = true
  18. SWEP.Primary.Ammo           = "ammo_timebomb"
  19. SWEP.Primary.Delay = 1
  20.  
  21. SWEP.Secondary.ClipSize     = 0
  22. SWEP.Secondary.DefaultClip  = 0
  23. SWEP.Secondary.Automatic    = false
  24. SWEP.Secondary.Ammo         = "none"
  25.  
  26. SWEP.Weight             = 5
  27. SWEP.AutoSwitchTo       = false
  28. SWEP.AutoSwitchFrom     = false
  29.  
  30. SWEP.PrintName          = "Time Bomb"
  31. SWEP.Slot               = 4
  32. SWEP.SlotPos            = 5
  33. SWEP.DrawAmmo           = false
  34. SWEP.DrawCrosshair      = false
  35.  
  36. SWEP.AllowInteraction = true
  37. SWEP.NoInstantDraw = true
  38.  
  39. SWEP.UseHands = true
  40.  
  41. SWEP.NZSpecialWeaponData = {MaxAmmo = 1, AmmoType = "ammo_timebomb"}
  42.  
  43. SWEP.NZSpecialCategory = "shield"
  44.  
  45. function SWEP:NZSpecialHolster(wep)
  46.     return true -- This lets us always holster it even though it is a special weapon
  47. end
  48.  
  49. game.AddAmmoType( {
  50.     name = "ammo_timebomb",
  51.     dmgtype = DMG_BULLET,
  52.     tracer = TRACER_LINE,
  53.     plydmg = 0,
  54.     npcdmg = 0,
  55.     force = 2000,
  56.     minsplash = 10,
  57.     maxsplash = 5
  58. } )
  59.  
  60. if CLIENT then
  61.     language.Add("ammo_timebomb_ammo", "Time Bomb Ammo")
  62. end
  63.  
  64. TimeBombState =
  65. {
  66.     VM_TIMEBOMB_UNSET = 0,
  67.     VM_TIMEBOMB_TICKERONLY = 1,
  68.     VM_TIMEBOMB_BOTH = 2
  69. }
  70.  
  71. SWEP.CurrentState = TimeBombState.VM_TIMEBOMB_UNSET
  72.  
  73. SWEP.Offset = {
  74.     Pos = {
  75.         Up = -1,
  76.         Right = 4.5,
  77.         Forward = 4.5,
  78.     },
  79.     Ang = {
  80.         Up = 90,
  81.         Right = 90,
  82.         Forward = 0,
  83.     }
  84. }
  85. function SWEP:DrawWorldModel( )
  86.     if not IsValid( self:GetOwner() ) then
  87.         self:DrawModel( )
  88.         return
  89.     end
  90.  
  91.     local bone = self:GetOwner():LookupBone( "ValveBiped.Bip01_R_Hand" )
  92.     if not bone then
  93.         self:DrawModel( )
  94.         return
  95.     end
  96.  
  97.     local pos, ang = self:GetOwner():GetBonePosition( bone )
  98.     pos = pos + ang:Right() * self.Offset.Pos.Right + ang:Forward() * self.Offset.Pos.Forward + ang:Up() * self.Offset.Pos.Up
  99.     ang:RotateAroundAxis( ang:Right(), self.Offset.Ang.Right )
  100.     ang:RotateAroundAxis( ang:Forward(), self.Offset.Ang.Forward )
  101.     ang:RotateAroundAxis( ang:Up(), self.Offset.Ang.Up )
  102.  
  103.     self:SetRenderOrigin( pos )
  104.     self:SetRenderAngles( ang )
  105.  
  106.     self:DrawModel()
  107. end
  108.  
  109. function SWEP:ResetBonePositions(val)
  110.     if SERVER then
  111.         self:CallOnClient("ResetBonePositions", "")
  112.  
  113.         return
  114.     end
  115.  
  116.     local vm = self:GetOwner():GetViewModel()
  117.     if not IsValid(vm) then return end
  118.     if (not vm:GetBoneCount()) then return end
  119.  
  120.     for i = 0, vm:GetBoneCount() do
  121.         vm:ManipulateBoneScale(i, Vector(1, 1, 1))
  122.         vm:ManipulateBoneAngles(i, Angle(0, 0, 0))
  123.         vm:ManipulateBonePosition(i, Vector(0,0,0))
  124.     end
  125. end
  126.  
  127. function SWEP:Initialize()
  128.     self:SetModelScale( 0.8, 0 )
  129.     timer.Simple(0.25, function()
  130.         if IsValid(self) and IsValid(self:GetOwner()) then
  131.             for k, v in ipairs( ents.FindByClass( "cod-timebomb" ) ) do
  132.                 if v:GetNWString("OwnerID") == self:GetOwner():SteamID() then
  133.                     v.BombOwner = self:GetOwner()
  134.                     self:SetNWBool("bTimeBombOut", true)
  135.                     break
  136.                 end
  137.             end
  138.         end
  139.         if IsValid(self) and IsValid(self:GetOwner()) and self:GetOwner():GetAmmoCount(self.Primary.Ammo) > 0 then
  140.             self:SetNWBool("bInitialDeploy", true)
  141.         end
  142.     end)
  143. end
  144.  
  145. function SWEP:Deploy()
  146.     self:ResetBonePositions()
  147.     self:SendWeaponAnim(ACT_VM_HITLEFT)
  148.     self:SetCollisionGroup(COLLISION_GROUP_NONE)
  149.  
  150.     self:SetHoldType("duel")
  151.  
  152.     if self:Ammo1() <= 0 then
  153.         self:SetCurrentState(TimeBombState.VM_TIMEBOMB_TICKERONLY)
  154.     else
  155.         self:SetCurrentState(TimeBombState.VM_TIMEBOMB_BOTH)
  156.     end
  157.  
  158.     timer.Simple(3.25, function()
  159.         if IsValid(self) and IsValid(self:GetOwner()) then
  160.             self:SetNWBool("bInitialDeploy", false)
  161.         end
  162.     end)
  163.  
  164.     self:SetNextPrimaryFire(CurTime() + 0.6)
  165.     self:SetNextSecondaryFire(CurTime() + 1)
  166. end
  167.  
  168. function SWEP:PrimaryAttack()
  169.     if CLIENT then
  170.         return
  171.     end
  172.  
  173.     self:PlayPrimaryFireAnim()
  174.  
  175.     timer.Simple(0.1, function()
  176.         if IsValid(self) then
  177.             self:GetOwner():EmitSound("hoff/zmb/timebomb/watch_click.mp3")
  178.         end
  179.     end)
  180.  
  181.     local bShouldSaveOwnerOnly = ConVarExists("TimeBomb_AffectSelfOnly") and GetConVar("TimeBomb_AffectSelfOnly"):GetBool() or false
  182.  
  183.     timer.Simple(0.35, function()
  184.         if not IsValid(self) then
  185.             return
  186.         end
  187.         local bFoundBomb = false
  188.  
  189.         if self:GetNWBool("bTimeBombOut") then
  190.             for k, v in ipairs( ents.FindByClass( "cod-timebomb" ) ) do
  191.                 if v.BombOwner ~= self:GetOwner() then
  192.                     continue
  193.                 end
  194.  
  195.                 local fx = EffectData()
  196.                 fx:SetOrigin(v:GetPos() + v:GetUp() * 25)
  197.                 util.Effect("StunstickImpact",fx)
  198.  
  199.                 if not GetConVar("TimeBomb_InstantTravel"):GetBool() then
  200.  
  201.                     if bShouldSaveOwnerOnly then
  202.                         net.Start( "CreateTimeBombOverlay" )
  203.                         net.Send(self:GetOwner())
  204.                     else
  205.                         v:FreezeNPCs()
  206.                         v:PlayScreenOverlayFX()
  207.                     end
  208.  
  209.                     self:SetNWBool("bTimeBombOut", false)
  210.  
  211.                     timer.Simple(4.25, function()
  212.                         if IsValid(v) and v:IsValid() then
  213.                             v:RewindProps()
  214.  
  215.                             for i,box in ipairs(ents.FindByClass("zombies_mysterybox")) do
  216.                                 local boxPos = v:GetPos() + v:GetUp() * 770
  217.                                 local radius = 150
  218.                                 box:RemoveDupedEnts(boxPos, radius)
  219.                             end
  220.                         end
  221.                     end)
  222.                 else
  223.                     if IsValid(v) and v:IsValid() then
  224.                         v:RewindProps()
  225.                     end
  226.                 end
  227.                 bFoundBomb = true
  228.             end
  229.         end
  230.  
  231.         if not bFoundBomb then
  232.             self:SetNextPrimaryFire(CurTime() + 0.5)
  233.             self:SetNextSecondaryFire(CurTime() + 0.7)
  234.             return
  235.         end
  236.  
  237.         if not bShouldSaveOwnerOnly then
  238.             for _, ply in ipairs(player.GetAll()) do
  239.                 if not GetConVar("TimeBomb_InstantTravel"):GetBool() then
  240.                     ply:AddFlags(FL_NOTARGET)
  241.                     ply:Lock()
  242.                 end
  243.                 ply:SendLua( "hook.Run( \"OnSpawnMenuClose\" )" )
  244.                 --ply:SendLua( "surface.PlaySound('hoff/zmb/timebomb/timebomb_activate.wav')")
  245.             end
  246.         else
  247.             if not GetConVar("TimeBomb_InstantTravel"):GetBool() then
  248.                 self:GetOwner():AddFlags(FL_NOTARGET)
  249.                 self:GetOwner():Lock()
  250.             end
  251.             self:GetOwner():SendLua( "hook.Run( \"OnSpawnMenuClose\" )" )
  252.         end
  253.     end)
  254.  
  255.     self:SetNextPrimaryFire(CurTime() + 5.5)
  256.     self:SetNextSecondaryFire(CurTime() + 5.5)
  257. end
  258.  
  259. function SWEP:SecondaryAttack()
  260.     if not GetConVar("TimeBomb_Infinite"):GetBool() then
  261.         if self:Ammo1() <= 0 then
  262.             return
  263.         end
  264.  
  265.         self:GetOwner():RemoveAmmo(1, self.Primary.Ammo)
  266.     end
  267.  
  268.     self.PlayingAnimation = true
  269.     self:SendWeaponAnim(ACT_VM_THROW)
  270.     timer.Simple(0.5, function()
  271.         if !IsValid(self) or !IsValid(self:GetOwner()) then
  272.             return
  273.         end
  274.         self.PlayingAnimation = false
  275.         if self:GetOwner():GetActiveWeapon() != self then
  276.             return false
  277.         end
  278.         if self:Ammo1() <= 0 then
  279.             self:SetCurrentState(TimeBombState.VM_TIMEBOMB_TICKERONLY)
  280.         else
  281.             self:SetCurrentState(TimeBombState.VM_TIMEBOMB_BOTH)
  282.         end
  283.     end)
  284.     self:GetOwner():SetAnimation(PLAYER_ATTACK1)
  285.  
  286.     self:EmitSound("hoff/mpl/seal_c4/whoosh_01.wav")
  287.     timer.Simple(0.095, function()
  288.         if not IsValid(self) then
  289.             return
  290.         end
  291.         if self:GetOwner():GetActiveWeapon() != self then
  292.             return false
  293.         end
  294.         if SERVER then
  295.  
  296.             local TargetPosition = self:GetOwner():GetShootPos() + (self:GetOwner():GetRight() * -8) + (self:GetOwner():GetUp() * -1) + (self:GetOwner():GetForward() * 10)
  297.  
  298.             local model = "models/hoff/weapons/timebomb/w_timebomb.mdl"
  299.             util.PrecacheModel(model)
  300.  
  301.             local TempC4 = ents.Create("prop_physics")
  302.             TempC4:SetModel(model)
  303.             TempC4:SetPos(TargetPosition)
  304.             TempC4:SetCollisionGroup(COLLISION_GROUP_NONE)
  305.             TempC4:Spawn()
  306.  
  307.             local mins, maxs = TempC4:GetCollisionBounds()
  308.  
  309.             TempC4:Remove()
  310.  
  311.             self:DestroyDuplicateTimeBombs()
  312.  
  313.             -- Use the mins and maxs vectors to check if there is enough space to spawn another c4
  314.             local tr = util.TraceHull({start = TargetPosition, endpos = TargetPosition, mins = mins, maxs = maxs, mask = MASK_BLOCKLOS})
  315.  
  316.             -- Check if the trace hit something
  317.             if not self:GetOwner():IsLineOfSightClear(TargetPosition) or tr.Hit then
  318.                 TargetPosition = self:GetOwner():EyePos()
  319.             end
  320.  
  321.             local ent = ents.Create("cod-timebomb")
  322.             ent:SetPos(Vector(0,0,0))
  323.             ent:SetOwner(self:GetOwner())  -- Disables collision between the C4 and its owner
  324.             ent:SetPos(TargetPosition)
  325.             ent:SetAngles(Angle(1,0,0))
  326.             ent:Spawn()
  327.             ent:SetOwner(self:GetOwner())  -- Disables collision between the C4 and its owner
  328.             ent.BombOwner = self:GetOwner()
  329.             ent.ThisTrigger = self
  330.             ent.ExplodedViaWorld = false
  331.             ent.QueuedForExplode = false
  332.             ent.UniqueExplodeTimer = "ExplodeTimer" .. self:GetOwner():SteamID() .. math.Rand(1, 1000)
  333.             ent:SetNWString("OwnerID", self:GetOwner():SteamID())
  334.             ent:SetNWString("OwnerNick", self:GetOwner():Nick())
  335.  
  336.             local phys = ent:GetPhysicsObject()
  337.  
  338.             --phys:SetMass(0.6)
  339.  
  340.             -- Compensate for the offcenter spawn
  341.             local aimvector = self:GetOwner():GetAimVector()
  342.             local aimangle = aimvector:Angle()
  343.             aimangle:RotateAroundAxis(aimangle:Up(), -1.5)
  344.             aimvector = aimangle:Forward()
  345.             phys:ApplyForceCenter( aimvector * 1500)
  346.  
  347.             -- The positive z coordinate emulates the spin from a left underhand throw
  348.             local angvel = Vector(0, math.random(-5000,-2000), math.random(-100,-900))
  349.             angvel:Rotate(-1 * ent:EyeAngles())
  350.             angvel:Rotate(Angle(0, self:GetOwner():EyeAngles().y, 0))
  351.  
  352.             --local angvel = Vector(0, math.random(-5000,-2000), math.random(-100,-900))
  353.             angvel.x = math.Clamp(angvel.x, -1000, 1000)
  354.             angvel.y = math.Clamp(angvel.y, -1000, 1000)
  355.             angvel.z = math.Clamp(angvel.z, -1000, 1000)
  356.  
  357.             phys:SetAngleVelocity(Vector(math.Clamp(angvel.x, -2000, 2000), math.Clamp(angvel.y, -2000, 2000), math.Clamp(angvel.z, -2000, 2000)))
  358.             if engine.ActiveGamemode() ~= "nzombies" then
  359.                 --undo.Create("Time Bomb")
  360.                 --  undo.AddEntity(ent)
  361.                 --  undo.SetPlayer(self:GetOwner())
  362.                 --undo.Finish()
  363.  
  364.                 self:GetOwner():AddCount("sents", ent) -- Add to the SENTs count ( ownership )
  365.                 self:GetOwner():AddCount("my_props", ent) -- Add count to our personal count
  366.                 self:GetOwner():AddCleanup("sents", ent) -- Add item to the sents cleanup
  367.                 self:GetOwner():AddCleanup("my_props", ent) -- Add item to the cleanup
  368.             end
  369.         end
  370.     end)
  371.  
  372.     self:SetNextPrimaryFire(CurTime() + 1.1)
  373.     self:SetNextSecondaryFire(CurTime() + 1.35)
  374. end
  375.  
  376. function SWEP:DestroyDuplicateTimeBombs()
  377.     for k, v in ipairs( ents.FindByClass( "cod-timebomb" ) ) do
  378.         if v.BombOwner == self:GetOwner() then
  379.             v:StopSound("hoff/zmb/timebomb/timebomb_plant_2d.mp3")
  380.             v:Remove()
  381.         end
  382.     end
  383. end
  384.  
  385. function SWEP:ShouldDropOnDie()
  386.     return false
  387. end
  388.  
  389. if CLIENT then
  390.     surface.CreateFont( "TimeBombFont", {
  391.         font = "Arial",
  392.         antialias = true,
  393.         size = 30,
  394.         outline = true
  395.     } )
  396. end
  397.  
  398. SWEP.RelativeTime = 0
  399. function SWEP:UpdateRelativeClock()
  400.     self.RelativeTime = os.clock()
  401. end
  402.  
  403. SWEP.ReticleMaterial = Material("models/hoff/weapons/timebomb/timebomb_reticle.png")
  404. SWEP.BombMaterial = Material("models/hoff/weapons/timebomb/zm_hud_icon_time_bomb_64")
  405. function SWEP:DrawHUD()
  406.     surface.SetDrawColor( 255, 255, 255, 255 )
  407.     surface.SetMaterial( self.ReticleMaterial )
  408.     surface.DrawTexturedRect( ScrW() / 2 - 24, ScrH() / 2 - 24, 46, 46 )
  409.  
  410.     if self:GetNWBool("bInitialDeploy") then
  411.         local y = ScrH() / 2
  412.         draw.DrawText("Press RMB to save, then press LMB to restore", "Trebuchet24", ScrW() / 2, y - 65, Color(255, 255, 255, 255),TEXT_ALIGN_CENTER)
  413.     end
  414.  
  415.     if self:GetNWBool("bTimeBombOut") and engine.ActiveGamemode() ~= "nzombies" then
  416.         local BombIconPosY = (ScrH() - ScrH() / 4 - 81)
  417.         surface.SetMaterial(self.BombMaterial)
  418.         surface.SetDrawColor( 255, 255, 255, 255 )
  419.         surface.DrawTexturedRect(80, BombIconPosY, 70, 70)
  420.  
  421.         local TimeSinceBomb = self.RelativeTime >= 0 and os.difftime(os.clock(), self.RelativeTime) or "-1"
  422.         local FormattedTime = string.FormattedTime( TimeSinceBomb )
  423.         local PrettyTime = FormattedTime.m < 1 and FormattedTime.s .. "s" or FormattedTime.m .. "m"
  424.         if FormattedTime.h > 0 then
  425.             PrettyTime = FormattedTime.m > 0 and FormattedTime.h .. "h " .. FormattedTime.m .. "m" or FormattedTime.h .. "h"
  426.         end
  427.         draw.DrawText(PrettyTime, "TimeBombFont", 115, BombIconPosY + 20, Color(255, 255, 255, 255),TEXT_ALIGN_CENTER)
  428.     end
  429. end
  430.  
  431. function SWEP:Think()
  432.     if CLIENT then
  433.         return
  434.     end
  435.     if self:Ammo1() <= 0 then
  436.         if self.CurrentState ~= TimeBombState.VM_TIMEBOMB_TICKERONLY then
  437.             self:SetCurrentState(TimeBombState.VM_TIMEBOMB_TICKERONLY)
  438.         end
  439.     else
  440.         if self.CurrentState ~= TimeBombState.VM_TIMEBOMB_BOTH then
  441.             self:SetCurrentState(TimeBombState.VM_TIMEBOMB_BOTH)
  442.         end
  443.     end
  444. end
  445.  
  446. SWEP.ChangingStates = false
  447. SWEP.PlayingAnimation = false
  448. function SWEP:SetCurrentState(NewState)
  449.     if self.ChangingStates or self.PlayingAnimation then
  450.         return false
  451.     end
  452.  
  453.     self.CurrentState = NewState
  454.     self.ChangingStates = true
  455.  
  456.     if NewState == TimeBombState.VM_TIMEBOMB_TICKERONLY then
  457.         self:SetHoldType("Slam")
  458.         self:SendWeaponAnim(ACT_VM_HITLEFT)
  459.         timer.Simple(0.5, function()
  460.             if not IsValid(self) then
  461.                 return false
  462.             end
  463.             self.ChangingStates = false
  464.             if self:GetOwner():GetActiveWeapon() != self then
  465.                 return false
  466.             end
  467.             self:SendWeaponAnim(ACT_VM_IDLE_LOWERED)
  468.             self:StopSound("hoff/zmb/timebomb/timebomb_hold_loop_low.wav")
  469.         end)
  470.     elseif NewState == TimeBombState.VM_TIMEBOMB_BOTH then
  471.         self:SetHoldType("duel")
  472.         self:SendWeaponAnim(ACT_VM_DRAW)
  473.         self:SetNextPrimaryFire(CurTime() + 0.6)
  474.         self:SetNextSecondaryFire(CurTime() + 0.6)
  475.         timer.Simple(0.5, function()
  476.             if not IsValid(self) then
  477.                 return false
  478.             end
  479.             self.ChangingStates = false
  480.             if self:GetOwner():GetActiveWeapon() != self then
  481.                 return false
  482.             end
  483.             self:SendWeaponAnim(ACT_VM_IDLE)
  484.             self:EmitSound("hoff/zmb/timebomb/timebomb_hold_loop_low.wav", 45)
  485.         end)
  486.     end
  487.     return true
  488. end
  489.  
  490. function SWEP:PlayAnim(NewAnim)
  491.     if self.PlayingAnimation then
  492.         return false
  493.     end
  494.     self.PlayingAnimation = true
  495.  
  496.     self:SendWeaponAnim(NewAnim)
  497.  
  498.     if NewAnim == ACT_VM_DRYFIRE then
  499.         timer.Simple(0.67,function()
  500.             if not IsValid(self) then
  501.                 return
  502.             end
  503.             self.PlayingAnimation = false
  504.             if self:GetOwner():GetActiveWeapon() != self then
  505.                 return false
  506.             end
  507.             self:SendWeaponAnim(ACT_VM_IDLE_LOWERED)
  508.         end)
  509.     elseif NewAnim == ACT_VM_PRIMARYATTACK then
  510.         timer.Simple(0.67,function()
  511.             if not IsValid(self) then
  512.                 return
  513.             end
  514.             self.PlayingAnimation = false
  515.             if self:GetOwner():GetActiveWeapon() != self then
  516.                 return false
  517.             end
  518.             self:SendWeaponAnim(ACT_VM_IDLE)
  519.         end)
  520.     end
  521.     return true
  522. end
  523.  
  524. function SWEP:PlayPrimaryFireAnim()
  525.     if self.ChangingStates or self.PlayingAnimation then
  526.         return false
  527.     end
  528.     if self.CurrentState == TimeBombState.VM_TIMEBOMB_TICKERONLY then
  529.         return self:PlayAnim(ACT_VM_DRYFIRE)
  530.     elseif self.CurrentState == TimeBombState.VM_TIMEBOMB_BOTH then
  531.         return self:PlayAnim(ACT_VM_PRIMARYATTACK)
  532.     end
  533. end
  534.  
  535. function SWEP:Holster()
  536.     self:StopSound("hoff/zmb/timebomb/timebomb_hold_loop_low.wav")
  537.     return true
  538. end
  539.  
  540. function SWEP:OnRemove()
  541.     self:StopSound("hoff/zmb/timebomb/timebomb_hold_loop_low.wav")
  542. end
  543.  
  544. hook.Add("PlayerDroppedWeapon", "StopTimeBombSound", function(owner, wep)
  545.     if IsValid(wep) and wep:GetClass() == "seal6-timebomb" then
  546.         wep:StopSound("hoff/zmb/timebomb/timebomb_hold_loop_low.wav")
  547.     end
  548. end)
  549.  
  550. function SWEP:Equip(ply)
  551.     if engine.ActiveGamemode() == "nzombies" then
  552.         timer.Simple(0.1, function()
  553.             ply:SetAmmo(1, "nz_specialgrenade")
  554.         end)
  555.     end
  556. end
  557.  
  558. if engine.ActiveGamemode() == "nzombies" then
  559.     if SERVER then
  560.         util.AddNetworkString("DisplayTimeBombRound")
  561.         util.AddNetworkString("RemoveTimeBombRound")
  562.     else
  563.         net.Receive("DisplayTimeBombRound", function()
  564.             local Round = net.ReadInt(16)
  565.             local BombWep = net.ReadEntity()
  566.             local OwnerIndex = BombWep.Owner:SteamID()
  567.  
  568.             hook.Add( "HUDPaint", "ShowTimeBombRound" .. OwnerIndex, function()
  569.                 if !IsValid(BombWep) then
  570.                     hook.Remove("HUDPaint", "ShowTimeBombRound" .. OwnerIndex)
  571.                     return
  572.                 end
  573.  
  574.                 local BombIconPosY = (ScrH() - ScrH() / 4 - 75)
  575.  
  576.                 surface.SetMaterial(Material("models/hoff/weapons/timebomb/zm_hud_icon_time_bomb_64"))
  577.                 surface.SetDrawColor( 255, 255, 255, 255 )
  578.                 surface.DrawTexturedRect(15, BombIconPosY, 70, 70)
  579.  
  580.                 draw.DrawText(Round, "Arialfbomb", 50, BombIconPosY + 18, Color(255, 255, 255, 255),TEXT_ALIGN_CENTER)
  581.             end)
  582.         end)
  583.  
  584.         net.Receive("RemoveTimeBombRound", function()
  585.             local BombOwner = net.ReadEntity()
  586.             local OwnerIndex = BombOwner:SteamID()
  587.  
  588.             hook.Remove("HUDPaint", "ShowTimeBombRound" .. OwnerIndex)
  589.         end)
  590.     end
  591. end
  592.  
  593. function SWEP:Precache()
  594.     util.PrecacheSound( "hoff/zmb/timebomb/timebomb_hold_loop_low.wav" )
  595.     util.PrecacheSound( "hoff/zmb/timebomb/timebomb_plant_2d.mp3" )
  596.     util.PrecacheSound( "hoff/zmb/timebomb/timebomb_activate_1.mp3" )
  597.     util.PrecacheSound( "hoff/zmb/timebomb/timebomb_activate_2.mp3" )
  598.  
  599.     util.PrecacheModel( "models/hoff/weapons/timebomb/c_timebomb.mdl" )
  600.     util.PrecacheModel( "models/hoff/weapons/timebomb/w_timebomb.mdl" )
  601. end
  602.  
  603. SWEP.ViewModelBoneMods = {
  604.     ["tag_view"] = { scale = Vector(1, 1, 1), pos = Vector(0, 0, 0), angle = Angle(0, 0, 0) },
  605.     ["ValveBiped.Bip01_R_Forearm"] = { scale = Vector(1, 1, 1), pos = Vector(0, 0, 0), angle = Angle(0, 0, 0) },
  606.     ["ValveBiped.Bip01_L_Forearm"] = { scale = Vector(1, 1, 1), pos = Vector(0, 0, 0), angle = Angle(0, 0, 0) }
  607. }
Advertisement
Add Comment
Please, Sign In to add comment