Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- easylua.StartWeapon("testpacwep")
- -- pac
- if CLIENT then
- -- setup the swep to get all the PAC related functions
- pac.SetupSWEP(SWEP)
- -- you can also do this if you want, which is much easier while developing
- -- local pac_session = pac.luadata.ReadFile("pac3/sessions/pac_weapon.txt")
- local pac_session = {
- [1] = {
- ["children"] = {
- [1] = {
- ["children"] = {
- },
- ["self"] = {
- ["ParentName"] = "firstperon",
- ["ClassName"] = "model",
- ["Position"] = Vector(0, -1, 12),
- ["UniqueID"] = "3451410124",
- ["Size"] = 0.275,
- ["Bone"] = "crossbow model crossbow base",
- ["Name"] = "barrel firstperson",
- ["ParentUID"] = "3005904956",
- },
- },
- },
- ["self"] = {
- ["EditorExpand"] = true,
- ["UniqueID"] = "3005904956",
- ["OwnerName"] = "viewmodel",
- ["Name"] = "firstperon",
- ["ClassName"] = "group",
- },
- },
- [2] = {
- ["children"] = {
- [1] = {
- ["children"] = {
- },
- ["self"] = {
- ["ParentName"] = "thirdperson",
- ["ClassName"] = "model",
- ["Position"] = Vector(10, -0.6, -4),
- ["UniqueID"] = "508789991",
- ["Size"] = 0.35,
- ["Bone"] = "right hand",
- ["Name"] = "barrel thirdperson",
- ["ParentUID"] = "2950810582",
- },
- },
- },
- ["self"] = {
- ["EditorExpand"] = true,
- ["UniqueID"] = "2950810582",
- ["ClassName"] = "group",
- ["Name"] = "thirdperson",
- ["Description"] = "add parts to me!",
- },
- },
- }
- -- these two functions are called from server on deploy and holster
- function SWEP:AttachOutfit()
- self:AttachPACPart(pac_session)
- self:SetShowPACPartsInEditor(true)
- -- self:SetPACDrawDistance(0) this will turn off the draw distance
- end
- function SWEP:RemoveOutfit()
- self:RemovePACPart(pac_session)
- end
- -- remove the outfit if the weapon is removed as well
- function SWEP:OnRemove(...)
- self:RemoveOutfit()
- return self.BaseClass.OnRemove(self, ...)
- end
- -- pac part manipulation test
- function SWEP:PrimaryAttack(...)
- -- find the barrel part
- local tp_barrel = self:FindPACPart(pac_session, "barrel thirdperson")
- local fp_barrel = self:FindPACPart(pac_session, "barrel firstperson")
- -- I don't know..
- local i = self:Clip1()
- -- these parts might be NULL.
- if tp_barrel:IsValid() then
- tp_barrel:SetPosition(Vector(i, -0.6, -4))
- end
- -- Especially the viewmodel. PAC wont create the viewmodel group for those who don't own this weapon.
- if fp_barrel:IsValid() then
- fp_barrel:SetPosition(Vector(i, -1, 12))
- if fp_barrel.ClassName == "model" then
- local params = {}
- params.Num = 1000 -- admmiinnn
- -- cached_pos and cached_ang is what the obivous is. it's a cached result of getpos after offset calculations
- -- i could probably add functions like GetPos and GetAngles for this
- params.Src = fp_barrel.cached_pos - fp_barrel.cached_ang:Up()*50
- params.Dir = fp_barrel.cached_ang:Up()
- params.Spread = Vector(0.1, 0.1, 0)
- params.Tracer = 5
- params.TracerName = "Tracer"
- params.Force = 1
- params.Damage = 1
- params.AmmoType = "Pistol"
- -- make it so the part's model entity fire the bullets for no reason
- fp_barrel:GetEntity():FireBullets(params)
- end
- end
- return self.BaseClass.PrimaryAttack(self, ...)
- end
- end
- if CLIENT then
- net.Receive(SWEP.ClassName, function()
- local ent = net.ReadEntity()
- local event = net.ReadString()
- if ent:IsValid() and ent[event] then
- ent[event](ent)
- end
- end)
- end
- if SERVER then
- util.AddNetworkString(SWEP.ClassName)
- function SWEP:Deploy(...)
- net.Start(self.ClassName)
- net.WriteEntity(self)
- net.WriteString("AttachOutfit")
- net.Broadcast()
- return self.BaseClass.Deploy(self, ...)
- end
- function SWEP:Holster(...)
- net.Start(self.ClassName)
- net.WriteEntity(self)
- net.WriteString("RemoveOutfit")
- net.Broadcast()
- return self.BaseClass.Holster(self, ...)
- end
- function SWEP:OnDrop(...)
- self:Holster()
- return self.BaseClass.OnDrop(self, ...)
- end
- function SWEP:Think(...)
- local owner = self.Owner
- if owner:IsValid() and not self.deploy_hack then
- self:Deploy()
- self.deploy_hack = true
- end
- return self.BaseClass.Think(self, ...)
- end
- end
- SWEP.PrintName = "pac_weapon" -- 'Nice' Weapon name (Shown on HUD)
- SWEP.Slot = 2 -- Slot in the weapon selection menu
- SWEP.SlotPos = 3 -- Position in the slot
- SWEP.DrawAmmo = true -- Should draw the default HL2 ammo counter -- Should draw the default crosshair
- SWEP.DrawWeaponInfoBox = true -- Should draw the weapon info box
- SWEP.BounceWeaponIcon = true -- Should the weapon icon bounce?
- -- Variables that are used on both client and server
- SWEP.Category = "guns"
- SWEP.MuzzleAttachment = "1" -- Should be "1" for CSS models or "muzzle" for hl2 models
- SWEP.ShellEjectAttachment = "2" -- Should be "2" for CSS models or "1" for hl2 models
- SWEP.DrawCrosshair = false
- SWEP.ViewModelFOV = 65
- SWEP.ViewModelFlip = true
- SWEP.ViewModel = "models/weapons/v_crossbow.mdl"
- SWEP.WorldModel = "models/weapons/w_crossbow.mdl"
- SWEP.Base = "gdcw_base_pistol"
- SWEP.Spawnable = true
- SWEP.AdminSpawnable = true
- SWEP.Primary.Sound = Sound("Weapon_P228.Single")
- SWEP.Primary.Round = ("5_7mm")
- SWEP.Primary.RPM = 900 -- This is in Rounds Per Minute
- SWEP.Primary.ClipSize = 13 -- Size of a clip
- SWEP.Primary.DefaultClip = 14
- SWEP.Primary.KickUp = 0.4 -- Maximum up recoil (rise)
- SWEP.Primary.KickDown = 0.3 -- Maximum down recoil (skeet)
- SWEP.Primary.KickHorizontal = 0.3 -- Maximum up recoil (stock)
- SWEP.Primary.Automatic = false -- Automatic/Semi Auto
- SWEP.Primary.Ammo = "pistol"
- SWEP.Secondary.ClipSize = 1 -- Size of a clip
- SWEP.Secondary.DefaultClip = 1 -- Default number of bullets in a clip
- SWEP.Secondary.Automatic = false -- Automatic/Semi Auto
- SWEP.Secondary.Ammo = ""
- SWEP.Secondary.IronFOV = 50 -- How much you 'zoom' in. Less is more!
- SWEP.data = {} -- The starting firemode
- SWEP.data.ironsights = 1
- SWEP.IronSightsPos = Vector (4.7715, 0, 2.9797)
- SWEP.IronSightsAng = Vector (-0.6263, 0.0401, 0)
- SWEP.SightsPos = Vector (4.7715, 0, 2.9797)
- SWEP.SightsAng = Vector (-0.6263, 0.0401, 0)
- SWEP.RunSightsPos = Vector (1.6926, 0, 3.6188)
- SWEP.RunSightsAng = Vector (-21.0418, -0.1143, 0)
- easylua.EndWeapon(true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement