Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile()
- if SERVER then
- AddCSLuaFile("cl_menu.lua")
- end
- if CLIENT then
- SWEP.PrintName = "Keys"
- SWEP.Slot = 1
- SWEP.SlotPos = 1
- SWEP.DrawAmmo = false
- SWEP.DrawCrosshair = false
- include("cl_menu.lua")
- end
- SWEP.Author = "Michael Conway"
- SWEP.Instructions = ""
- SWEP.Contact = ""
- SWEP.Purpose = ""
- SWEP.IsDarkRPKeys = true
- SWEP.HoldType = "slam"
- SWEP.ViewModelFOV = 62.5
- SWEP.ViewModelFlip = true
- SWEP.UseHands = false
- SWEP.ViewModel = "models/weapons/c_slam.mdl"
- SWEP.WorldModel = "models/santosrp/key/car_key.mdl"
- SWEP.ShowViewModel = false
- SWEP.ShowWorldModel = false
- SWEP.ViewModelBoneMods = {
- ["Detonator"] = { scale = Vector(0.009, 0.009, 0.009), pos = Vector(0, 0, 0), angle = Angle(0, 0, 0) },
- ["ValveBiped.Bip01_R_UpperArm"] = { scale = Vector(1, 1, 1), pos = Vector(0, 0, -10), angle = Angle(0, 0, 0) },
- ["Slam_base"] = { scale = Vector(0.009, 0.009, 0.009), pos = Vector(0, 0, 0), angle = Angle(0, 0, 0) }
- }
- SWEP.VElements = {
- ["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 = {} }
- }
- SWEP.WElements = {
- ["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 = {} }
- }
- SWEP.IronSightsPos = Vector(4.239, 0, -0.88)
- SWEP.IronSightsAng = Vector(0, 0, 27.34)
- SWEP.Spawnable = true
- SWEP.AdminOnly = true
- SWEP.Category = "DarkRP (Utility)"
- SWEP.Sound = "doors/door_latch3.wav"
- SWEP.Primary.ClipSize = -1
- SWEP.Primary.DefaultClip = 0
- SWEP.Primary.Automatic = false
- SWEP.Primary.Ammo = ""
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = 0
- SWEP.Secondary.Automatic = false
- SWEP.Secondary.Ammo = ""
- function SWEP:Initialize()
- end
- function SWEP:Deploy()
- if CLIENT or not IsValid(self:GetOwner()) then return true end
- self:GetOwner():DrawWorldModel(false)
- return true
- end
- function SWEP:Holster()
- return true
- end
- function SWEP:PreDrawViewModel()
- return true
- end
- local function lookingAtLockable(ply, ent)
- local eyepos = ply:EyePos()
- return IsValid(ent) and
- ent:isKeysOwnable() and
- not ent:getKeysNonOwnable() and
- (
- ent:isDoor() and eyepos:Distance(ent:GetPos()) < 65
- or
- ent:IsVehicle() and eyepos:Distance(ent:NearestPoint(eyepos)) < 100
- )
- end
- local function lockUnlockAnimation(ply, snd)
- ply:EmitSound("npc/metropolice/gear" .. math.floor(math.Rand(1,7)) .. ".wav")
- timer.Simple(0.9, function() if IsValid(ply) then ply:EmitSound(snd) end end)
- local RP = RecipientFilter()
- RP:AddAllPlayers()
- umsg.Start("anim_keys", RP)
- umsg.Entity(ply)
- umsg.String("usekeys")
- umsg.End()
- ply:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_GMOD_GESTURE_ITEM_PLACE, true)
- end
- local function doKnock(ply, sound)
- ply:EmitSound(sound, 100, math.random(90, 110))
- umsg.Start("anim_keys")
- umsg.Entity(ply)
- umsg.String("knocking")
- umsg.End()
- ply:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_HL2MP_GESTURE_RANGE_ATTACK_FIST, true)
- end
- function SWEP:PrimaryAttack()
- local trace = self:GetOwner():GetEyeTrace()
- if not lookingAtLockable(self:GetOwner(), trace.Entity) then return end
- self:SetNextPrimaryFire(CurTime() + 0.3)
- if CLIENT then return end
- if self:GetOwner():canKeysLock(trace.Entity) then
- trace.Entity:keysLock() -- Lock the door immediately so it won't annoy people
- lockUnlockAnimation(self:GetOwner(), self.Sound)
- elseif trace.Entity:IsVehicle() then
- DarkRP.notify(self:GetOwner(), 1, 3, DarkRP.getPhrase("do_not_own_ent"))
- else
- doKnock(self:GetOwner(), "physics/wood/wood_crate_impact_hard2.wav")
- end
- end
- function SWEP:SecondaryAttack()
- local trace = self:GetOwner():GetEyeTrace()
- if not lookingAtLockable(self:GetOwner(), trace.Entity) then return end
- self:SetNextSecondaryFire(CurTime() + 0.3)
- if CLIENT then return end
- if self:GetOwner():canKeysUnlock(trace.Entity) then
- trace.Entity:keysUnLock() -- Unlock the door immediately so it won't annoy people
- lockUnlockAnimation(self:GetOwner(), self.Sound)
- elseif trace.Entity:IsVehicle() then
- DarkRP.notify(self:GetOwner(), 1, 3, DarkRP.getPhrase("do_not_own_ent"))
- else
- doKnock(self:GetOwner(), "physics/wood/wood_crate_impact_hard3.wav")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement