Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.28 KB | None | 0 0
  1. if SERVER then
  2.     AddCSLuaFile("shared.lua")
  3. end
  4.  
  5. if CLIENT then
  6.     SWEP.PrintName = "Lock Pick"
  7.     SWEP.Slot = 2
  8.     SWEP.SlotPos = 1
  9.     SWEP.DrawAmmo = false
  10.     SWEP.DrawCrosshair = false
  11. end
  12.  
  13. SWEP.Author = "HuntsKikBut"
  14. SWEP.Instructions = "Left Click: Attempt to pick lock."
  15. SWEP.Contact = ""
  16. SWEP.Purpose = ""
  17.  
  18. SWEP.HoldType = "melee";
  19. SWEP.ViewModel = "models/weapons/v_crowbar.mdl";
  20. SWEP.WorldModel = "models/weapons/w_crowbar.mdl";
  21.  
  22. SWEP.ViewModelFOV = 62
  23. SWEP.ViewModelFlip = false
  24. SWEP.AnimPrefix  = "melee"
  25.  
  26. SWEP.BreakSound = "doors/handle_pushbar_locked1.wav"
  27. SWEP.BatterSound = "doors/door_locked2.wav"
  28. SWEP.BreakSelfChance = 15;
  29. SWEP.PercentChance = 8;
  30. SWEP.Spawnable = false
  31. SWEP.AdminSpawnable = true
  32. SWEP.Primary.ClipSize = -1
  33. SWEP.Primary.DefaultClip = 0
  34. SWEP.Primary.Automatic = false
  35. SWEP.Primary.Ammo = ""
  36.  
  37. SWEP.Secondary.ClipSize = -1
  38. SWEP.Secondary.DefaultClip = 0
  39. SWEP.Secondary.Automatic = false
  40. SWEP.Secondary.Ammo = ""
  41.  
  42. function SWEP:Initialize()
  43.     self:SetWeaponHoldType("melee")
  44. end
  45. function SWEP:CanPrimaryAttack ( ) return true; end
  46.  
  47. function SWEP:TryToBatter ( Target )
  48.     if Target:GetDoorOwner() == self.Owner then
  49.         self.Owner:Notify('You pick open your own doors. Use a key!');
  50.         return false;
  51.     end
  52.    
  53.     self:EmitSound(self.BatterSound);
  54.    
  55.     if self.Owner:GetSkillLevel('strength') > 3 then
  56.         self.BreakSelfChance = self.BreakSelfChance - 5
  57.         self.PercentChance = self.PercentChance + 5
  58.     end
  59.    
  60.     local function whatlol ( )
  61.         if !self or !self:IsValid() then return false; end
  62.         local EyeTrace = self.Owner:GetEyeTrace()
  63.         if !EyeTrace.Entity:IsValid() or !(EyeTrace.Entity:IsDoor() and EyeTrace.Entity:IsOwnable()) then
  64.             self.Owner:Notify('You lost your focus');
  65.             return false;
  66.         end
  67.        
  68.         local Randomness = math.random(1, 100);
  69.        
  70.         local SetOffHouseAlarm = true;
  71.         if Randomness <= self.BreakSelfChance then
  72.             self:Brake();
  73.         elseif Randomness <= self.BreakSelfChance + self.PercentChance then    
  74.             Target:Fire('unlock', '', 0);
  75.             Target:Fire('open', '', .5);
  76.             Target:SetNWBool("DoorLock", false)
  77.             Target:SetNWInt("PixLoxTime", CurTime())
  78.             SetOffHouseAlarm = false;
  79.            
  80.             if IsValid(self.Owner) then
  81.                 self.Owner:AddProgress(32, 1);
  82.             end
  83.         end
  84.        
  85.         if SetOffHouseAlarm then           
  86.             local Group = Target:GetDoorGroup();
  87.  
  88.             if GAMEMODE.HouseAlarms[Group] and (!Target:GetTable().LastSirenPlay or Target:GetTable().LastSirenPlay + 30 < CurTime()) and Target:GetDoorOwner() and Target:GetDoorOwner():IsValid() and Target:GetDoorOwner():IsPlayer() then
  89.                 umsg.Start('perp_house_alarm');
  90.                     umsg.Entity(Target);
  91.                 umsg.End();
  92.                
  93.                 local LocationText = Target:GetLocationText();
  94.                
  95.                 umsg.Start('PE_CUSTOMCHAT', Target:GetDoorOwner());
  96.                     umsg.Entity(Target:GetDoorOwner());
  97.                     umsg.String('[ Burglar Alarm ] A break in has occurred at ' .. LocationText .. '. Police requested.');
  98.                     umsg.Short(CHAT_911);
  99.                 umsg.End();
  100.                
  101.                 for k, v in pairs(player.GetAll()) do
  102.                     if v:Team() == TEAM_POLICE or v:Team() == TEAM_FIREMAN or v:Team() == TEAM_MAYOR or v:Team() == TEAM_PARAMEDIC or v:Team() == TEAM_SWAT then
  103.                         umsg.Start('PE_CUSTOMCHAT', v);
  104.                             umsg.Entity(Target:GetDoorOwner());
  105.                             umsg.String('[ Burglar Alarm ] A break in has occurred at ' .. LocationText .. '. Police requested.');
  106.                             umsg.Short(CHAT_911);
  107.                         umsg.End();
  108.                     end
  109.                 end
  110.                
  111.                 Target:GetTable().LastSirenPlay = CurTime()
  112.             end
  113.         end
  114.     end
  115.    
  116.     if SERVER then
  117.         timer.Simple(1.5, whatlol);
  118.     end
  119. end
  120.  
  121. function SWEP:PrimaryAttack()
  122.     local EyeTrace = self.Owner:GetEyeTrace()
  123.  
  124.     if !EyeTrace.Entity:IsValid() or !(EyeTrace.Entity:IsDoor() and EyeTrace.Entity:IsOwnable()) then return false; end
  125.    
  126.     local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos);
  127.    
  128.     if Distance > 75 then return false; end
  129.    
  130.     self:TryToBatter(EyeTrace.Entity);
  131.  
  132.     self.Weapon:SetNextPrimaryFire(CurTime() + 3)
  133.     self.Weapon:SetNextSecondaryFire(CurTime() + 3)
  134. end
  135.  
  136. function SWEP:SecondaryAttack()
  137.     self:PrimaryAttack();
  138. end
  139.  
  140. function SWEP:Brake()
  141.     for k,v in pairs(self.Owner:GetTable().weaponsEquipped) do
  142.         if v=='weapon_lock_pick' then
  143.             table.remove(self.Owner:GetTable().weaponsEquipped,k);
  144.         end
  145.     end
  146.     self:EmitSound(self.BreakSound);
  147.     self.Owner:Notify('Your lock pick broke!');
  148.     self:Remove();
  149. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement