I have a problem with my lua script for an MTA Server. When I run the code, I get the following error:
attempt to index field '?' (a nil value)
Here's the code:
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
I've been searching for hours, but I can not find where the mistake comes from.