意外的符号 )

在第10行意外的符号 ')'

我刚刚开始学习编程,并且已经跟随了“LUA教程10b”中的一切。

hook.Add( "PlayerSay", "CommandIdent", function( ply, text, team )
  if( text == "!hurt" ) then
    ply:SetHealth( ply:Health() - 25 )
    if( ply:Health() <= 0 ) then
      ply:Kill()
    end
    return "OUCH!"
  end

  if( string.sub( text, 1, 4, ) == "/ooc" ) then
    return "[OOC]" .. string.sub( text, 5 )
  end

end )

脚本应该在用户在游戏中输入“/ooc (message)”时将其翻译为“[OOC] (message)”.

点赞
用户2725326
用户2725326

根据评论中@char的说法,你在第10行中有一个额外的逗号

if( string.sub( text, 1, 4, ) == "/ooc" ) then

应该是

if( string.sub( text, 1, 4 ) == "/ooc" ) then\

lua wiki所述。

2019-10-25 16:48:26