Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- variables
- placed = false
- position = 0
- angleb = 0
- if SERVER then
- AddCSLuaFile( "shared.lua" )
- end
- SWEP.HoldType = "normal"
- if CLIENT then
- SWEP.PrintName = "Spy Camera"
- SWEP.Slot = 7
- SWEP.ViewModelFOV = 10
- SWEP.EquipMenuData = {
- type="Weapon + Active use item",
- model="models/dav0r/camera.mdl",
- desc=""
- };
- SWEP.Icon = "VGUI/ttt/icon_radio"
- end
- SWEP.Base = "weapon_tttbase"
- SWEP.ViewModel = "models/weapons/v_crowbar.mdl"
- SWEP.WorldModel = "models/dav0r/camera.mdl"
- SWEP.DrawCrosshair = true
- SWEP.ViewModelFlip = false
- SWEP.Primary.ClipSize = -1
- SWEP.Primary.DefaultClip = -1
- SWEP.Primary.Automatic = true
- SWEP.Primary.Ammo = "none"
- SWEP.Primary.Delay = 1.0
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = -1
- SWEP.Secondary.Automatic = true
- SWEP.Secondary.Ammo = "none"
- SWEP.Secondary.Delay = 1.0
- SWEP.Kind = WEAPON_EQUIP2
- SWEP.CanBuy = {ROLE_TRAITOR}
- SWEP.LimitedStock = true
- SWEP.WeaponID = AMMO_RADIO
- SWEP.AllowDrop = false
- SWEP.NoSights = true
- function SWEP:OnDrop()
- self:Remove()
- end
- function SWEP:PrimaryAttack()
- self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- self:CameraStick()
- end
- function SWEP:SecondaryAttack()
- self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
- self:CameraStick()
- end
- local throwsound = Sound( "Weapon_SLAM.SatchelThrow" )
- function SWEP:CameraStick()
- if SERVER then
- local ply = self.Owner
- if not ValidEntity(ply) then return end
- if self.Planted then return end
- local ignore = {ply, self.Weapon}
- local spos = ply:GetShootPos()
- local epos = spos + ply:GetAimVector() * 80
- local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})
- if tr.HitWorld then
- local camera = ents.Create("gmod_cameraprop")
- if ValidEntity(camera) then
- camera:PointAtEntity(ply)
- local tr_ent = util.TraceEntity({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID}, camera)
- if tr_ent.HitWorld then
- local ang = tr_ent.HitNormal:Angle()
- camera:SetPos(tr_ent.HitPos) -- + ang:Forward()
- camera:SetAngles(ang)
- camera:SetOwner(ply)
- camera:Spawn()
- local phys = camera:GetPhysicsObject()
- if ValidEntity(phys) then
- phys:EnableMotion(false)
- end
- camera.IsOnWall = true
- self:Remove()
- self.Planted = true
- position = camera:GetPos()
- angleb = camera:GetAngles()
- placed = true
- end
- end
- end
- end
- end
- function SWEP:Reload()
- return false
- end
- function SWEP:OnRemove()
- if CLIENT and ValidEntity(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
- RunConsoleCommand("lastinv")
- end
- end
- if CLIENT then
- local hudtxt = {text="Click to place the radio", font="TabLarge", xalign=TEXT_ALIGN_RIGHT, pos={}}
- function SWEP:DrawHUD()
- hudtxt.pos[1] = ScrW() - 80
- hudtxt.pos[2] = ScrH() - 80
- draw.TextShadow(hudtxt, 2)
- end
- end
- -- Invisible, same hacks as holstered weapon
- function SWEP:Deploy()
- if SERVER and IsValid(self.Owner) then
- self.Owner:DrawViewModel(false)
- end
- return true
- end
- function SWEP:DrawWorldModel()
- end
- function SWEP:DrawWorldModelTranslucent()
- end
- local function OriginCam()
- local camera = ents.FindByName("camera")
- local CamData = {}
- CamData.angles = angleb
- CamData.origin = position
- CamData.x = 0
- CamData.y = 0
- CamData.w = ScrW() / 3
- CamData.h = ScrH() / 3
- if placed then
- render.RenderView( CamData )
- end
- end
- hook.Add("HUDPaint", "OriginCam", OriginCam)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement