问题:
当有玩家正在进入服务器时,获取不到xplayer,这个值为nil,尝试添加了if xPlayer then判断后似乎也不能修复该问题
报错:
[script:wasabi_ambula] SCRIPT ERROR: @wasabi_ambulance/server/server.lua:31: attempt to index a nil value (local 'xPlayer')
代码:
sqlSetStatus = function(id, isDead)
local xPlayer = ESX.GetPlayerFromId(id)
if isDead then
isDead = 1
else
isDead = 0
end
MySQL.Async.execute('UPDATE users SET is_dead = @is_dead WHERE identifier = @identifier', {
['@is_dead'] = isDead,
['@identifier'] = xPlayer.identifier
})
end
当有玩家正在进入服务器时,获取不到xplayer,这个值为nil,尝试添加了if xPlayer then判断后似乎也不能修复该问题
报错:
[script:wasabi_ambula] SCRIPT ERROR: @wasabi_ambulance/server/server.lua:31: attempt to index a nil value (local 'xPlayer')
代码:
sqlSetStatus = function(id, isDead)
local xPlayer = ESX.GetPlayerFromId(id)
if isDead then
isDead = 1
else
isDead = 0
end
MySQL.Async.execute('UPDATE users SET is_dead = @is_dead WHERE identifier = @identifier', {
['@is_dead'] = isDead,
['@identifier'] = xPlayer.identifier
})
end