Gmod错误darkrp lua脚本

时间:2013-11-04 00:03:49

标签: lua

我需要有关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行,但ERROR在行中: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

1 个答案:

答案 0 :(得分:3)

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

local DavyCrockettAllowed = GetConVar("DavyCrockettAllowed")
if not (DavyCrockettAllowed and DavyCrockettAllowed:GetBool()) then return end