Advertisement
Guest User

HELP

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