How to make SWEP that kills striders instantly?

Hello. I made a bullet shooting SWEP, but it doesn’t kill striders. How to make it killing striders instantly? I made something with dmginfo and it kills striders with 5 shots, but i want to make it killing with ONE shot. Can anyone help? I hope someone understood what i want.

Try Kill(), or SetHealth(0), or Fire(“sethealth”,“0”,0), or if those don’t work, maybe set the damage type of your damage to explosive.

But i want to do this with dmginfo, if you are experienced at LUA you should know what is this. I made damage type “DMG_BLAST” (Explosion damage type) and it affects at striders, but i need five shots to kill it. I made SetDamage to 5, but it still doesn’t work, strider dies after five shots.

I wouldn’t be saying what you should know if you are experienced in Lua if you don’t seem to know what you’re doing yourself.

Obviously 5 damage isn’t enough. Raise the damage.

I made 5000 damage and shit happens.

No one can help you if you don’t show the script you’re using to do this. If you set the damage to 5000 then you should be getting the desired effect.

Alright, i will show it later. Now i can’t.

bullet2.Callback = function(attacker, trace, dmginfo)
local g = math.random( 1, 2 )
if ( g == 1 ) then
dmginfo:SetDamageType(DMG_AIRBOAT)
elseif ( g == 2 ) then
dmginfo:SetDamageType(DMG_BLAST)
dmginfo:SetDamage( 1 )
else
end
end

Code of damage

Why don’t you detect the entity the bullet/weapon hits, and if it is a strider, then kill it.

I don’t see this supposed 5000 damage anywhere. Also, please use


 tags for Lua code.

Can you show me code if you can? Please.

[editline]5th April 2015[/editline]

Alright, i will show it with code next time.

[editline]5th April 2015[/editline]

And note that the weapon destroys Hunter-Chopper with ONLY one shot, with RPG chopper needs to be hit over 50 times, but it doesn’t destroy gunships and striders wih one shot.

I can’t give you the code since I do not have the rights to do so. But I can give you the basics.

GetEyeTrace is huge part of this code. Detect the entity it hits on Primary Fire. Then you need to do an if statement.



local dmg = DamageInfo()

dmg:SetDamage(1000)
dmg:SetDamageType(DMG_BLAST)
dmg:SetAttacker(self.Owner)

entity:TakeDamageInfo(dmg)


Might work. I should hope you know what to do with this.

EDIT:
ahaha no don’t do this I just did and it crashed me.

I don’t think you can directly use Dmginfo to specifically cause striders to die in a single hit. It’s much better listen for when an entity takes damage, test if it’s a strider and if the gun used is your custom swep, and then kill the strider if so.

Perform a trace, set the hit entity’s health to 1 if it’s a strider, then use util.BlastDamage.
Striders do not react to DmgInfo as far as I can tell.

Here, use this code;

[lua]
hook.Add(“EntityTakeDamage”, “kill_striders”, function(hit, dmginfo)
if hit:GetClass() == “npc_strider” and dmginfo:GetInflictor():GetClass() == “custom_swep_name” then
hit:SetHealth(0)
end
end )
[/lua]

Replace “custom_swep_name” with the classname of whatever swep you’re coding.

Just found that SetHealth(0) and SetHealth(-1) and Fire(“sethealth”,“0”,0) don’t work.

Also you have to apply the dmginfo 5 times regardless of damage number and the damage position has to be near the strider. If you don’t specify a position you crash.

You have to do Strider:Fire(“sethealth”,"-1",0)
Makes the strider die epicly.

Thank you all for the code, i will test it.

[editline]6th April 2015[/editline]

[ERROR] addons/beam gun/lua/weapons/weapon_beamthrower/shared.lua:227: ‘)’ expected (to close ‘(’ at line 221) near ‘local’

  1. unknown - addons/beam gun/lua/weapons/weapon_beamthrower/shared.lua:0
    Yay, as always, beautiful ERROR! :smiley:

Fuck me, thats got nothing to do with the above code. You forgot to insert a bracket somewhere near local in your own code, the one above is fine.

But i hasn’t receive this error before…