Advertisement
CapsAdmin

Untitled

Mar 11th, 2013
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.35 KB | None | 0 0
  1. easylua.StartWeapon("testpacwep")
  2.  
  3. -- pac
  4. if CLIENT then
  5.  
  6.     -- setup the swep to get all the PAC related functions
  7.     pac.SetupSWEP(SWEP)
  8.    
  9.     -- you can also do this if you want, which is much easier while developing
  10.     -- local pac_session = pac.luadata.ReadFile("pac3/sessions/pac_weapon.txt")
  11.        
  12.     local pac_session = {
  13.         [1] = {
  14.             ["children"] = {
  15.                 [1] = {
  16.                     ["children"] = {
  17.                     },
  18.                     ["self"] = {
  19.                         ["ParentName"] = "firstperon",
  20.                         ["ClassName"] = "model",
  21.                         ["Position"] = Vector(0, -1, 12),
  22.                         ["UniqueID"] = "3451410124",
  23.                         ["Size"] = 0.275,
  24.                         ["Bone"] = "crossbow model crossbow base",
  25.                         ["Name"] = "barrel firstperson",
  26.                         ["ParentUID"] = "3005904956",
  27.                     },
  28.                 },
  29.             },
  30.             ["self"] = {
  31.                 ["EditorExpand"] = true,
  32.                 ["UniqueID"] = "3005904956",
  33.                 ["OwnerName"] = "viewmodel",
  34.                 ["Name"] = "firstperon",
  35.                 ["ClassName"] = "group",
  36.             },
  37.         },
  38.         [2] = {
  39.             ["children"] = {
  40.                 [1] = {
  41.                     ["children"] = {
  42.                     },
  43.                     ["self"] = {
  44.                         ["ParentName"] = "thirdperson",
  45.                         ["ClassName"] = "model",
  46.                         ["Position"] = Vector(10, -0.6, -4),
  47.                         ["UniqueID"] = "508789991",
  48.                         ["Size"] = 0.35,
  49.                         ["Bone"] = "right hand",
  50.                         ["Name"] = "barrel thirdperson",
  51.                         ["ParentUID"] = "2950810582",
  52.                     },
  53.                 },
  54.             },
  55.             ["self"] = {
  56.                 ["EditorExpand"] = true,
  57.                 ["UniqueID"] = "2950810582",
  58.                 ["ClassName"] = "group",
  59.                 ["Name"] = "thirdperson",
  60.                 ["Description"] = "add parts to me!",
  61.             },
  62.         },
  63.     }
  64.    
  65.     -- these two functions are called from server on deploy and holster
  66.     function SWEP:AttachOutfit()
  67.         self:AttachPACPart(pac_session)
  68.        
  69.         self:SetShowPACPartsInEditor(true)
  70.         -- self:SetPACDrawDistance(0) this will turn off the draw distance
  71.     end
  72.    
  73.     function SWEP:RemoveOutfit()
  74.         self:RemovePACPart(pac_session)
  75.     end
  76.        
  77.     -- remove the outfit if the weapon is removed as well
  78.     function SWEP:OnRemove(...)
  79.         self:RemoveOutfit()
  80.         return self.BaseClass.OnRemove(self, ...)
  81.     end
  82.    
  83.     -- pac part manipulation test
  84.     function SWEP:PrimaryAttack(...)
  85.        
  86.         --  find the barrel part
  87.         local tp_barrel = self:FindPACPart(pac_session, "barrel thirdperson")
  88.         local fp_barrel = self:FindPACPart(pac_session, "barrel firstperson")
  89.        
  90.         -- I don't know..
  91.         local i = self:Clip1()
  92.  
  93.         -- these parts might be NULL.
  94.         if tp_barrel:IsValid() then
  95.             tp_barrel:SetPosition(Vector(i, -0.6, -4))
  96.         end
  97.        
  98.         -- Especially the viewmodel. PAC wont create the viewmodel group for those who don't own this weapon.
  99.         if fp_barrel:IsValid() then
  100.             fp_barrel:SetPosition(Vector(i, -1, 12))
  101.            
  102.             if fp_barrel.ClassName == "model" then
  103.                 local params = {}
  104.                     params.Num = 1000 -- admmiinnn
  105.                    
  106.                     -- cached_pos and cached_ang is what the obivous is. it's a cached result of getpos after offset calculations
  107.                     -- i could probably add functions like GetPos and GetAngles for this
  108.                     params.Src = fp_barrel.cached_pos - fp_barrel.cached_ang:Up()*50
  109.                     params.Dir = fp_barrel.cached_ang:Up()
  110.                    
  111.                     params.Spread = Vector(0.1, 0.1, 0)
  112.                     params.Tracer = 5
  113.                     params.TracerName = "Tracer"
  114.                     params.Force = 1
  115.                     params.Damage = 1
  116.                     params.AmmoType = "Pistol"       
  117.                
  118.                 -- make it so the part's model entity fire the bullets for no reason
  119.                 fp_barrel:GetEntity():FireBullets(params)
  120.             end
  121.    
  122.         end
  123.        
  124.         return self.BaseClass.PrimaryAttack(self, ...)
  125.     end
  126.  
  127. end
  128.  
  129. if CLIENT then
  130.     net.Receive(SWEP.ClassName, function()
  131.         local ent = net.ReadEntity()
  132.         local event = net.ReadString()
  133.  
  134.         if ent:IsValid() and ent[event] then
  135.             ent[event](ent)
  136.         end
  137.     end)
  138. end
  139.  
  140. if SERVER then
  141.     util.AddNetworkString(SWEP.ClassName)
  142.  
  143.     function SWEP:Deploy(...)
  144.         net.Start(self.ClassName)
  145.             net.WriteEntity(self)
  146.             net.WriteString("AttachOutfit")
  147.         net.Broadcast()
  148.  
  149.         return self.BaseClass.Deploy(self, ...)
  150.     end
  151.  
  152.     function SWEP:Holster(...)
  153.         net.Start(self.ClassName)
  154.             net.WriteEntity(self)
  155.             net.WriteString("RemoveOutfit")
  156.         net.Broadcast()
  157.        
  158.         return self.BaseClass.Holster(self, ...)
  159.     end
  160.  
  161.     function SWEP:OnDrop(...)
  162.         self:Holster()
  163.         return self.BaseClass.OnDrop(self, ...)
  164.     end
  165.    
  166.     function SWEP:Think(...)
  167.         local owner = self.Owner
  168.        
  169.         if owner:IsValid() and not self.deploy_hack then
  170.             self:Deploy()
  171.             self.deploy_hack = true
  172.         end
  173.        
  174.         return self.BaseClass.Think(self, ...)
  175.     end
  176. end
  177.  
  178. SWEP.PrintName = "pac_weapon" -- 'Nice' Weapon name (Shown on HUD) 
  179. SWEP.Slot = 2 -- Slot in the weapon selection menu
  180. SWEP.SlotPos = 3 -- Position in the slot
  181. SWEP.DrawAmmo = true -- Should draw the default HL2 ammo counter                -- Should draw the default crosshair
  182. SWEP.DrawWeaponInfoBox = true -- Should draw the weapon info box
  183. SWEP.BounceWeaponIcon = true -- Should the weapon icon bounce?
  184.  
  185. -- Variables that are used on both client and server
  186. SWEP.Category = "guns"
  187. SWEP.MuzzleAttachment = "1" -- Should be "1" for CSS models or "muzzle" for hl2 models
  188. SWEP.ShellEjectAttachment = "2" -- Should be "2" for CSS models or "1" for hl2 models
  189. SWEP.DrawCrosshair = false 
  190.  
  191. SWEP.ViewModelFOV = 65
  192. SWEP.ViewModelFlip = true
  193. SWEP.ViewModel = "models/weapons/v_crossbow.mdl"
  194. SWEP.WorldModel = "models/weapons/w_crossbow.mdl"
  195. SWEP.Base = "gdcw_base_pistol"
  196. SWEP.Spawnable = true
  197. SWEP.AdminSpawnable = true
  198.  
  199. SWEP.Primary.Sound = Sound("Weapon_P228.Single")
  200. SWEP.Primary.Round = ("5_7mm")
  201. SWEP.Primary.RPM = 900 -- This is in Rounds Per Minute
  202. SWEP.Primary.ClipSize = 13 -- Size of a clip
  203. SWEP.Primary.DefaultClip = 14
  204. SWEP.Primary.KickUp = 0.4 -- Maximum up recoil (rise)
  205. SWEP.Primary.KickDown = 0.3 -- Maximum down recoil (skeet)
  206. SWEP.Primary.KickHorizontal = 0.3 -- Maximum up recoil (stock)
  207. SWEP.Primary.Automatic = false -- Automatic/Semi Auto
  208. SWEP.Primary.Ammo = "pistol"
  209.  
  210. SWEP.Secondary.ClipSize = 1 -- Size of a clip
  211. SWEP.Secondary.DefaultClip = 1 -- Default number of bullets in a clip
  212. SWEP.Secondary.Automatic = false -- Automatic/Semi Auto
  213. SWEP.Secondary.Ammo = ""
  214. SWEP.Secondary.IronFOV = 50 -- How much you 'zoom' in. Less is more!    
  215.  
  216. SWEP.data = {} -- The starting firemode
  217. SWEP.data.ironsights = 1
  218.  
  219. SWEP.IronSightsPos = Vector (4.7715, 0, 2.9797)
  220. SWEP.IronSightsAng = Vector (-0.6263, 0.0401, 0)
  221. SWEP.SightsPos = Vector (4.7715, 0, 2.9797)
  222. SWEP.SightsAng = Vector (-0.6263, 0.0401, 0)
  223. SWEP.RunSightsPos = Vector (1.6926, 0, 3.6188)
  224. SWEP.RunSightsAng = Vector (-21.0418, -0.1143, 0)
  225.  
  226. easylua.EndWeapon(true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement