[Help] Jihad's / Explosions do not damage T's! [GMod] [TTT]

Hi, I was wondering if anyone could help me figure out why T’s do not die from Jihad’s / Explosions in TTT?, For ex: if the Jihad were to be used by a traitor it would kill everyone around his/her radius but it wouldn’t do a single damage to the person who triggered the Jihad? I previously posted on here requesting assistance on how to make it so T and D buddy’s don’t damage each other, and it was successful, I got the code I needed, and implemented it on the server and it worked great, but it had a flaw, and that flaw is what I am trying to fix/solve (Explosion’s when triggered by T’s do not damage himself)

Here is the lua code I used:


hook.Add("EntityTakeDamage", "No T or D buddy damage", function(ply, dmginfo)
	if ply:IsPlayer() and (ply:GetRole() == ROLE_TRAITOR or ply:GetRole() == ROLE_DETECTIVE) and IsValid(dmginfo:GetAttacker()) and dmginfo:GetAttacker():IsPlayer() and ply:GetRole() == dmginfo:GetAttacker():GetRole() then
		dmginfo:ScaleDamage(0)
	end
end)

If anyone could read this and make an edit to the code so that Jihad’s and C4’s or any type of explosion will damage the Traitor if he or she triggered it?

Thanks in advance! C:

                                                       - smexy

P.S. I suck at coding, so a copy n paste of the new edit would be fantastic! :smiley: Thank you so much for your help.


hook.Add("EntityTakeDamage", "No T or D buddy damage", function(ply, dmginfo)
    if ply:IsPlayer() and (ply:GetRole() == ROLE_TRAITOR or ply:GetRole() == ROLE_DETECTIVE) and IsValid(dmginfo:GetAttacker()) and dmginfo:GetAttacker():IsPlayer() and ply:GetRole() == dmginfo:GetAttacker():GetRole() then
          if not (ply == dmginfo:GetAttacker()) then
		dmginfo:ScaleDamage(0)
           end
    end
end)

I wouldn’t ask for spoonfed code too often.

use the DMG Enums and check if the dmginfo’s type is explosion damage and the attackers role is the same as the victims role
Example:

[lua]
if ( dmginfo:IsDamageType( DMG_BLAST ) and dmginfo:GetAttacker():GetRole() == ply:GetRole() ) then return true end[/lua]

If you’re unable to add that to your code then you should learn how to code instead of asking everything to be done for you
ps: copy and paste won’t work very well

Don’t know why people even bother giving code to people, they aren’t even real “developers” if they are just buying scriptfodder scripts and given code on facepunch to “make their server”.

Everyone starts somewhere.

That is true, and I know I sound harsh, but there is literally 0 effort coming out of this guy to learn anything.

“Why would I waste my time learning to code when these dopes will do it all for me mwahahahaha” -OP

If you think writing a script to block damage is as complicated as it gets you’ve thought completely wrong.

I didn’t say that, personally I find networking the hardest thing but that’s mostly just lack of experience with it. Having said that posting to a forum asking for help is literally the last thing I do, I hate doing it.

Yeah I know it wasn’t you saying it.