Martyr DEagle

Hai guise! i am making a swep that if you right click, you die and drop a grenade, i get the drop thing to work but it wont be activated after drop, you need to pick it up with the gravity gun to make it work, HALP ME PL0X! D:

HERE IS TEH CODE!


function SWEP:SecondaryAttack()
 
 local ent = ents.Create ("npc_grenade_frag");
 ent:SetEntity ("npc_grenade_frag");
 
 
 ent:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 16));
 ent:SetAngles (self.Owner:EyeAngles());
 ent:Spawn();
 ent:Activate();
 
 local phys = ent:GetPhysicsObject();
 
 RunConsoleCommand("kill");
 
end

PS: i spelt bad because i wanted to :3

I’d change this bit as a matter of style.
[lua]RunConsoleCommand(“kill”) – to
self:GetOwner():Kill()[/lua]
Apart from that you’ve got to look at the SDK to work out what you need to do to make the grenade live.
From that you should find out that you need to give it the SetTimer input. Now we look at the Gmod Wiki to work out how to send the input. **[Entity.Input

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Entity.Input)**
So add to the code
[lua]ent:Input(“SetTimer”, self:GetOwner(), self:GetOwner(), 3)[/lua]

gonna test it now to see if it works :slight_smile:

[editline]03:37PM[/editline]

TY, it works :smiley: gonna put it in pack one time with some other sweps i am making