I'm using attacker:Ignite(30) in a script to ignite players who kill an innocent player. It works fine, but the only issue I have is when the attacker dies, if they still have some ignite time left they keep burning even tho they are dead. If they spectate someone, that player takes damage. Anyway I can make the ignite stop when the player dies? Thank you.
[code]
hook.Add("PlayerDeath", "RDM", function(ply, Inflictor, attacker )
if IsValid(attacker) && attacker:IsPlayer() && not attacker:GetMurderer() then
attacker:Ignite(10)
end
end)
[/code]
Instead of using Ignite / Extinguish you could "bleed" them. Here's the Extinguish function, PlayerDeath victim:Extinguish( )
[url]http://wiki.garrysmod.com/page/Entity/Extinguish[/url]
Damage over time: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/takedamageinfo_example.lua.html[/url]
So if the attacker gets ignited and dies and keeps burning, dose he then become a victim? Should I be trying to extinguish the attacker or victim?
I tried using something like [code] if not victim:Alive()
victim:Extinguish() [/code] but i'm probably way wrong right?
[QUOTE=MrTHC;44940058]So if the attacker gets ignited and dies and keeps burning, dose he then become a victim? Should I be trying to extinguish the attacker or victim?
I tried using something like [code] if not victim:Alive()
victim:Extinguish() [/code] but i'm probably way wrong right?[/QUOTE]
No, you want to Extinguish the victim each time. They will be dead on PlayerDeath, no need for a check - you should use IsValid though; you don't need to compare anything else, just use Extinguish on the victim so that they can't burn people by spectating.
The attacker will eventually be a victim; by only extinguishing victim you're guaranteeing they won't be on fire after death.
Hmm, doesn't seem to work. Here's my full code.
[code]
hook.Add("PlayerDeath", "RDM", function(ply, Inflictor, attacker, victim )
if IsValid(attacker) && attacker:IsPlayer() && not attacker:GetMurderer() then
attacker:Ignite(10)
end
if IsValid(victim) then
victim:Extinguish() end
end)
[/code]
Is this right?
Sure, what does GetMurderer do though? Because if an innocent kills a murderer, it'd fire because they would be valid, they would be a player, and they wouldn't be a "murderer"...
Make sure you take care of the other clause where innocents kill the right people OR where the murderer kills the right person.
[QUOTE=Acecool;44940142]Sure, what does GetMurderer do though? Because if an innocent kills a murderer, it'd fire because they would be valid, they would be a player, and they wouldn't be a "murderer"...
Make sure you take care of the other clause where innocents kill the right people OR where the murderer kills the right person.[/QUOTE]
So this should fix that then right?
[code]
hook.Add("PlayerDeath", "RDM", function(ply, Inflictor, attacker, victim )
if IsValid(attacker) && attacker:IsPlayer() && not attacker:GetMurderer() && not victim:GetMurderer() then
attacker:Ignite(10)
end
if IsValid(victim) then
victim:Extinguish() end
end)
[/code]
but even then the victims aren't getting extinguished for some reason with this code.
Do a test SERVER-side;
[lua]concommand.Add( "dev_ignite", function( _p, _cmd, _args )
_p:Ignite( 10 );
end );
concommand.Add( "dev_extinguish", function( _p, _cmd, _args )
_p:Extinguish( );
end );
concommand.Add( "dev_stopignite", function( _p, _cmd, _args )
_p:Ignite( 0.1 );
end );[/lua]
After using the first command, try the second; if it doesn't extinguish you, try the last one to overwrite the time to 0.1 second.
The new logic should be fine if murderers can't teamkill:
I kills I : tttt = teamkill
I kills M: tttf = correct
M kills I: ttft = correct
M kills M: ttff = teamkill
So you may want to change the logic if M can team-kill to accommodate that. For the ignite, try it and see what happens.
Weird. No matter how I'm coding this. I can't get victim to do anything. Players continue to burn after dying.. Eh..
PlayerDeath has three arguments, not four.
[url]http://wiki.garrysmod.com/page/GM/PlayerDeath[/url]
[QUOTE=Jeezy;44941231]PlayerDeath has three arguments, not four.
[url]http://wiki.garrysmod.com/page/GM/PlayerDeath[/url][/QUOTE]
so removing inflictor should fix it then? I didn't think that mattered.
Victim would be a nil value in that case, and I believe the reason you didn't see any errors was because victim was surrounded by the IsValid function.
I didn't even notice; yeah - you have ply where victim should be.
Everything works perfectly now. Thank you for your help guys.
Sorry, you need to Log In to post a reply to this thread.