Jump to content

[AJUDA] Por favor estou com erro no meu painel vip


Recommended Posts

Na hora que clico no Vip para comprar da esse erro no debugscript 3 Linha 183:
Bad Argument @ 'aclGroupAddObject' [expected acl-group at argument 1, got boolean]

vehicle = {}
delay = {}
delay['Skin'] = {}
delay['Arma'] = {}
delay['Veiculo'] = {}
delay['Vida'] = {}
delay['Colete'] = {}
delay['Inventario'] = {}

function getVipPlayer (player)
    local vips = {}
    for i, v in pairs(config.vips) do
        if aclGetGroup(i) and  isObjectInACLGroup('user.'..getAccountName(getPlayerAccount(player)), aclGetGroup(i)) then
            vips[i] = true
        end
    end
    return vips
end

connection = dbConnect('sqlite', 'assets/dados/sqlite.db')
dbExec(connection, 'CREATE TABLE IF NOT EXISTS DelayActions (Action, Account, Timer)')
dbExec(connection, 'CREATE TABLE IF NOT EXISTS EstoqueShopCoins (Nome, Quantidade)')
dbExec(connection, 'CREATE TABLE IF NOT EXISTS Vip (User, Type, Dias, DateAtivation, DateVencimento)')
dbExec(connection, 'CREATE TABLE IF NOT EXISTS Armas (User, Nome, Arma, Skin)')
dbExec(connection, 'CREATE TABLE IF NOT EXISTS Equipe (User, Nome, Arma, Skin)')

for i, v in pairs(config.loja) do
    for index, value in ipairs(v.products) do
        if tonumber(value.estoque) then
            if #dbPoll(dbQuery(connection, 'SELECT * FROM EstoqueShopCoins WHERE Nome = ?', value.nome), - 1) == 0 then
                dbExec(connection, 'INSERT INTO EstoqueShopCoins (Nome, Quantidade) VALUES(?, ?)', value.nome, value.estoque)
            end
        end
    end
end

function getEstoque (nome)
    local result = dbPoll(dbQuery(connection, 'SELECT * FROM EstoqueShopCoins WHERE Nome = ?', nome), - 1)
    if #result ~= 0 then
        local quantidade = result[1]['Quantidade']
        if tonumber(quantidade) > 0 then
            return true, quantidade
        end
    end
    return false
end

function diminuirEstoque (nome)
    local result = dbPoll(dbQuery(connection, 'SELECT * FROM EstoqueShopCoins WHERE Nome = ?', nome), - 1)
    if #result ~= 0 then
        local quantidade = result[1]['Quantidade']
        if tonumber(quantidade) > 0 then
            dbExec(connection, 'UPDATE EstoqueShopCoins SET Quantidade = ? WHERE Nome = ?', quantidade - 1, nome)
            return true
        end
    end
    return false
end

function isArmaPlayer (player, arma)
    local result = dbPoll(dbQuery(connection, 'SELECT * FROM Armas WHERE User = ?', getAccountName(getPlayerAccount(player))), - 1)
    if (#result ~= 0) then
        for i, v in ipairs(result) do
            if v['Skin'] == arma then
                return true
            end
        end
    end
    return false
end

function getPlayerByLogin (login)
    for _, player in ipairs(getElementsByType('player')) do
        if getAccountName(getPlayerAccount(player)) == tostring(login) then
            return player
        end
    end
    return false
end

addEvent('equipeWeaponShader', true)
addEventHandler('equipeWeaponShader', root, function (item)
    if item and type(item) == 'table' then
        local shader = config.weapons_shader[item.nome].shader
        local texture = config.weapons_shader[item.nome].texture
        if isArmaPlayer(source, shader) then
            if (getPedWeapon(source) == config.weapons_shader[item.nome].weapon) then
                if item.action == 'Equipar' then
                    if (#dbPoll(dbQuery(connection, 'SELECT * FROM Equipe WHERE User = ? AND Skin = ?', getAccountName(getPlayerAccount(source)), shader), - 1) ~= 0) then
                        dbExec(connection, 'DELETE FROM Equipe WHERE User = ? AND Skin = ?', getAccountName(getPlayerAccount(source)), shader)
                    end
                    dbExec(connection, 'INSERT INTO Equipe (User, Nome, Arma, Skin) VALUES(?, ?, ?, ?)', getAccountName(getPlayerAccount(source)), item.nome, string.upper(texture), shader)
                    triggerClientEvent(root, 'setArmaSticker', root, source, texture, shader)
                    config.notify(source, 'success', 'Você equipou a arma com sucesso.')
                elseif item.action == 'Desequipar' then
                    triggerClientEvent(root, 'removerArmaSticker', root, source)
                    local result = dbPoll(dbQuery(connection, 'SELECT * FROM Equipe WHERE User = ?', getAccountName(getPlayerAccount(source))), - 1)
                    if (#result ~= 0) then
                        for i, v in ipairs(result) do
                            dbExec(connection, 'DELETE FROM Equipe WHERE User = ? AND Arma = ?', getAccountName(getPlayerAccount(source)), v['Arma'])
                        end
                    end
                    config.notify(source, 'success', 'Você desequipou a arma com sucesso.')
                end
                triggerClientEvent(source, 'updateArmas', source, dbPoll(dbQuery(connection, 'SELECT * FROM Armas WHERE User = ?', getAccountName(getPlayerAccount(source))) , - 1),  dbPoll(dbQuery(connection, 'SELECT * FROM Equipe WHERE User = ?', getAccountName(getPlayerAccount(source))) , - 1))
            else
                config.notify(source, 'error', 'Equipe a arma para '..(item.action == 'Desequipar' and 'des' or '')..'equipar esta skin de arma.')
            end
        else
            config.notify(source, 'error', 'Você não possui essa skin de arma.')
        end
    end
end)

addEventHandler('onPlayerLogin', root, function (_, acc)
    local result = dbPoll(dbQuery(connection, 'SELECT * FROM Equipe WHERE User = ?', getAccountName(acc)), - 1)
    if (#result ~= 0) then
        for i, v in ipairs(result) do
            local shader = config.weapons_shader[v['Nome']].shader
            local texture = config.weapons_shader[v['Nome']].texture
            triggerClientEvent(root, 'setArmaSticker', root, source, texture, shader)
        end
    end
    local resultDados = dbPoll(dbQuery(connection, 'SELECT * FROM Equipe'), - 1)
    if (#resultDados ~= 0) then
        for i, v in ipairs(resultDados) do
            local player = getPlayerByLogin(v['User'])
            if isElement(player) then
                local shader = config.weapons_shader[v['Nome']].shader
                local texture = config.weapons_shader[v['Nome']].texture
                triggerClientEvent(source, 'setArmaSticker', source, player, texture, shader)
            end
        end
    end
end)

setTimer(function()
    for i, v in ipairs(dbPoll(dbQuery(connection, 'SELECT * FROM Vip'), - 1)) do
        if (v['Dias'] ~= 'Permanente') then
            if ((tonumber(v['Dias'])-15000) < 0) then
                aclGroupRemoveObject(aclGetGroup(v['Type']), 'user.'..v['User'])
                dbExec(connection, 'DELETE FROM Vip WHERE User = ? AND Type = ?', v['User'], v['Type'])
                local player = getPlayerByLogin(v['User'])
                if isElement(player) then
                    config.notify(player, 'info', 'A Pulseira '..v['Type']..' acabou de ser removido pois o tempo acabou.')
                end
            else
                dbExec(connection, 'UPDATE Vip SET Dias = ? WHERE User = ? AND Type = ?', (tonumber(v['Dias']) - 15000), v['User'], v['Type'])
            end
        end
    end
end, 15000, 0)

addEvent('buyItemCoin', true)
addEventHandler('buyItemCoin', root, function (item)
    if item and type(item) == 'table' then
        local coins = getElementData(source, config.datacoin) or 0
        if (item.loja == 'Skins de Armas') then
            local shader = config.weapons_shader[item.nome].shader
            if not isArmaPlayer(source, shader) then
                local texture = config.weapons_shader[item.nome].texture
                if shader and texture then
                    if coins >= tonumber(item.price) then
                        dbExec(connection, 'INSERT INTO Armas (User, Nome, Arma, Skin) values(?, ?, ?, ?)', getAccountName(getPlayerAccount(source)), item.nome, string.upper(texture), shader)
                        setElementData(source, config.datacoin, coins - item.price)
                        config.notify(source, 'success', 'Você comprou uma skin de arma.')
                        triggerClientEvent(source, 'updateArmas', source, dbPoll(dbQuery(connection, 'SELECT * FROM Armas WHERE User = ?', getAccountName(getPlayerAccount(source))) , - 1),  dbPoll(dbQuery(connection, 'SELECT * FROM Equipe WHERE User = ?', getAccountName(getPlayerAccount(source))) , - 1))
                    else
                        return config.notify(source, 'error', 'Você não possui Acoins suficiente.')
                    end
                else
                    return config.notify(source, 'error', 'Ocorreu um erro ao comprar a skin de arma.')
                end
            else
                return config.notify(source, 'error', 'Você já possui esta skin de armas.')
            end
        elseif (item.loja == 'Vips') then
            if #dbPoll(dbQuery(connection, 'SELECT * FROM Vip WHERE User = ? AND Type = ?', getAccountName(getPlayerAccount(source)), item.informations.vip), - 1) == 0 then
                if coins >= tonumber(item.price) then
                    setElementData(source, config.datacoin, coins - item.price)
                    config.notify(source, 'success', 'Você assinou VIP '..item.nome..', obrigado pelo apoio! ❤️')
                    dbExec(connection, 'INSERT INTO Vip (User, Type, Dias, DateAtivation, DateVencimento) Values(?, ?, ?, ?, ?)', getAccountName(getPlayerAccount(source)), item.informations.vip, (item.informations.dias == 'Permanente' and 'Permanente' or (item.informations.dias * 86400000)), getDate('hoje'), getDate('vencimento', item.informations.dias))
                    aclGroupAddObject(aclGetGroup(item.informations.vip), 'user.'..getAccountName(getPlayerAccount(source)))
                    givePlayerMoney(source, tonumber(item.informations.ativation_money))
                    config.notify(root, string.gsub(string.gsub(getPlayerName(source), '#%x%x%x%x%x%x', ''), '_', ' ')..' assinou o plano '..item.nome..' com sucesso!', 'info')
                    triggerClientEvent(source, 'updateVips', source, getVipPlayer(source), dbPoll(dbQuery(connection, 'SELECT * FROM Vip WHERE User = ?', getAccountName(getPlayerAccount(source))) , - 1))
                else
                    return config.notify(source, 'error', 'Você não possui ACoins suficiente.')
                end
            else
                return config.notify(source, 'error', 'Você já possui um VIP '..item.informations.vip..' ativado, aguarde o vencimento para poder comprar outro.')
            end
        elseif (item.loja == 'Passaporte') then
            if coins >= tonumber(item.price) then
                if tonumber(item.estoque) then
                    if getEstoque(item.nome) then
                        if diminuirEstoque(item.nome) then
                            setElementData(source, config.datacoin, coins - item.price)
                            config.notify(source, 'error', 'Você comprou o ID '..item.id..'.')
                            triggerEvent('buyId', source, getElementData(source, 'ID'), item.id)
                        else
                            return config.notify(source, 'error', 'Ocorreu um erro ao diminuir o estoque do item.')
                        end
                    else
                        return config.notify(source, 'warning', 'Acabou o estoque desse item.')
                    end
                end
            else
                return config.notify(source, 'error', 'Você não possui ACoins suficiente.')
            end
        elseif (item.loja == 'Mascaras') then
            if coins >= tonumber(item.price) then
				local inv = config.inventario.nome
				local giveInv = config.inventario.giveItem
                setElementData(source, config.datacoin, coins - item.price)
                exports.CzInventory:sendItem(source, item.informations.id, 1)
                config.notify(source, 'success', 'Você comprou um(a) '..item.nome..'')
            end
        end
    end
end)

monthdays = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
function getDate (action, dias)
    time = getRealTime()
    local day = time.monthday
    local month = time.month + 1
    local year = time.year + 1900
    if action == 'hoje' then
        local day = tonumber(day) < 10 and '0'..day or day
        local month = tonumber(month) < 10 and '0'..month or month
        return day..'/'..month..'/'..year
    else
        if dias == 'Permanente' then
            return 'Permanente'
        else
            if (day+dias) > monthdays[month] then
                day = day+dias
                day = day-monthdays[month]
                if month < 12 then
                    month = month + 1
                else
                    month = 1
                    year = year + 1
                end
            else
                day = day + dias
            end
            local day = tonumber(day) < 10 and '0'..day or day
            local month = tonumber(month) < 10 and '0'..month or month
            return day..'/'..month..'/'..year
        end
    end
end

for i,v in ipairs(dbPoll(dbQuery(connection, 'SELECT * FROM DelayActions'), - 1)) do
    if delay[v['Action']] then
        delay[v['Action']][v['Account']] = setTimer(function() end, tonumber(v['Timer']), 1)
        dbExec(connection, 'DELETE FROM DelayActions WHERE Action = ? AND Account = ?', v['Action'], v['Account'])
    end
end

addEventHandler('onResourceStop', resourceRoot, function()
    for i, _ in pairs(delay) do
        for user, timer in pairs(delay[i]) do
            if isTimer(timer) then
                local remaining, _, _ = getTimerDetails(timer) 
                dbExec(connection, 'INSERT INTO DelayActions (Action, Account, Timer) VALUES(?, ?, ?)', i, user, remaining)
            end
        end
    end
end)

addEventHandler('onResourceStart', resourceRoot, function ()
    for i, v in ipairs(getElementsByType('player')) do
        if not isGuestAccount(getPlayerAccount(v)) then
            bindKey(v, config.panel.key, config.panel.state, function (player)
                local armas = dbPoll(dbQuery(connection, 'SELECT * FROM Armas WHERE User = ?', getAccountName(getPlayerAccount(player))) , - 1)
                local armasequipadas = dbPoll(dbQuery(connection, 'SELECT * FROM Equipe WHERE User = ?', getAccountName(getPlayerAccount(player))) , - 1)
                local vencimentos = dbPoll(dbQuery(connection, 'SELECT * FROM Vip WHERE User = ?', getAccountName(getPlayerAccount(player))) , - 1)
                local estoque = dbPoll(dbQuery(connection, 'SELECT * FROM EstoqueShopCoins'), - 1)
                triggerClientEvent(player, 'onPanelDraw', player, getVipPlayer(player), (1), armas, armasequipadas, vencimentos, estoque)
            end)
        end
    end
end)

addEventHandler('onPlayerLogin', root, function()
    bindKey(source, config.panel.key, config.panel.state, function (player)
        local armas = dbPoll(dbQuery(connection, 'SELECT * FROM Armas WHERE User = ?', getAccountName(getPlayerAccount(player))) , - 1)
        local armasequipadas = dbPoll(dbQuery(connection, 'SELECT * FROM Equipe WHERE User = ?', getAccountName(getPlayerAccount(player))) , - 1)
        local vencimentos = dbPoll(dbQuery(connection, 'SELECT * FROM Vip WHERE User = ?', getAccountName(getPlayerAccount(player))) , - 1)
        local estoque = dbPoll(dbQuery(connection, 'SELECT * FROM EstoqueShopCoins'), - 1)
        triggerClientEvent(player, 'onPanelDraw', player, getVipPlayer(player), 1, armas, armasequipadas, vencimentos, estoque)
    end)
end)

addEvent('coletarBeneficioVip', true)
addEventHandler('coletarBeneficioVip', root, function (beneficio, vip, group)
    local account = getAccountName(getPlayerAccount(source))
    if aclGetGroup(group) and  isObjectInACLGroup('user.'..account, aclGetGroup(group)) then
        if (beneficio) then
            if delay[beneficio[3]] and delay[beneficio[3]][account] and isTimer(delay[beneficio[3]][account]) then
                return config.notify(source, 'error', 'Você já pegou uma '..beneficio[3]..' recentemente.')
            end
            if (beneficio[3] == 'Skin') then
                setElementModel(source, beneficio[4])
                config.notify(source, 'info', 'Você pegou o beneficio '..beneficio[2]..'.')
                delay[beneficio[3]][account] = setTimer(function() end, vip.delay*60000, 1)
            elseif (beneficio[3] == 'Arma') then
                exports['CzInventory']:sendItem(source, beneficio[4], 1)
                exports['CzInventory']:sendItem(source, beneficio[5][1], beneficio[5][2])
                config.notify(source, 'info', 'Você pegou o beneficio '..beneficio[2]..'.')
                delay[beneficio[3]][account] = setTimer(function() end, vip.delay*3600000, 1)
            elseif (beneficio[3] == 'Veiculo') then
				if not isElement(vehicle[source]) then
                    local x, y, z = getElementPosition(source)
                    local _, _, r = getElementRotation(source)
                    vehicle[source] = createVehicle(beneficio[4], x+1.5, y+1.5, z, 0, 0, r, 'Trinity')
                    config.notify(source, 'info', 'Você pegou o beneficio '..beneficio[2]..'.')
                    delay[beneficio[3]][account] = setTimer(function() end, vip.delay*60000, 1)
					setElementData(vehicle[source], 'Owner', source)
					setElementData(vehicle[source], 'fuel', 100)
                else
					destroyElement(vehicle[source])
					--config.notify(source, 'Você já possui um veículo spawnado, digite /vehiclevip para guardar.', 'warning')
                end
            elseif (beneficio[3] == 'Vida') then
                if getElementHealth(source) < 100 then
                    setElementHealth(source, getElementHealth(source) + beneficio[4])
                    config.notify(source, 'info', 'Você pegou o beneficio '..beneficio[2]..'.')
                    delay[beneficio[3]][account] = setTimer(function() end, vip.delay*60000, 1)
                else
                    config.notify(source, 'warning', 'Você já está com a vida cheia.')
                end
            elseif (beneficio[3] == 'Colete') then
                if getPedArmor(source) < 100 then
                    setPedArmor(source, getPedArmor(source) + beneficio[4])
                    config.notify(source, 'info', 'Você pegou o beneficio '..beneficio[2]..'.')
                    delay[beneficio[3]][account] = setTimer(function() end, vip.delay*60000, 1)
                else
                    config.notify(source, 'warning', 'Você já esta com colete.')
                end
            elseif (beneficio[3] == 'Inventario') then
                exports['CzInventory']:sendItem(source, beneficio[4], 1)
                config.notify(source, 'info', 'Você pegou o beneficio '..beneficio[2]..'.')
                delay[beneficio[3]][account] = setTimer(function() end, vip.delay*60000, 1)
            elseif (beneficio[3] == 'Rainbow') then
                local vehicle = getPedOccupiedVehicle(source)
                if vehicle then 
                    if getElementData(source, 'rainbow.car') then 
                        setElementData(source, 'rainbow.car', false)
                    else 
                        setElementData(source, 'rainbow.car', true)
                    end 
                end
            elseif (beneficio[3] == 'Blindar') then
                local vehicle = getPedOccupiedVehicle(source)
                if vehicle then
                    setVehicleDamageProof(vehicle, true)
                    config.notify(source, 'info', 'Você pegou o beneficio '..beneficio[2]..'.')
                    --exports['FR_DxMessages']:addBox(player, 'Pacote de '..type..' coletado com sucesso', 'success')
                end
            end
        end
    end
end)


addCommandHandler('vehiclevip', function (player)
    if isElement(vehicle[player]) then
        destroyElement(vehicle[player])
        config.notify(player, 'success', 'Você guardou seu veículo VIP.')
    else
        config.notify(player, 'error', 'Você não possui um veículo VIP spawnado.')
    end
end)



addEventHandler('onPlayerQuit', root,
    function ()
        if isElement(vehicle[source]) then
            destroyElement(vehicle[source])
        end
    end
)

 

Link to comment
  • Other Languages Moderators

Basicamente ele está reclamando que a ACL Vip que você está tentando atribuir ao jogador ela não existe.

Antes da linha do erro, coloque isso na linha anterior e descubra qual o nome da ACL que não existe.

iprint("Nome da ACL inexistente:", item.informations.vip)


 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...