Advertisement
Guest User

Untitled

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