Gmod错误 darkrp lua脚本

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

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

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

我的错误消息是:

[ERROR] gamemodes/darkrp/entities/weapons/m9k_davy_crockett/shared.lua:1: attempt to index a nil value

  1. unknown - gamemodes/darkrp/entities/weapons/m9k_davy_crockett/shared.lua:1

这是文件:

我只复制了前10行,但错误在第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
点赞
用户936986
用户936986

GetConVar 明显返回了 nil,而进一步尝试使用 : 进行索引是导致错误的原因。请查看相关文档 - 如果此函数在某些情况下应返回 nil,则必须在尝试索引之前进行检查:

local DavyCrockettAllowed = GetConVar("DavyCrockettAllowed")
如果不是 (DavyCrockettAllowed and DavyCrockettAllowed:GetBool()) 则返回。
2013-11-04 00:41:55