Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.90 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.     if Target:GetDoorOwner():GetPlayTime()<36000 then
  53.         if Target:GetDoorOwner().RoleplayData.Organization==0 then
  54.             if #Target:GetDoorOwner().RoleplayData.Buddies==0 then
  55.                 self.Owner:Notify("You try to raid a noob. Shame on you.")
  56.                 return false;
  57.             end
  58.            
  59.             if #Target:GetDoorOwner().RoleplayData.Buddies<3 then
  60.                 for k,v in pairs(Target:GetDoorOwner().RoleplayData.Buddies) do
  61.                     if v:GetPlayTime()>36000 then
  62.                         local Noob=false
  63.                     end
  64.                 end
  65.                 if (Noob==false) then
  66.                     self.Owner:Notify("You try to raid a noob. Shame on you.")
  67.                     return false;
  68.                 end
  69.             end
  70.            
  71.         end
  72.        
  73.     end
  74.    
  75.     self:EmitSound(self.BatterSound);
  76.    
  77.     if self.Owner:GetSkillLevel('strength') > 3 then
  78.         self.BreakSelfChance = self.BreakSelfChance - 5
  79.         self.PercentChance = self.PercentChance + 5
  80.     end
  81.    
  82.     local function whatlol ( )
  83.         if !self or !self:IsValid() then return false; end
  84.         local EyeTrace = self.Owner:GetEyeTrace()
  85.         if !EyeTrace.Entity:IsValid() or !(EyeTrace.Entity:IsDoor() and EyeTrace.Entity:IsOwnable()) then
  86.             self.Owner:Notify('You lost your focus');
  87.             return false;
  88.         end
  89.        
  90.         local Randomness = math.random(1, 100);
  91.        
  92.         local SetOffHouseAlarm = true;
  93.         if Randomness <= self.BreakSelfChance then
  94.             self:Brake();
  95.         elseif Randomness <= self.BreakSelfChance + self.PercentChance then    
  96.             Target:Fire('unlock', '', 0);
  97.             Target:Fire('open', '', .5);
  98.             Target:SetNWBool("DoorLock", false)
  99.             Target:SetNWInt("PixLoxTime", CurTime())
  100.             SetOffHouseAlarm = false;
  101.            
  102.             if IsValid(self.Owner) then
  103.                 self.Owner:AddProgress(32, 1);
  104.             end
  105.         end
  106.        
  107.         if SetOffHouseAlarm then           
  108.             local Group = Target:GetDoorGroup();
  109.  
  110.             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
  111.                 umsg.Start('perp_house_alarm');
  112.                     umsg.Entity(Target);
  113.                 umsg.End();
  114.                
  115.                 local LocationText = Target:GetLocationText();
  116.                
  117.                 umsg.Start('PE_CUSTOMCHAT', Target:GetDoorOwner());
  118.                     umsg.Entity(Target:GetDoorOwner());
  119.                     umsg.String('[ Burglar Alarm ] A break in has occurred at ' .. LocationText .. '. Police requested.');
  120.                     umsg.Short(CHAT_911);
  121.                 umsg.End();
  122.                
  123.                 for k, v in pairs(player.GetAll()) do
  124.                     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
  125.                         umsg.Start('PE_CUSTOMCHAT', v);
  126.                             umsg.Entity(Target:GetDoorOwner());
  127.                             umsg.String('[ Burglar Alarm ] A break in has occurred at ' .. LocationText .. '. Police requested.');
  128.                             umsg.Short(CHAT_911);
  129.                         umsg.End();
  130.                     end
  131.                 end
  132.                
  133.                 Target:GetTable().LastSirenPlay = CurTime()
  134.             end
  135.         end
  136.     end
  137.    
  138.     if SERVER then
  139.         timer.Simple(1.5, whatlol);
  140.     end
  141. end
  142.  
  143. function SWEP:PrimaryAttack()
  144.     local EyeTrace = self.Owner:GetEyeTrace()
  145.  
  146.     if !EyeTrace.Entity:IsValid() or !(EyeTrace.Entity:IsDoor() and EyeTrace.Entity:IsOwnable()) then return false; end
  147.    
  148.     local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos);
  149.    
  150.     if Distance > 75 then return false; end
  151.    
  152.     self:TryToBatter(EyeTrace.Entity);
  153.  
  154.     self.Weapon:SetNextPrimaryFire(CurTime() + 3)
  155.     self.Weapon:SetNextSecondaryFire(CurTime() + 3)
  156. end
  157.  
  158. function SWEP:SecondaryAttack()
  159.     self:PrimaryAttack();
  160. end
  161.  
  162. function SWEP:Brake()
  163.     for k,v in pairs(self.Owner:GetTable().weaponsEquipped) do
  164.         if v=='weapon_lock_pick' then
  165.             table.remove(self.Owner:GetTable().weaponsEquipped,k);
  166.         end
  167.     end
  168.     self:EmitSound(self.BreakSound);
  169.     self.Owner:Notify('Your lock pick broke!');
  170.     self:Remove();
  171. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement