• Getting delay to work on trail prop-throwing SWEP
    2 replies, posted
Hello, I have a SWEP that I got off of this thread: [url]http://facepunch.com/showthread.php?t=1295918[/url] and I was confused on how to get the primary fire delay to work. Curently it has no delay at all and I would like to set the delay to 10 seconds per shot. Here Is My Current Code: [CODE]if SERVER then AddCSLuaFile ("shared.lua") SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false elseif CLIENT then SWEP.PrintName = "Donator Trail Gun" SWEP.Slot = 4 SWEP.SlotPos = 1 SWEP.DrawAmmo = false SWEP.DrawCrosshair = true language.Add("Undone_Thrown_SWEP_Entity","Undone Thrown SWEP Entity") end SWEP.Author = "" SWEP.Contact = "" SWEP.Purpose = "Shoot A Can With A Trail" SWEP.Instructions = "Thanks for donating <3" SWEP.Category = "Orange Launcher" SWEP.Spawnable = true -- Whether regular players can see it SWEP.AdminSpawnable = true -- Whether Admins/Super Admins can see it SWEP.ViewModel = "" -- This is the model used for clients to see in first person. SWEP.WorldModel = "" -- This is the model shown to all other clients and in third-person. SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Delay = 99999999 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "none" SWEP.Secondary.ClipSize = 0 SWEP.Secondary.DefaultClip = 0 SWEP.Secondary.Delay = 99999999999 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" local ShootSound = Sound("Metal.SawbladeStick") function SWEP:throw_attack (model_file) local tr = self.Owner:GetEyeTrace() self:EmitSound(ShootSound) self.BaseClass.ShootEffects(self) if (!SERVER) then return end local ent = ents.Create("prop_physics") ent:SetModel(model_file) local trail = util.SpriteTrail(ent, 0, Color(255,93,0), false, 15, 1, 4, 1/(15+1)*0.5, "trails/tube.vmt") ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 1)) ent:SetAngles(self.Owner:EyeAngles()) ent:Spawn() local phys = ent:GetPhysicsObject() if !(phys && IsValid(phys)) then ent:Remove() return end phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() * math.pow(tr.HitPos:Length(), 3)) cleanup.Add(self.Owner, "props", ent) undo.Create ("Thrown_SWEP_Entity") undo.AddEntity (ent) undo.SetPlayer (self.Owner) undo.Finish() end function SWEP:PrimaryAttack() self:throw_attack("models/props_junk/GlassBottle01a.mdl") end function SWEP:SecondaryAttack() end[/CODE] Any help would be appreciated.
[LUA] if SERVER then AddCSLuaFile ("shared.lua") SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false elseif CLIENT then SWEP.PrintName = "Donator Trail Gun" SWEP.Slot = 4 SWEP.SlotPos = 1 SWEP.DrawAmmo = false SWEP.DrawCrosshair = true language.Add("Undone_Thrown_SWEP_Entity","Undone Thrown SWEP Entity") end SWEP.Author = "" SWEP.Contact = "" SWEP.Purpose = "Shoot A Can With A Trail" SWEP.Instructions = "Thanks for donating <3" SWEP.Category = "Orange Launcher" SWEP.Spawnable = true -- Whether regular players can see it SWEP.AdminSpawnable = true -- Whether Admins/Super Admins can see it SWEP.ViewModel = "" -- This is the model used for clients to see in first person. SWEP.WorldModel = "" -- This is the model shown to all other clients and in third-person. SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Delay = 10 -- changed here SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "none" SWEP.Secondary.ClipSize = 0 SWEP.Secondary.DefaultClip = 0 SWEP.Secondary.Delay = 99999999999 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" local ShootSound = Sound("Metal.SawbladeStick") function SWEP:throw_attack (model_file) local tr = self.Owner:GetEyeTrace() self:EmitSound(ShootSound) self.BaseClass.ShootEffects(self) if (!SERVER) then return end local ent = ents.Create("prop_physics") ent:SetModel(model_file) local trail = util.SpriteTrail(ent, 0, Color(255,93,0), false, 15, 1, 4, 1/(15+1)*0.5, "trails/tube.vmt") ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 1)) ent:SetAngles(self.Owner:EyeAngles()) ent:Spawn() local phys = ent:GetPhysicsObject() if !(phys && IsValid(phys)) then ent:Remove() return end phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() * math.pow(tr.HitPos:Length(), 3)) cleanup.Add(self.Owner, "props", ent) undo.Create ("Thrown_SWEP_Entity") undo.AddEntity (ent) undo.SetPlayer (self.Owner) undo.Finish() end function SWEP:PrimaryAttack() self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay ); -- delay self:throw_attack("models/props_junk/GlassBottle01a.mdl") end function SWEP:SecondaryAttack() end [/LUA] added one line in SWEP:PrimaryAttack() and changed SWEP.Primary.Delay.
[QUOTE=Busan1;42772384][LUA] if SERVER then AddCSLuaFile ("shared.lua") SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false elseif CLIENT then SWEP.PrintName = "Donator Trail Gun" SWEP.Slot = 4 SWEP.SlotPos = 1 SWEP.DrawAmmo = false SWEP.DrawCrosshair = true language.Add("Undone_Thrown_SWEP_Entity","Undone Thrown SWEP Entity") end SWEP.Author = "" SWEP.Contact = "" SWEP.Purpose = "Shoot A Can With A Trail" SWEP.Instructions = "Thanks for donating <3" SWEP.Category = "Orange Launcher" SWEP.Spawnable = true -- Whether regular players can see it SWEP.AdminSpawnable = true -- Whether Admins/Super Admins can see it SWEP.ViewModel = "" -- This is the model used for clients to see in first person. SWEP.WorldModel = "" -- This is the model shown to all other clients and in third-person. SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Delay = 10 -- changed here SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "none" SWEP.Secondary.ClipSize = 0 SWEP.Secondary.DefaultClip = 0 SWEP.Secondary.Delay = 99999999999 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" local ShootSound = Sound("Metal.SawbladeStick") function SWEP:throw_attack (model_file) local tr = self.Owner:GetEyeTrace() self:EmitSound(ShootSound) self.BaseClass.ShootEffects(self) if (!SERVER) then return end local ent = ents.Create("prop_physics") ent:SetModel(model_file) local trail = util.SpriteTrail(ent, 0, Color(255,93,0), false, 15, 1, 4, 1/(15+1)*0.5, "trails/tube.vmt") ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 1)) ent:SetAngles(self.Owner:EyeAngles()) ent:Spawn() local phys = ent:GetPhysicsObject() if !(phys && IsValid(phys)) then ent:Remove() return end phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() * math.pow(tr.HitPos:Length(), 3)) cleanup.Add(self.Owner, "props", ent) undo.Create ("Thrown_SWEP_Entity") undo.AddEntity (ent) undo.SetPlayer (self.Owner) undo.Finish() end function SWEP:PrimaryAttack() self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay ); -- delay self:throw_attack("models/props_junk/GlassBottle01a.mdl") end function SWEP:SecondaryAttack() end [/LUA] added one line in SWEP:PrimaryAttack() and changed SWEP.Primary.Delay.[/QUOTE] Thanks Alot! It works perfectly.
Sorry, you need to Log In to post a reply to this thread.