Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. AddCSLuaFile()
  2.  
  3. if SERVER then
  4. AddCSLuaFile("cl_menu.lua")
  5. end
  6.  
  7. if CLIENT then
  8. SWEP.PrintName = "Keys"
  9. SWEP.Slot = 1
  10. SWEP.SlotPos = 1
  11. SWEP.DrawAmmo = false
  12. SWEP.DrawCrosshair = false
  13.  
  14. include("cl_menu.lua")
  15. end
  16.  
  17. SWEP.Author = "Michael Conway"
  18. SWEP.Instructions = ""
  19. SWEP.Contact = ""
  20. SWEP.Purpose = ""
  21. SWEP.IsDarkRPKeys = true
  22.  
  23. SWEP.HoldType = "slam"
  24. SWEP.ViewModelFOV = 62.5
  25. SWEP.ViewModelFlip = true
  26. SWEP.UseHands = false
  27. SWEP.ViewModel = "models/weapons/c_slam.mdl"
  28. SWEP.WorldModel = "models/santosrp/key/car_key.mdl"
  29. SWEP.ShowViewModel = false
  30. SWEP.ShowWorldModel = false
  31.  
  32. SWEP.ViewModelBoneMods = {
  33. ["Detonator"] = { scale = Vector(0.009, 0.009, 0.009), pos = Vector(0, 0, 0), angle = Angle(0, 0, 0) },
  34. ["ValveBiped.Bip01_R_UpperArm"] = { scale = Vector(1, 1, 1), pos = Vector(0, 0, -10), angle = Angle(0, 0, 0) },
  35. ["Slam_base"] = { scale = Vector(0.009, 0.009, 0.009), pos = Vector(0, 0, 0), angle = Angle(0, 0, 0) }
  36. }
  37.  
  38. SWEP.VElements = {
  39. ["Keys"] = { type = "Model", model = "models/santosrp/key/car_key.mdl", bone = "ValveBiped.Bip01_L_Hand", rel = "", pos = Vector(4.959, -1.933, 2.69), angle = Angle(7.727, 7.168, 161.57), size = Vector(1.21, 1.21, 1.21), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
  40. }
  41. SWEP.WElements = {
  42. ["Keys"] = { type = "Model", model = "models/santosrp/key/car_key.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(7.637, 1.254, -0.427), angle = Angle(0, 0, -75.82), size = Vector(1.136, 1.136, 1.136), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
  43. }
  44. SWEP.IronSightsPos = Vector(4.239, 0, -0.88)
  45. SWEP.IronSightsAng = Vector(0, 0, 27.34)
  46.  
  47. SWEP.Spawnable = true
  48. SWEP.AdminOnly = true
  49. SWEP.Category = "DarkRP (Utility)"
  50. SWEP.Sound = "doors/door_latch3.wav"
  51. SWEP.Primary.ClipSize = -1
  52. SWEP.Primary.DefaultClip = 0
  53. SWEP.Primary.Automatic = false
  54. SWEP.Primary.Ammo = ""
  55.  
  56. SWEP.Secondary.ClipSize = -1
  57. SWEP.Secondary.DefaultClip = 0
  58. SWEP.Secondary.Automatic = false
  59. SWEP.Secondary.Ammo = ""
  60.  
  61. function SWEP:Initialize()
  62. end
  63.  
  64. function SWEP:Deploy()
  65. if CLIENT or not IsValid(self:GetOwner()) then return true end
  66. self:GetOwner():DrawWorldModel(false)
  67. return true
  68. end
  69.  
  70. function SWEP:Holster()
  71. return true
  72. end
  73.  
  74. function SWEP:PreDrawViewModel()
  75. return true
  76. end
  77.  
  78. local function lookingAtLockable(ply, ent)
  79. local eyepos = ply:EyePos()
  80. return IsValid(ent) and
  81. ent:isKeysOwnable() and
  82. not ent:getKeysNonOwnable() and
  83. (
  84. ent:isDoor() and eyepos:Distance(ent:GetPos()) < 65
  85. or
  86. ent:IsVehicle() and eyepos:Distance(ent:NearestPoint(eyepos)) < 100
  87. )
  88.  
  89. end
  90.  
  91. local function lockUnlockAnimation(ply, snd)
  92. ply:EmitSound("npc/metropolice/gear" .. math.floor(math.Rand(1,7)) .. ".wav")
  93. timer.Simple(0.9, function() if IsValid(ply) then ply:EmitSound(snd) end end)
  94.  
  95. local RP = RecipientFilter()
  96. RP:AddAllPlayers()
  97.  
  98. umsg.Start("anim_keys", RP)
  99. umsg.Entity(ply)
  100. umsg.String("usekeys")
  101. umsg.End()
  102.  
  103. ply:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_GMOD_GESTURE_ITEM_PLACE, true)
  104. end
  105.  
  106. local function doKnock(ply, sound)
  107. ply:EmitSound(sound, 100, math.random(90, 110))
  108. umsg.Start("anim_keys")
  109. umsg.Entity(ply)
  110. umsg.String("knocking")
  111. umsg.End()
  112.  
  113. ply:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_HL2MP_GESTURE_RANGE_ATTACK_FIST, true)
  114. end
  115.  
  116. function SWEP:PrimaryAttack()
  117. local trace = self:GetOwner():GetEyeTrace()
  118.  
  119. if not lookingAtLockable(self:GetOwner(), trace.Entity) then return end
  120.  
  121. self:SetNextPrimaryFire(CurTime() + 0.3)
  122.  
  123. if CLIENT then return end
  124.  
  125. if self:GetOwner():canKeysLock(trace.Entity) then
  126. trace.Entity:keysLock() -- Lock the door immediately so it won't annoy people
  127. lockUnlockAnimation(self:GetOwner(), self.Sound)
  128. elseif trace.Entity:IsVehicle() then
  129. DarkRP.notify(self:GetOwner(), 1, 3, DarkRP.getPhrase("do_not_own_ent"))
  130. else
  131. doKnock(self:GetOwner(), "physics/wood/wood_crate_impact_hard2.wav")
  132. end
  133. end
  134.  
  135. function SWEP:SecondaryAttack()
  136. local trace = self:GetOwner():GetEyeTrace()
  137.  
  138. if not lookingAtLockable(self:GetOwner(), trace.Entity) then return end
  139.  
  140. self:SetNextSecondaryFire(CurTime() + 0.3)
  141.  
  142. if CLIENT then return end
  143.  
  144. if self:GetOwner():canKeysUnlock(trace.Entity) then
  145. trace.Entity:keysUnLock() -- Unlock the door immediately so it won't annoy people
  146. lockUnlockAnimation(self:GetOwner(), self.Sound)
  147. elseif trace.Entity:IsVehicle() then
  148. DarkRP.notify(self:GetOwner(), 1, 3, DarkRP.getPhrase("do_not_own_ent"))
  149. else
  150. doKnock(self:GetOwner(), "physics/wood/wood_crate_impact_hard3.wav")
  151. end
  152. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement