简体   繁体   English

GMod - lua 代码似乎不起作用,但没有显示错误

[英]GMod - lua code doesn't seem to work but displays no errors

Trying to change damage modifier in Garry's Mod with lua, because sk_npc_head doesn't work.尝试使用 lua 更改 Garry's Mod 中的伤害修正,因为 sk_npc_head 不起作用。 Here's the code I'm trying to use in Hammer Editor:这是我试图在 Hammer Editor 中使用的代码:

function FScaleNPCDamage( npc, hitgroup, dmginfo ) if ( hitgroup == HITGROUP_HEAD ) then dmginfo:ScaleDamage( 60 ) end end

Example from the manual :手册中的示例:

 hook.Add( "ScaleNPCDamage", "ScaleNPCDamageExample", function( npc, hitgroup, dmginfo ) dmginfo:ScaleDamage( 2 ) end )

So your code should look something like所以你的代码应该看起来像

hook.Add("ScaleNPCDamage", "YourFancyNPCDamageHook", function (npc, hitgroup, dmginfo)
  if hitgroup == HITGROUP_HEAD then
    dmginfo:ScaleDamage(60)
  end
end)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM