Advertisement
Guest User

Untitled

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