Hey!
I’m making a command for whitelistening members via an in-game command. The commands and the way they work are taken from whitelistDb script and is being implemented by me into the esx_whitelistEnchanced script. However, that isn’t relevant.
I have checked the query, and it works just fine. The only thing I need to get fixed, is the command. Whenever I write a command, I get “Incorrect identifier!” error, as you can see is a part of the wladd command. So my goal is to write /wladd SteamID64inHex - then the SQL query is being executed with the SteamID. Don’t worry about the query, the error is somewhere in the command input.
TriggerEvent('es:addGroupCommand', 'wladd', "admin", function(source, args, user)
if #args == 2 then
if isWhiteListed(args[2]) then
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, args[2] .. " is already whitelisted!")
else
addWhiteList(args[2])
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, args[2] .. " has been whitelisted!")
end
else
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Incorrect identifier!")
end
end, function(source, args, user)
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!")
end)
function addWhiteList(identifier)
MySQL.Sync.execute("INSERT INTO whitelist (`identifier`) VALUES (@identifier)", {['@identifier'] = identifier})
end
function removeWhiteList(identifier)
MySQL.Sync.execute("DELETE identifier FROM whitelist WHERE identifier = @identifier", {['@identifier'] = identifier})
end
function isWhiteListed(identifier)
local result = MySQL.Sync.fetchScalar("SELECT identifier FROM whitelist WHERE identifier = @identifier", {['@identifier'] = identifier})
if result then
return true
end
return false
end