2

我需要关于那个 LUA 文件的帮助,但我没有编辑这个文件,它是一个下载的文件。

ADDON Pack 是 M9K Specialties,适用于 GMOD 服务器。

|------------------------------------------------- -------------------|

我的错误消息是:

[错误] gamemodes/darkrp/entities/weapons/m9k_davy_crockett/shared.lua:1: 尝试索引零值 1。未知 - gamemodes/darkrp/entities/weapons/m9k_davy_crockett/shared.lua:1

这是文件:

我只是复制前 10 行,但错误在 Line: 1

1) if not (GetConVar("DavyCrockettAllowed"):GetBool()) then return end
2) -- Variables that are used on both client and server    
3) SWEP.Gun = ("m9k_davy_crockett") -- must be the name of your swep but NO CAPITALS!    
4) SWEP.Category                = "M9K Specialties"    
5) SWEP.Author              = ""    
6) SWEP.Contact             = ""    
7) SWEP.Purpose             = ""    
8) SWEP.Instructions                = ""
9) SWEP.MuzzleAttachment            = "1"   -- Should be "1" for CSS models or 10) "muzzle" for hl2 models    
10) SWEP.ShellEjectAttachment           = "2"   -- Should be "2" for CSS models or "1" for hl2 models
4

1 回答 1

3

GetConVar显然是在返回nil,并且进一步尝试对其进行索引:是导致错误的原因。查看您的文档 - 如果此函数在某些情况下应该返回nil,那么您需要在尝试对其编制索引之前检查返回:

local DavyCrockettAllowed = GetConVar("DavyCrockettAllowed")
if not (DavyCrockettAllowed and DavyCrockettAllowed:GetBool()) then return end
于 2013-11-04T00:41:55.727 回答