我的 MTA 服务器的 lua 脚本有问题。当我运行代码时,我收到以下错误:
attempt to index field '?' (a nil value)
这是代码:
addEvent("bank:transfer", true)
addEventHandler("bank:transfer", root, function(id, amount, to, reason)
if(transferBank(id, amount, to, reason)) then
triggerClientEvent(client, "bank:transferRecieve", client, true)
else
triggerClientEvent(client, "bank:transferRecieve", client, false)
end
end)
function transferBank(id, amount, to, reason)
if(id and amount and to and reason) then
if(BANK_ACCOUNTS[to]) then
if(BANK_ACCOUNTS[id].balance >= amount) then
dbExec(connection, "INSERT INTO bank_records (bank_id, record_type, record_from, reason, amount, date) VALUES(?, ?, ?, ?, ?, NOW())", to, 3, id, reason, amount)
dbExec(connection, "UPDATE bank_accounts SET balance = balance - ? WHERE id=?", amount, id)
dbExec(connection, "UPDATE bank_accounts SET balance = balance + ? WHERE id=?", amount, to)
BANK_ACCOUNTS[to].balance = BANK_ACCOUNTS[to].balance + amount
BANK_ACCOUNTS[id].balance = BANK_ACCOUNTS[id].balance - amount
return true
else
return false, "Le Compte Bancaire spécifié ne contient pas assez d'argent."
end
else
return false, "Le Compte Bancaire spécifié n'existe pas."
end
else
return false, "Argument Invalide."
end
end
我一直在寻找几个小时,但我找不到错误来自哪里。