尝试在FiveM essentialmode上对一个空值(字段'?')进行索引
我在代码的某个部分遇到了问题,我不是程序员,我在互联网上查找过,但没有找到任何能够帮助我的问题。该问题出现在第234行,即if groups[Users[source].getGroup()]:canTarget(group) then我不知道该怎么办,这是错误
Error running call reference function for resource essentialmode: citizen:/scripting/lua/scheduler.lua:351: server/main.lua:234: attempt to index a nil value (field '?') stack traceback: server/main.lua:234: in upvalue 'ref' citizen:/scripting/lua/scheduler.lua:337: in function citizen:/scripting/lua/scheduler.lua:336 [C]: in function 'xpcall' citizen:/scripting/lua/scheduler.lua:336: in function citizen:/scripcfx ting/lua/scheduler.lua:335> stack traceback: [C]: in function 'error' citizen:/scripting/lua/scheduler.lua:351: in function citizen:/scripting/lua/scheduler.lua:322
function addGroupCommand(command, group, callback, callbackfailed, suggestion)
commands[command] = {}
commands[command].perm = math.maxinteger
commands[command].group = group
commands[command].cmd = callback
commands[command].callbackfailed = callbackfailed
if suggestion then
if not suggestion.params or not type(suggestion.params) == "table" then suggestion.params = {} end
if not suggestion.help or not type(suggestion.help) == "string" then suggestion.help = "" end
commandSuggestions[command] = suggestion
end
ExecuteCommand('add_ace group.' .. group .. ' command.' .. command .. ' allow')
RegisterCommand(command, function(source, args)
if groups[Users[source].getGroup()]:canTarget(group) then
callback(source, args, Users[source])
else
callbackfailed(source, args, Users[source])
end
end)
debugMsg("Group command added: " .. command .. ", requires group: " .. group) end
有点晚了,但为了后来者的参考:
当日志中出现像这样的错误时:
citizen:/scripting/lua/scheduler.lua:351: server/main.lua:234: attempt to index a nil value (field '?')`
往往是由于从数据库中获取的数据为空。
例如,
Error running call reference function for resource esx_identity: citizen:/scripting/lua/scheduler.lua:405: @esx_identity/server/main.lua:11: attempt to index a nil value (field '?')
stack traceback:
@esx_identity/server/main.lua:11: in upvalue 'ref'
esx_identity/server/main.lua中的第11行是:
if result[1].firstname ~= nil then
“firstname”引用的是从数据库返回的空值。SQL查询通常非常接近代码的问题行。
检查数据库中是否有包含空值的行,并删除或修复任何存在的行。
- Lua 虚拟机加密load(string.dump(function)) 后执行失败问题如何解决
- 我想创建一个 Nginx 规则,禁止访问
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?

Lua 只接受从 1 开始的索引,而当索引是 0 时通常会出现错误。因此,您可以检查
source或Users[source].getGroup()是否可能等于 0,以确保它们始终>= 1。