I’m trying to make a function that checks whether the identifier is present in the database or not via a command, the problem is that if the result is null (so the identifier is not present in the database) it doesn’t return anything to me. (I am using overexented)
(sorry for my english)
Code:
Server Side
-- FUNCTION THAT CHECK IF THE IDENTIFIER EXIST IN THE DB (WHERE THE PROBLEM SHOW UP)
function checkIdentifier(identifier)
MySQL.query('SELECT * FROM gnc_diamond WHERE identifier = ?', {identifier}, function(result)
if result then
for _, v in pairs(result) do
print(v.identifier)
print("Identifier already exist")
end
else -- THE PROBLEM IS HERE, IF THE IDENTIFIER DOESN'T EXIST IT DOESN'T PRINT ANYTHING
print("The identifier doesn't exist in the db")
-- Insert a new entry in the db
end
end)
end
-- COMMAND
lib.addCommand('group.admin', {'addgem', 'givegem'}, function(source, args)
checkIdentifier(getIdentifier(args.target))
end, {'target:number', 'gem:number'})
-- FUNCTION THAT CHECK THE PLAYER IDENTIFIER
function getIdentifier(source)
local license = GetPlayerIdentifier(source, 1)
local identifier = string.gsub(license, "license", "char1")
return identifier
end