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 [b]Lua[/b] 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 [CODE] tags for Lua code.
[QUOTE=nikorev;47458371]Why don't you detect the entity the bullet/weapon hits, and if it is a strider, then kill it.[/QUOTE]
Can you show me code if you can? Please.
[editline]5th April 2015[/editline]
[QUOTE=r0uge;47458373]I don't see this supposed 5000 damage anywhere. Also, please use [CODE] tags for Lua code.[/QUOTE]
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.
[QUOTE=xgdg;47461278]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.[/QUOTE]
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.
[code]
local dmg = DamageInfo()
dmg:SetDamage(1000)
dmg:SetDamageType(DMG_BLAST)
dmg:SetAttacker(self.Owner)
entity:TakeDamageInfo(dmg)
[/code]
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]
[QUOTE=Maurdekye;47466448]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.[/QUOTE]
[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! :D
[QUOTE=xgdg;47466901]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! :D[/QUOTE]
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...
Remove the code and tell us whether or not you still receive the error. And if you do, please highlight the line that it occurs on.
[editline]6th April 2015[/editline]
Here's some new code in accordance with thegrb93's findings;
[lua]
hook.Add("EntityTakeDamage", "kill_striders", function(hit, dmginfo)
if hit:GetClass() == "npc_strider" and dmginfo:GetInflictor():GetClass() == "weapon_beamthrower" then
hit:Fire("sethealth", "-1", "0")
end
end )
[/lua]
[QUOTE=xgdg;47468503]But i hasn't receive this error before...[/QUOTE]
Well we can't test your code because you haven't posted the whole thing. If It worked on his normal gun then something in the code above is incorrect.
I can give attack function.
Just close your bloody bracket yourself...
[QUOTE=r0uge;47469417]Just close your bloody bracket yourself...[/QUOTE]
I think you're over estimating this guy's knowledge...
Please just post the full SWEP code, no one is going to steal it from you. We really cant help you without it
[QUOTE=AIX-Who;47469851]I think you're over estimating this guy's knowledge...
Please just post the full SWEP code, no one is going to steal it from you. We really cant help you without it[/QUOTE]
Looking at his existing knowledge, I don't think anybody would want to steal it from him anyway.
[QUOTE=Maurdekye;47470248]Looking at your existing knowledge, I don't think anybody would want to steal it from you anyway.[/QUOTE]
Wait what?
I know i'm no professional at scripting however i do know enough to make simple gamemodes etc, If you were talking about the original poster then yeah, sure.
I was talking about xgdg, sorry for any ambiguity.
How this thread continues when the answers been given many times, I don't know.
Sorry, you need to Log In to post a reply to this thread.