• Martyr DEagle
    2 replies, posted
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! [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[/CODE] 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 [url=http://developer.valvesoftware.com/wiki/Npc_grenade_frag]SDK[/url] 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. [b][url=wiki.garrysmod.com/?title=Entity.Input]Entity.Input [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] So add to the code [lua]ent:Input("SetTimer", self:GetOwner(), self:GetOwner(), 3)[/lua]
[QUOTE=fishface60;19983177]I'd change this bit as a matter of style. RunConsoleCommand("kill") -- to self:GetOwner():Kill() Apart from that you've got to look at the [URL="http://developer.valvesoftware.com/wiki/Npc_grenade_frag"]SDK[/URL] 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. [B][URL="http://wiki.garrysmod.com/?title=Entity.Input"]Entity.Input [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B] So add to the code ent:Input("SetTimer", self:GetOwner(), self:GetOwner(), 3)[/QUOTE] gonna test it now to see if it works :) [editline]03:37PM[/editline] TY, it works :D gonna put it in pack one time with some other sweps i am making
Sorry, you need to Log In to post a reply to this thread.