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