• How to make Friendly-Fire for DarkRP
    12 replies, posted
Hello guys, I need some help for a gmod server. I have a militaryRP and i would like to make it where like TEAM_FRIEND1, TEAM_FRIEND2 vs TEAM_ENEMY1, TEAM_ENEMY2. I check the other facepunch threads about this but I just don't know where to put the code at. Thank you in advance!
Have a look at the hook [url=http://wiki.garrysmod.com/page/GM/PlayerShouldTakeDamage]PlayerShouldTakeDamage[/url]. Check whether the attacker is one of your allies in there.
[QUOTE=Fruitwesp;52006439]Have a look at the hook [url=http://wiki.garrysmod.com/page/GM/PlayerShouldTakeDamage]PlayerShouldTakeDamage[/url]. Check whether the attacker is one of your allies in there.[/QUOTE] Okay I will check it out.
Couldnt find anything. Anybody else?
Couldn't find anything? It's literally just checking for the player's team and returning the appropriate value. The hook was all you need
function FriendlyFire(ply,attacker) if ply:Team() == attacker:Team() then return false end end hook.Add("PlayerShouldTakeDamage","FriendlyFire",FriendlyFire)
Guessing you have little to no Lua knowledge JcooJ?
[QUOTE=Owjo;52008066]Guessing you have little to no Lua knowledge JcooJ?[/QUOTE] I'm guessing that's why he was asking for help.
[QUOTE=defyReality;52008217]I'm guessing that's why he was asking for help.[/QUOTE] I only ask because providing him with hooks and other resources is useless if he doesn't actually know what they do/are. Your post before mine was posted literally seconds before mine so i didn't see it till after I posted. Something like your first post is what was needed as he probably wouldn't have been able to figure it out without your assistance.
[code] function FriendlyFire(_p,_a) if !_a:IsPlayer() then return true else return !(_p:Team()==_a:Team()) end end hook.Add("PlayerShouldTakeDamage","FriendlyFire",FriendlyFire) [/code] this is what i usually use
[QUOTE=StickmanJohn;52009123][code] function FriendlyFire(_p,_a) if !_a:IsPlayer() then return true else return !(_p:Team()==_a:Team()) end end hook.Add("PlayerShouldTakeDamage","FriendlyFire",FriendlyFire) [/code] this is what i usually use[/QUOTE] What adavantage does using _X as variable names have other than being a pain to read (and confusing to some new coders)?
[QUOTE=JasonMan34;52009752]What adavantage does using _X as variable names have other than being a pain to read (and confusing to some new coders)?[/QUOTE] none iirc
Sorry, you need to Log In to post a reply to this thread.