Hello! I'm trying to make a "HeadShot" system, and I've a problem.
[video]https://youtu.be/_Cht6FgM-AA[/video]
Help me :)
May we see the code you're using?
[QUOTE=Jompe;52226747]May we see the code you're using?[/QUOTE]
Standart Base.
function GM:ScalePlayerDamage( ply, hitgroup, dmginfo )
-- More damage if we're shot in the head
if ( hitgroup == HITGROUP_HEAD ) then
dmginfo:ScaleDamage( 200 )
end
-- Less damage if we're shot in the arms or legs
if ( hitgroup == HITGROUP_LEFTARM ||
hitgroup == HITGROUP_RIGHTARM ||
hitgroup == HITGROUP_LEFTLEG ||
hitgroup == HITGROUP_RIGHTLEG ||
hitgroup == HITGROUP_GEAR ) then
dmginfo:ScaleDamage( 0.25 )
end
end
You should be using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/ScalePlayerDamage]GM:ScalePlayerDamage[/url] if you aren't already. That gives you the hitgroup, and if it's HITGROUP_HEAD, you can do whatever.
[editline]14th May 2017[/editline]
ninja'd. I guess it's a bug then.
Try to shoot the bot without it carrying a physgun, as your code looks alright.
[QUOTE=Jompe;52226765]Try to shoot the bot without it carrying a physgun, as your code looks alright.[/QUOTE]
With the keys everything works, but if the player holds any weapons, it does not work.
Try using a hook
[CODE]
hook.Add( "ScalePlayerDamage", "HeadShotTest", function( ply, hitgroup, dmginfo )
if hitgroup == HITGROUP_HEAD then
dmginfo:ScaleDamage( 200 )
else
dmginfo:ScaleDamage( 0.25 )
end
end )
[/CODE]
Shorter version:
[CODE]
hook.Add( "ScalePlayerDamage", "HeadShotTest", function( ply, hitgroup, dmginfo )
dmginfo:ScaleDamage( hitgroup == HITGROUP_HEAD and 200 or 0.25 )
end )
[/CODE]
[QUOTE=MPan1;52226799]Try using a hook
[CODE]
hook.Add( "ScalePlayerDamage", "HeadShotTest", function( ply, hitgroup, dmginfo )
if hitgroup == HITGROUP_HEAD then
dmginfo:ScaleDamage( 200 )
else
dmginfo:ScaleDamage( 0.25 )
end
end )
[/CODE][/QUOTE]
When I shoot straight to the head it does not work, but when it is slightly to the left it works.
Strange, it works for me. Try changing the ScaleDamage number to 9999, it should instantly kill (it does for me at least)
[editline]14th May 2017[/editline]
E.G.
[CODE]
hook.Add( "ScalePlayerDamage", "HeadShotTest", function( ply, hitgroup, dmginfo )
dmginfo:ScaleDamage( hitgroup == HITGROUP_HEAD and 99999 or 0.25 )
end )
[/CODE]
[QUOTE=MPan1;52226831]Strange, it works for me. Try changing the ScaleDamage number to 9999, it should instantly kill (it does for me at least)
[editline]14th May 2017[/editline]
E.G.
[CODE]
hook.Add( "ScalePlayerDamage", "HeadShotTest", function( ply, hitgroup, dmginfo )
dmginfo:ScaleDamage( hitgroup == HITGROUP_HEAD and 99999 or 0.25 )
end )
[/CODE][/QUOTE]
[video]https://youtu.be/9z2LQg3Ub_I[/video]
Make sure you're running that serverside (or shared) by the way - if it's clientside it probably won't work
Edit: automerge
Maybe your models are a bit wonky? By default my bots are kleiner, not the citizen model, and it appears your one doesn't even take damage unless you shoot them in the head. I'm clueless at this point - but it works for me. Sorry
What's wrong with hit box...
[editline]14th May 2017[/editline]
[QUOTE=MPan1;52226839]Make sure you're running that serverside (or shared) by the way - if it's clientside it probably won't work[/QUOTE]
Full serverside, I know it.
Try to restart your game as you have overriden the ScalePlayerDamage function and is now using a hook.
[QUOTE=Jompe;52226844]Try to restart your game as you have overriden the ScalePlayerDamage function and is now using a hook.[/QUOTE]
I did.
[editline]14th May 2017[/editline]
[QUOTE=Jompe;52226844]Try to restart your game as you have overriden the ScalePlayerDamage function and is now using a hook.[/QUOTE]
When I shoot not in the head and in the left, it works.
Do as MPan1 said and try to use a different playermodel.
[QUOTE=Jompe;52226858]Do as MPan1 said and try to use a different playermodel.[/QUOTE]
I tryed...
[QUOTE]This is not called for all damage a player receives ( For example fall damage or NPC melee damage ), so you should use GM:EntityTakeDamage instead if you need to detect ALL damage.[/QUOTE]
[URL="https://wiki.garrysmod.com/page/GM/ScalePlayerDamage"]Source: https://wiki.garrysmod.com/page/GM/ScalePlayerDamage[/URL]
Don't know if you should count a bot as a NPC?
[B]EDIT:[/B]
Try to invite your friend to try it on a non-bot.
[QUOTE=Jompe;52226878][URL="https://wiki.garrysmod.com/page/GM/ScalePlayerDamage"]Source: https://wiki.garrysmod.com/page/GM/ScalePlayerDamage[/URL]
Don't know if you should count a bot as a NPC?
[B]EDIT:[/B]
Try to invite your friend to try it on a non-bot.[/QUOTE]
alright, I will..
Try "sv_showlagcompensation 1", that should show you the hitboxes. Another possibility is that the damage is modified in EntityTakeDamage as it first calls ScalePlayerDamage then EntityTakeDamage.
Sorry, you need to Log In to post a reply to this thread.