This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

HELP

By: a guest on Dec 5th, 2010  |  syntax: None  |  size: 17.11 KB  |  views: 72  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //General Settings \\
  2. SWEP.AdminSpawnable = true                          // Is the swep spawnable for admin
  3. SWEP.ViewModelFOV = 64                              // How much of the weapon do u see ?
  4. SWEP.ViewModel = "models/Weapons/v_smg1_dx7.mdl"      // The viewModel, the model you se when you are holding it-.-
  5. SWEP.WorldModel = "models/Weapons/w_smg1.mdl"     // The worlmodel, The model yu when it's down on the ground
  6. SWEP.AutoSwitchTo = false                           // when someone walks over the swep, chould i automatectly change to your swep ?
  7. SWEP.Slot = 3                                      // Deside wich slot you want your swep do be in 1 2 3 4 5 6
  8. SWEP.HoldType = "smg"                            // How the swep is hold Pistol smg greanade melee
  9. SWEP.PrintName = "AR3 Heavy"                         // your sweps name
  10. SWEP.Author = "floof5467"                            // Your name
  11. SWEP.Spawnable = true                               //  Can everybody spawn this swep ? - If you want only admin keep this false and adminsapwnable true.
  12. SWEP.AutoSwitchFrom = false                         // Does the weapon get changed by other sweps if you pick them up ?
  13. SWEP.FiresUnderwater = true                       // Does your swep fire under water ?
  14. SWEP.Weight = 8                                     // Chose the weight of the Swep
  15. SWEP.DrawCrosshair = true                           // Do you want it to have a crosshair ?
  16. SWEP.Category = "Other"                      // Make your own catogory for the swep
  17. SWEP.SlotPos = 0                                    // Deside wich slot you want your swep do be in 1 2 3 4 5 6
  18. SWEP.DrawAmmo = true                                // Does the ammo show up when you are using it ? True / False
  19. SWEP.ReloadSound = "Weapon_pistol.Reload"           // Reload sound, you can use the default ones, or you can use your one; Example; "sound/myswepreload.waw"
  20. SWEP.Instructions = "AR3"              // How do pepole use your swep ?
  21. SWEP.Contact = "YourMailAdress"                     // How Pepole chould contact you if they find bugs, errors, etc
  22. SWEP.Purpose = "WhatsThePurposeOfThisSwep"          // What is the purpose with this swep ?
  23. SWEP.base = "weapon_base"
  24. //General settings\\
  25.  
  26. //PrimaryFire Settings\\
  27. SWEP.Primary.Sound = "Weapon_SMG1.Single"        // The sound that plays when you shoot :]
  28. SWEP.Primary.Damage = 10                           // How much damage the swep is doing
  29. SWEP.Primary.TakeAmmo = 1                          // How much ammo does it take for each shot ?
  30. SWEP.Primary.ClipSize = 16                         // The clipsize
  31. SWEP.Primary.Ammo = "smg1"                       // ammmo type pistol/ smg1
  32. SWEP.Primary.DefaultClip = 238                      // How much ammo does the swep come with `?
  33. SWEP.Primary.Spread = 0                          //  Does the bullets spread all over, if you want it fire exactly where you are aiming leave it o.1
  34. SWEP.Primary.NumberofShots = 1                     // How many bullets you are firing each shot.
  35. SWEP.Primary.Automatic = true                    // Is the swep automatic ?
  36. SWEP.Primary.Recoil = 5                            //  How much we should punch the view
  37. SWEP.Primary.Delay = 0.1                           // How long time before you can fire again
  38. SWEP.Primary.Force = 50                            // The force of the shot
  39. //PrimaryFire settings\\
  40.  
  41. //Secondary Fire Variables\\
  42. SWEP.Secondary.NumberofShots = 1                  // How many explosions for each shot
  43. SWEP.Secondary.Force = 10                         // Explosions Force
  44. SWEP.Secondary.Spread = 20                      // How much the explosion does spread
  45. SWEP.Secondary.Sound = "Weapon_RPG.Single"        // Fire sound
  46. SWEP.Secondary.DefaultClip = 6                  // How much ammo the secoindary swep comes with
  47. SWEP.Secondary.Automatic = false                  // Is it automactic ?
  48. SWEP.Secondary.Ammo = "Pistol"                    // Leave as Pistol !
  49. SWEP.Secondary.Recoil = 1                         // How uch we should punch the  view
  50. SWEP.Secondary.Delay = 0.2                        //  How long you have to wait before fire a new shot
  51. SWEP.Secondary.TakeAmmo = 1                       // How much ammo Does it take ?
  52. SWEP.Secondary.ClipSize = 16                      // ClipSize
  53. SWEP.Secondary.Damage = 70                        -- The damage the explosion does.
  54. SWEP.Secondary.Magnitude = "175"                  -- How big its the explosion ?
  55. //Secondary Fire Variables\\
  56.  
  57. //SWEP:Initialize()\\
  58. function SWEP:Initialize()
  59.      
  60.     util.PrecacheSound(self.Primary.Sound)
  61.     util.PrecacheSound(self.Secondary.Sound)
  62.          
  63.     self:SetWeaponHoldType( self.HoldType )
  64.     self.Weapon:SetNetworkedBool( "Ironsights", false )
  65.      
  66.     if CLIENT then
  67.         self:CreateModels(SWEP.VElements = {
  68.         ["models/Items/combine_rifle_ammo01.mdl"] = { type = "Model", model = "models/Items/combine_rifle_ammo01.mdl", bone = "ValveBiped", pos = Vector(17.288, 3.062, 5.949), angle = Angle(4.099, 100.681, -82.656), size = Vector(0.5, 0.5, 0.5), color = Color(255, 255, 255, 255), surpresslightning = false, material = ""},
  69.         ["models/Items/BoxFlares.mdl"] = { type = "Model", model = "models/Items/BoxFlares.mdl", bone = "ValveBiped", pos = Vector(17.274, 5.388, 3.898), angle = Angle(-5.819, 12.649, -5.719), size = Vector(0.3, 0.3, 0.3), color = Color(255, 255, 255, 255), surpresslightning = false, material = ""},
  70.         ["models/Gibs/airboat_broken_engine.mdl"] = { type = "Model", model = "models/Gibs/airboat_broken_engine.mdl", bone = "ValveBiped", pos = Vector(17.774, 6.337, 6.313), angle = Angle(-2.095, 9.381, 83.081), size = Vector(0.331, 0.331, 0.331), color = Color(255, 255, 255, 255), surpresslightning = false, material = ""}
  71. }) // create viewmodels
  72.         self:CreateModels(SWEP.WElements = {
  73.         ["models/Items/combine_rifle_ammo01.mdl"] = { type = "Model", model = "models/Items/combine_rifle_ammo01.mdl", pos = Vector(10.607, -0.445, -9.832), angle = Angle(73.938, 9.536, -7.694), size = Vector(0.5, 0.5, 0.5), color = Color(255, 255, 255, 255), surpresslightning = false, material = ""},
  74.         ["models/Gibs/airboat_broken_engine.mdl"] = { type = "Model", model = "models/Gibs/airboat_broken_engine.mdl", pos = Vector(2.444, 1.587, -2.645), angle = Angle(-10.756, -0.219, 9.112), size = Vector(0.5, 0.5, 0.5), color = Color(255, 255, 255, 255), surpresslightning = false, material = ""}
  75. }) // create worldmodels
  76.     end
  77.  
  78. end
  79. //SWEP:Initialize()\\
  80.  
  81. //SWEP:PrimaryFire()\\
  82. function SWEP:PrimaryAttack()
  83.         if ( !self:CanPrimaryAttack() ) then return end
  84.         local bullet = {}
  85.                 bullet.Num = self.Primary.NumberofShots
  86.                 bullet.Src = self.Owner:GetShootPos()
  87.                 bullet.Dir = self.Owner:GetAimVector()
  88.                 bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0)
  89.                 bullet.Tracer = 0
  90.                 bullet.Force = self.Primary.Force
  91.                 bullet.Damage = self.Primary.Damage
  92.                 bullet.AmmoType = self.Primary.Ammo
  93.         local rnda = self.Primary.Recoil * -1
  94.         local rndb = self.Primary.Recoil * math.random(-1, 1)
  95.         self:ShootEffects()
  96.         self.Owner:FireBullets( bullet )
  97.         self.Weapon:EmitSound(Sound(self.Primary.Sound))
  98.         self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) )
  99.         self:TakePrimaryAmmo(self.Primary.TakeAmmo)
  100.         self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  101.         self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
  102. end
  103. //SWEP:PrimaryFire()\\
  104.  
  105. //SWEP:SecondaryFire()\\
  106. function SWEP:SecondaryAttack()
  107.         if ( !self:CanSecondaryAttack() ) then return end
  108.         local rnda = -self.Secondary.Recoil
  109.         local rndb = self.Secondary.Recoil * math.random(-1, 1)
  110.         self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) )
  111.         local eyetrace = self.Owner:GetEyeTrace()
  112.         self.Weapon:EmitSound ( self.Secondary.Sound )
  113.         self:ShootEffects()
  114.         local explode = ents.Create("env_explosion")
  115.         explode:SetPos( eyetrace.HitPos )
  116.         explode:SetOwner( self.Owner )
  117.         explode:Spawn()
  118.         explode:SetKeyValue("iMagnitude","175")
  119.         explode:Fire("Explode", 0, 0 )
  120.         explode:EmitSound("weapon_AWP.Single", 400, 400 )
  121.         self.Weapon:SetNextPrimaryFire( CurTime() + self.Secondary.Delay )
  122.         self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
  123.         self:TakePrimaryAmmo(self.Secondary.TakeAmmo)
  124. end
  125. //SWEP:SecondaryFire()\\
  126.  
  127.  self:SetWeaponHoldType( self.HoldType )
  128.  self.Weapon:SetNetworkedBool( "Ironsights", false )
  129.      
  130.     if CLIENT then
  131.         self:CreateModels(self.VElements) // create viewmodels
  132.         self:CreateModels(self.WElements) // create worldmodels
  133.     end
  134.  
  135. end
  136.  
  137. function SWEP:OnRemove()
  138.      
  139.     if CLIENT then
  140.         self:RemoveModels() // cleanup
  141.     end
  142.      
  143. end
  144.  
  145. if CLIENT then
  146.  
  147.     SWEP.vRenderOrder = nil
  148.     function SWEP:ViewModelDrawn()
  149.          
  150.         local vm = self.Owner:GetViewModel()
  151.         if !ValidEntity(vm) then return end
  152.         if (!self.VElements) then return end
  153.          
  154.         if (!self.vRenderOrder) then
  155.              
  156.             // we build a render order because sprites need to be drawn after models
  157.             self.vRenderOrder = {}
  158.  
  159.             for k, v in pairs( self.VElements ) do
  160.                 if (v.type == "Model") then
  161.                     table.insert(self.vRenderOrder, 1, k)
  162.                 elseif (v.type == "Sprite") then
  163.                     table.insert(self.vRenderOrder, k)
  164.                 end
  165.             end
  166.              
  167.         end
  168.  
  169.         for k, name in ipairs( self.vRenderOrder ) do
  170.          
  171.             local v = self.VElements[name]
  172.             if (!v) then self.vRenderOrder = nil break end
  173.          
  174.             local model = v.modelEnt
  175.             local sprite = v.spriteMaterial
  176.              
  177.             if (!v.bone) then continue end
  178.             local bone = vm:LookupBone(v.bone)
  179.             if (!bone) then continue end
  180.              
  181.             local pos, ang = Vector(0,0,0), Angle(0,0,0)
  182.             local m = vm:GetBoneMatrix(bone)
  183.             if (m) then
  184.                 pos, ang = m:GetTranslation(), m:GetAngle()
  185.             end
  186.              
  187.             if (self.ViewModelFlip) then
  188.                 ang.r = -ang.r // Fixes mirrored models
  189.             end
  190.              
  191.             if (v.type == "Model" and ValidEntity(model)) then
  192.  
  193.                 model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
  194.                 ang:RotateAroundAxis(ang:Up(), v.angle.y)
  195.                 ang:RotateAroundAxis(ang:Right(), v.angle.p)
  196.                 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
  197.  
  198.                 model:SetAngles(ang)
  199.                 model:SetModelScale(v.size)
  200.                  
  201.                 if (v.material == "") then
  202.                     model:SetMaterial("")
  203.                 elseif (model:GetMaterial() != v.material) then
  204.                     model:SetMaterial( v.material )
  205.                 end
  206.                  
  207.                 if (v.surpresslightning) then
  208.                     render.SuppressEngineLighting(true)
  209.                 end
  210.                  
  211.                 render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
  212.                 render.SetBlend(v.color.a/255)
  213.                 model:DrawModel()
  214.                 render.SetBlend(1)
  215.                 render.SetColorModulation(1, 1, 1)
  216.                  
  217.                 if (v.surpresslightning) then
  218.                     render.SuppressEngineLighting(false)
  219.                 end
  220.                  
  221.             elseif (v.type == "Sprite" and sprite) then
  222.                  
  223.                 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
  224.                 render.SetMaterial(sprite)
  225.                 render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
  226.                  
  227.             end
  228.              
  229.         end
  230.          
  231.     end
  232.      
  233.     SWEP.wRenderOrder = nil
  234.     function SWEP:DrawWorldModel()
  235.          
  236.         if (!self.WElements) then return end
  237.          
  238.         if (!self.wRenderOrder) then
  239.  
  240.             self.wRenderOrder = {}
  241.  
  242.             for k, v in pairs( self.WElements ) do
  243.                 if (v.type == "Model") then
  244.                     table.insert(self.wRenderOrder, 1, k)
  245.                 elseif (v.type == "Sprite") then
  246.                     table.insert(self.wRenderOrder, k)
  247.                 end
  248.             end
  249.  
  250.         end
  251.  
  252.         local bone_ent
  253.         local opos, oang = self:GetPos(), self:GetAngles()
  254.          
  255.         self:DrawModel()
  256.         if (ValidEntity(self.Owner)) then
  257.             bone_ent = self.Owner
  258.         else
  259.             // when the weapon is dropped
  260.             bone_ent = self
  261.         end
  262.          
  263.         local bone = bone_ent:LookupBone("ValveBiped.Bip01_R_Hand")
  264.         if (bone) then
  265.             local m = bone_ent:GetBoneMatrix(bone)
  266.             if (m) then
  267.                 opos, oang = m:GetTranslation(), m:GetAngle()
  268.             end
  269.         end
  270.          
  271.         for k, name in pairs( self.wRenderOrder ) do
  272.          
  273.             local v = self.WElements[name]
  274.             if (!v) then self.wRenderOrder = nil break end
  275.          
  276.             local model = v.modelEnt
  277.             local sprite = v.spriteMaterial
  278.  
  279.             local pos, ang = Vector(opos.x, opos.y, opos.z), Angle(oang.p, oang.y, oang.r)
  280.  
  281.             if (v.type == "Model" and ValidEntity(model)) then
  282.  
  283.                 model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
  284.                 ang:RotateAroundAxis(ang:Up(), v.angle.y)
  285.                 ang:RotateAroundAxis(ang:Right(), v.angle.p)
  286.                 ang:RotateAroundAxis(ang:Forward(), v.angle.r)
  287.  
  288.                 model:SetAngles(ang)
  289.                 model:SetModelScale(v.size)
  290.                  
  291.                 if (v.material == "") then
  292.                     model:SetMaterial("")
  293.                 elseif (model:GetMaterial() != v.material) then
  294.                     model:SetMaterial( v.material )
  295.                 end
  296.                  
  297.                 if (v.surpresslightning) then
  298.                     render.SuppressEngineLighting(true)
  299.                 end
  300.                  
  301.                 render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
  302.                 render.SetBlend(v.color.a/255)
  303.                 model:DrawModel()
  304.                 render.SetBlend(1)
  305.                 render.SetColorModulation(1, 1, 1)
  306.                  
  307.                 if (v.surpresslightning) then
  308.                     render.SuppressEngineLighting(false)
  309.                 end
  310.                  
  311.             elseif (v.type == "Sprite" and sprite) then
  312.                  
  313.                 local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
  314.                 render.SetMaterial(sprite)
  315.                 render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
  316.                  
  317.             end
  318.              
  319.         end
  320.          
  321.     end
  322.  
  323.     function SWEP:CreateModels( tab )
  324.      
  325.         if (!tab) then return end
  326.      
  327.         // Create the clientside models here because Garry says we can't do it in the render hook
  328.         for k, v in pairs( tab ) do
  329.             if (v.type == "Model" and v.model and v.model != "" and (!ValidEntity(v.modelEnt) or v.createdModel != v.model) and
  330.                     string.find(v.model, ".mdl") and file.Exists ("../"..v.model) ) then
  331.                  
  332.                 v.modelEnt = ClientsideModel(v.model, RENDER_GROUP_VIEW_MODEL_OPAQUE)
  333.                 if (ValidEntity(v.modelEnt)) then
  334.                     v.modelEnt:SetPos(self:GetPos())
  335.                     v.modelEnt:SetAngles(self:GetAngles())
  336.                     v.modelEnt:SetParent(self)
  337.                     v.modelEnt:SetNoDraw(true)
  338.                     v.createdModel = v.model
  339.                 else
  340.                     v.modelEnt = nil
  341.                 end
  342.                  
  343.             elseif (v.type == "Sprite" and v.sprite and v.sprite != "" and (!v.spriteMaterial or v.createdSprite != v.sprite)
  344.                 and file.Exists ("../materials/"..v.sprite..".vmt")) then
  345.                  
  346.                 local name = v.sprite.."-"
  347.                 local params = { ["$basetexture"] = v.sprite }
  348.                 // make sure we create a unique name based on the selected options
  349.                 local tocheck = { "nocull", "additive", "vertexalpha", "vertexcolor", "ignorez" }
  350.                 for i, j in pairs( tocheck ) do
  351.                     if (v[j]) then
  352.                         params["$"..j] = 1
  353.                         name = name.."1"
  354.                     else
  355.                         name = name.."0"
  356.                     end
  357.                 end
  358.  
  359.                 v.createdSprite = v.sprite
  360.                 v.spriteMaterial = CreateMaterial(name,"UnlitGeneric",params)
  361.                  
  362.             end
  363.         end
  364.          
  365.     end
  366.      
  367.     function SWEP:RemoveModels()
  368.         if (self.VElements) then
  369.             for k, v in pairs( self.VElements ) do
  370.                 if (ValidEntity( v.modelEnt )) then v.modelEnt:Remove() end
  371.             end
  372.         end
  373.         if (self.WElements) then
  374.             for k, v in pairs( self.WElements ) do
  375.                 if (ValidEntity( v.modelEnt )) then v.modelEnt:Remove() end
  376.             end
  377.         end
  378.         self.VElements = nil
  379.         self.WElements = nil
  380.     end
  381.  
  382. end
clone this paste RAW Paste Data