• Anyway to specify if attacker hits head then
    6 replies, posted
Hey guys, I'm using the hook GM:PlayerHurt and I can't get it so if the player hits the head it will then do something. I'm not using GM:ScalePlayerDamage as it won't work for what I want. Anyway to fix this? [CODE] function GM:PlayerHurt( victim, attacker ) if ( attacker:IsPlayer() ) and ( attacker:HasWeapon("weapon_fists") ) then local pos = victim:GetPos() victim:CreateRagdoll() victim:SetRenderMode(RENDERMODE_TRANSALPHA) victim:SetColor( Color(0, 0, 0, 0 ) ) victim:Freeze( true ) victim:GodEnable() victim:SetCollisionGroup( 20 ) timer.Simple( 2, function() victim:Respawn() victim:SetPos( pos ) SafeRemoveEntity( victim:GetRagdollEntity() ) victim:SetRenderMode( 0 ) victim:SetColor( Color(255, 255, 255, 255) ) victim:Freeze( false ) victim:GodDisable() victim:SetCollisionGroup( 0 ) end ) end end hook.Add( "PlayerHurt", "Knockout", PlayerHurt ) [/CODE] I want it so if the player hits the head the code will then run
[url]http://wiki.garrysmod.com/page/GM/ScalePlayerDamage[/url] [editline]8th November 2015[/editline] I don't know what do you mean that it wouldn't work lol.
Either I'm just stupid or ScalePlayerDamage doesn't work. I put prints in there, etc. and it just isn't working.
It works fine for me. Can you give me the code you are using for your ScalePlayerDamage hook? If it's incorrect like your code you posted there, that may be the problem.
[CODE] function GM:ScalePlayerDamage( ply, hitgroup, dmginfo ) if ( ply:IsPlayer() ) and ( dmginfo:GetAttacker():IsPlayer() ) and ( dmginfo:GetAttacker():HasWeapon("weapon_fists") ) and ( hitgroup == HITGROUP_HEAD ) then local pos = ply:GetPos() ply:CreateRagdoll() ply:SetRenderMode(RENDERMODE_TRANSALPHA) ply:SetColor( Color(0, 0, 0, 0 ) ) ply:Freeze( true ) ply:GodEnable() ply:SetCollisionGroup( 20 ) timer.Simple( 2, function() ply:Respawn() ply:SetPos( pos ) SafeRemoveEntity( ply:GetRagdollEntity() ) ply:SetRenderMode( 0 ) ply:SetColor( Color(255, 255, 255, 255) ) ply:Freeze( false ) ply:GodDisable() ply:SetCollisionGroup( 0 ) end ) end end [/CODE] Sorry for late response family problems.
Make something like this, its a simple example but it will do. [lua] function GM:ScalePlayerDamage( ply, hitgroup, dmginfo ) if ( hitgroup == HITGROUP_HEAD ) then dmginfo:ScaleDamage( 2 ) end if ( hitgroup == HITGROUP_LEFTARM or hitgroup == HITGROUP_RIGHTARM or hitgroup == HITGROUP_LEFTLEG or hitgroup == HITGROUP_RIGHTLEG or hitgroup == HITGROUP_GEAR ) then dmginfo:ScaleDamage( 0.50 ) end if hitgroup == HITGROUP_CHEST then dmginfo:ScaleDamage(1.1) end if hitgroup == HITGROUP_STOMACH then dmginfo:ScaleDamage(1.05) end end [/lua]
[QUOTE=Skere_;49110998]Make something like this, its a simple example but it will do. [lua] function GM:ScalePlayerDamage( ply, hitgroup, dmginfo ) if ( hitgroup == HITGROUP_HEAD ) then dmginfo:ScaleDamage( 2 ) end if ( hitgroup == HITGROUP_LEFTARM or hitgroup == HITGROUP_RIGHTARM or hitgroup == HITGROUP_LEFTLEG or hitgroup == HITGROUP_RIGHTLEG or hitgroup == HITGROUP_GEAR ) then dmginfo:ScaleDamage( 0.50 ) end if hitgroup == HITGROUP_CHEST then dmginfo:ScaleDamage(1.1) end if hitgroup == HITGROUP_STOMACH then dmginfo:ScaleDamage(1.05) end end [/lua][/QUOTE] I know how it works, I'm questioning why it isn't
Sorry, you need to Log In to post a reply to this thread.