• Fire Rocket Command
    13 replies, posted
Is it possible if one of you LUA coders could code me a console command & function? One that creates a rocket entity and fires it towards the direction your looking at. To where I would be able to bind it to a key and use it in my server. Thank you.
Bump
Done. [url]http://www.garrysmod.org/downloads/?a=view&id=100720[/url] Bind "key" "fire_rocket"
Your awesome man. Thanks. [editline]10:55AM[/editline] Is there any way I could change the model into a rocket and add a smoke trail to it? I tried adding a smoke trail and changing the model but now the model just sits there like an idiot. Heres the code, I highlated the parts I modified. [quote]local function FireRocket( player ) if ( !player:IsAdmin() ) then return end local vShootPos = player:GetShootPos() local vShootAng = player:GetAimVector() [b]util.PrecacheModel("models/weapons/w_missle.mdl")[/b] ball = ents.Create( "prop_physics" ) ball:SetPos( vShootPos + Vector(0, 0, 10) ) ball:SetAngles( vShootAng ) [b]ball:SetKeyValue("model", "models/weapons/w_missile.mdl")[/b] ball:SetKeyValue("rendercolor", "131 139 131") ball:Fire("addoutput","exploderadius 280", 0) ball:Fire("addoutput","explodedamage 100", 0) --Change this line to do more damage. 15 is default ball:Fire("physdamagescale","100", 0) ball:Fire("addoutput","onhealthchanged !self,break", 0) ball:SetOwner(player) ball:SetKeyValue("PerformanceMode", 1) ball:Spawn() ball:Activate() local vForce = vShootAng * 100000 local phys = ball:GetPhysicsObject() phys:ApplyForceCenter( vForce ) phys:EnableGravity(false) phys:EnableDrag(false) ball:SetPhysicsAttacker(player) [b]local trail = util.SpriteTrail(ent, 0, Color(205,205,193), false, 15, 1, 4, 1/(15+1)*0.5, "trails/smoke.vmt")[/b][/quote]
Does yours do damage and follow RPGs? I've got one that does the latter, but I can't get it to damage people. [media]http://www.youtube.com/watch?v=RgWSCC-pGsw[/media]
Yes it does damage, no it doesn't follow RPG's. I think the problem is me putting the smoke trail command before I end the function. It being behind all the firing commands. So maybe put it on the top. [editline]11:02AM[/editline] Just watched that video, that is an awesome command. Though not being able to damage people, should be an easy fix.
Uhm, I just create a rocket from the rpg and solve that issue, I just can't get it to have any damage. [lua]function shootRocket(ply) local r = ents.Create("rpg_missile") r:SetPos(ply:GetShootPos() + ply:GetForward() * 10) r:SetAngles(ply:GetAimVector():Normalize():Angle()) r:SetOwner(ply) r:Spawn() r:SetVelocity(r:GetForward() * 7000) end concommand.Add("scoin_firerocket", shootRocket)[/lua]
[code]function shootRocket(ply) local r = ents.Create("rpg_missile") local position = Vector(0,0,0) local damage = 80 local radius = 1024 r:SetPos(ply:GetShootPos() + ply:GetForward() * 10) r:SetAngles(ply:GetAimVector():Normalize():Angle()) r:SetOwner(ply) r:Spawn() r:SetVelocity(r:GetForward() * 7000) util.BlastDamage(0, 0, 0, 1024, 80) end concommand.Add("scoin_firerocket", shootRocket)[/code] Might work. If it doesn't then your back where you started.
Uh, you created 3 local variables that have no purpose what so ever, then you're creating damage at the origin, which I'm not sure would work at all. I can't debug or test anything right now, on a laptop with no wifi.
Ok, well I am not a LUA coder and I have no knowledge of LUA whatsoever. I just got these from the GMOD LUA Wiki. So excuse me if I'm wrong on this.
[QUOTE=santasia;22487413]Your awesome man. Thanks. [editline]10:55AM[/editline] Is there any way I could change the model into a rocket and add a smoke trail to it? I tried adding a smoke trail and changing the model but now the model just sits there like an idiot. Heres the code, I highlated the parts I modified.[/QUOTE] This is probably because the w_missile model may be an effect. I'll try and switch it anyway though. Edit; Didn't work... [editline]05:34PM[/editline] [QUOTE=nicatronTg;22488068]Uhm, I just create a rocket from the rpg and solve that issue, I just can't get it to have any damage. function shootRocket(ply) local r = ents.Create("rpg_missile") r:SetPos(ply:GetShootPos() + ply:GetForward() * 10) r:SetAngles(ply:GetAimVector():Normalize():Angle()) r:SetOwner(ply) r:Spawn() r:SetVelocity(r:GetForward() * 7000) r:Fire("addoutput","onhealthchanged !self,break", 0) end concommand.Add("scoin_firerocket", shootRocket) [/QUOTE] Maybe that? Edit; Nope, didn't work.
Well Fu-, is there no way to change the model? I tried it and when I hit the command it just stood there.
All you kind of just did was create an output that on health changed it should break, which does absolutely nothing. I'll work on this later.
Sorry, you need to Log In to post a reply to this thread.