• Traitor Fire Grenade Help
    1 replies, posted
Hi. I have a LUA script here that is like a incin, but it is suppose to burn bodys after they die. Here is the script: PS. There are no lua errors [CODE]-- common code for all types of grenade if SERVER then AddCSLuaFile( "shared.lua" ) end SWEP.HoldReady = "grenade" SWEP.HoldNormal = "slam" if CLIENT then SWEP.PrintName = "Fire Grenade" SWEP.Instructions = "Burn." SWEP.Slot = 6 SWEP.SlotPos = 0 SWEP.EquipMenuData = { type = "Weapon", desc = "Fire Grenade\nHas the ability to burn bodys.\nDO NOT USE YET BETA WEAPON!!!" }; SWEP.Icon = "VGUI/ttt/icon_nades" end SWEP.CanBuy = {ROLE_TRAITOR} SWEP.Base = "weapon_tttbase" SWEP.Kind = WEAPON_EQUIP1 SWEP.ViewModel = "models/weapons/v_eq_flashbang.mdl" SWEP.WorldModel = "models/weapons/w_eq_flashbang.mdl" SWEP.Weight = 5 SWEP.ViewModelFlip = true SWEP.AutoSwitchFrom = true SWEP.DrawCrosshair = false SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Automatic = false SWEP.Primary.Delay = 1.0 SWEP.Primary.Ammo = "none" SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" SWEP.IsGrenade = true SWEP.NoSights = true SWEP.pin_pulled = false SWEP.throw_time = 0 SWEP.was_thrown = false SWEP.detonate_timer = 5 SWEP.DeploySpeed = 1.5 AccessorFuncDT( SWEP, "pin_pulled", "Pin") AccessorFuncDT( SWEP, "throw_time", "ThrowTime") AccessorFunc(SWEP, "det_time", "DetTime") CreateConVar("ttt_no_nade_throw_during_prep", "0") function SWEP:SetupDataTables() self:DTVar("Bool", 0, "pin_pulled") self:DTVar("Int", 0, "throw_time") end function SWEP:PrimaryAttack() self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) if GetRoundState() == ROUND_PREP and GetConVar("ttt_no_nade_throw_during_prep"):GetBool() then return end self:PullPin() end function SWEP:SecondaryAttack() end function SWEP:PullPin() if self:GetPin() then return end local ply = self.Owner if not IsValid(ply) then return end self.Weapon:SendWeaponAnim(ACT_VM_PULLPIN) if self.SetWeaponHoldType then self:SetWeaponHoldType(self.HoldReady) end self:SetPin(true) self:SetDetTime(CurTime() + self.detonate_timer) end function SWEP:Think() local ply = self.Owner if not IsValid(ply) then return end -- pin pulled and attack loose = throw if self:GetPin() then -- we will throw now if not ply:KeyDown(IN_ATTACK) then self:StartThrow() self:SetPin(false) self.Weapon:SendWeaponAnim(ACT_VM_THROW) if SERVER then self.Owner:SetAnimation( PLAYER_ATTACK1 ) end else -- still cooking it, see if our time is up if SERVER and self:GetDetTime() < CurTime() then self:BlowInFace() end end elseif self:GetThrowTime() > 0 and self:GetThrowTime() < CurTime() then self:Throw() end end function SWEP:BlowInFace() local ply = self.Owner if not IsValid(ply) then return end if self.was_thrown then return end self.was_thrown = true -- drop the grenade so it can immediately explode local ang = ply:GetAngles() local src = ply:GetPos() + (ply:Crouching() and ply:GetViewOffsetDucked() or ply:GetViewOffset()) src = src + (ang:Right() * 10) self:CreateGrenade(src, Angle(0,0,0), Vector(0,0,1), Vector(0,0,1), ply) self:SetThrowTime(0) self:Remove() end function SWEP:StartThrow() self:SetThrowTime(CurTime() + 0.1) end function SWEP:Throw() if CLIENT then self:SetThrowTime(0) elseif SERVER then local ply = self.Owner if not IsValid(ply) then return end if self.was_thrown then return end self.was_thrown = true local ang = ply:EyeAngles() -- don't even know what this bit is for, but SDK has it -- probably to make it throw upward a bit if ang.p < 90 then ang.p = -10 + ang.p * ((90 + 10) / 90) else ang.p = 360 - ang.p ang.p = -10 + ang.p * -((90 + 10) / 90) end local vel = math.min(800, (90 - ang.p) * 6) local vfw = ang:Forward() local vrt = ang:Right() -- local vup = ang:Up() local src = ply:GetPos() + (ply:Crouching() and ply:GetViewOffsetDucked() or ply:GetViewOffset()) src = src + (vfw * 8) + (vrt * 10) local thr = vfw * vel + ply:GetVelocity() self:CreateGrenade(src, Angle(0,0,0), thr, Vector(600, math.random(-1200, 1200), 0), ply) self:SetThrowTime(0) self:Remove() end end -- subclasses must override with their own grenade ent function SWEP:GetGrenadeName() ErrorNoHalt("SWEP BASEGRENADE ERROR: GetGrenadeName not overridden! This is probably wrong!\n") return "ttt_firegrenade_proj" end function SWEP:CreateGrenade(src, ang, vel, angimp, ply) local gren = ents.Create(self:GetGrenadeName()) if not IsValid(gren) then return end gren:SetPos(src) gren:SetAngles(ang) -- gren:SetVelocity(vel) gren:SetOwner(ply) gren:SetThrower(ply) gren:SetGravity(0.4) gren:SetFriction(0.2) gren:SetElasticity(0.45) gren:Spawn() gren:PhysWake() local phys = gren:GetPhysicsObject() if IsValid(phys) then phys:SetVelocity(vel) phys:AddAngleVelocity(angimp) end -- This has to happen AFTER Spawn() calls gren's Initialize() gren:SetDetonateExact(self:GetDetTime()) return gren end function SWEP:PreDrop() -- if owner dies or drops us while the pin has been pulled, create the armed -- grenade anyway if self:GetPin() then self:BlowInFace() end end function SWEP:Deploy() if self.SetWeaponHoldType then self:SetWeaponHoldType(self.HoldNormal) end self:SetThrowTime(0) self:SetPin(false) return true end function SWEP:Holster() if self:GetPin() then return false -- no switching after pulling pin end self:SetThrowTime(0) self:SetPin(false) return true end function SWEP:Reload() return false end function SWEP:Initialize() if self.SetWeaponHoldType then self:SetWeaponHoldType(self.HoldNormal) end self:SetDeploySpeed(self.DeploySpeed) self:SetDetTime(0) self:SetThrowTime(0) self:SetPin(false) self.was_thrown = false end function SWEP:OnRemove() if CLIENT and IsValid(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then RunConsoleCommand("use", "weapon_ttt_unarmed") end end SWEP.Tracer = "AR2Tracer" local function RunIgniteTimer(ent, timer_name) if IsValid(ent) and ent:IsOnFire() then if ent:WaterLevel() > 0 then ent:Extinguish() elseif CurTime() > ent.burn_destroy then ent:SetNotSolid(true) ent:Remove() else -- keep on burning return end end timer.Destroy(timer_name) -- stop running timer end local SendScorches if CLIENT then local function ReceiveScorches(um) local ent = um:ReadEntity() local num = um:ReadChar() for i=1, num do util.PaintDown(um:ReadVector(), "FadingScorch", ent) end if IsValid(ent) then util.PaintDown(ent:LocalToWorld(ent:OBBCenter()), "Scorch", ent) end end usermessage.Hook("flare_scorch", ReceiveScorches) else -- it's sad that decals are so unreliable when drawn serverside, failing to -- draw more often than they work, that I have to do this SendScorches = function(ent, tbl) umsg.Start("flare_scorch") umsg.Entity(ent) umsg.Char(#tbl) for _, p in pairs(tbl) do umsg.Vector(p) end umsg.End() end usermessage.Hook("flare_scorch") -- pools it end local function ScorchUnderRagdoll(ent) if SERVER then local postbl = {} -- small scorches under limbs for i
I think I figured it out. This is the code I think is the probably: [QUOTE]function SWEP:ShootFlare() local cone = self.Primary.Cone local bullet = {} bullet.Num = 1 bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector( cone, cone, 0 ) bullet.Tracer = 1 bullet.Force = 2 bullet.Damage = self.Primary.Damage bullet.TracerName = self.Tracer bullet.Callback = IgniteTarget self.Owner:FireBullets( bullet ) end[/QUOTE] Is there a way to convert it to a grenade script, it a flaregun now.
Sorry, you need to Log In to post a reply to this thread.