Advertisement
Guest User

Untitled

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