Hi, so I’m trying to make a command that will help our department heads to redistribute rewards to player even if they’re gonna be offline. I tried to fetch the account by first and last names from database and this way to gain identifier which I want to use to assign reward (after next employee spawn, from a different table)
But I ran into a problem and don’t know how to fix it.
/paycheck Test Testys 420420
An error happens for query "SELECT identifier FROM users WHERE firstname = ?, lastname = ? : ["Test","Testys"]": ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' lastname = 'Testys'' at line 1
SCRIPT ERROR: @rewards/server.lua:663: attempt to index a nil value (local 'result')
RegisterCommand("paycheck", function(source, args, rawCommand)
local xPlayer = ESX.GetPlayerFromId(source)
local isBoss = (xPlayer.job.grade_name == 'boss' or xPlayer.job.grade_name == 'chief' or xPlayer.job.grade_name == 'deputy')
local first = args[1]
local second = args[2]
local amount = args[3]
if isBoss then
MySQL.Async.fetchScalar('SELECT identifier FROM users WHERE firstname = @firstname, lastname = @lastname', {
['@firstname'] = first,
['@lastname'] = second
}, function(result)
if result[1] ~= nil then
-- do stuff
end
end)
else
xPlayer.showNotification('Nope')
end
end, false)
Can someone educate me what I did wrong, please? Any advice will be hugely appreciated.