I’m trying to make a watermelon bomb that works just like a frag grenade but I’m having trouble coding the explosion. Here is what I have (for the primary attack part):
function SWEP:PrimaryAttack() //Call the throw attack function, with the watermelon model self:throw_attack("models/props_junk/watermelon01.mdl") local entpos = ent.GetPos(); local explode = ents.Create("env_explosion") explode:SetPos(entpos) explode:SetOwner(self.Owner) explode:Spawn() explode:SetKeyValue("iMagnitude", "220") explode:Fire("Explode", 0, 0) explode:EmitSound("BaseGrenade.Explode", 400, 400) timer.Create("timer1", 2.5, 1, ents.Create("env_explosion")) end
I have a feeling that my problem has to do with finding the physics prop (watermelon) to create the explosion there.
[editline]24th July 2015[/editline]
oh wait nevermind.
I realized I posted this in the wrong place.