Ir para conteúdo
  • Cadastre-se

(Resolvido)Erro no globalevent


Ir para solução Resolvido por Absolute,

Posts Recomendados

Gostaria da ajuda de vcs pra arruma isso '-'

 

[Error - GlobalEvent Interface]
data/globalevents/scripts/start.lua:onstartup
Description:
data/globalevents/scripts/start.lua:78 attempt to call field 'executequery' <a nil value>
stack traceback:
data/globalevents/scripts/start.lua:78 in function <data/globalevents/scripts/start.lua:8>

 

Aqui meu arquivo Start '-'
 

local config = {
	creationTime = 7 * 86400,
	checkTime = 7 * 86400,
	viceCount = 4,
	memberCount = 10
}

function onStartup()
	local data, time, result = {}, os.time(), db.getResult("SELECT `id`, `ownerid`, `creationdata`, `checkdata` FROM `guilds` WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
	if(result:getID() ~= -1) then
		repeat
			data[result:getDataInt("id")] = {result:getDataInt("ownerid"), result:getDataInt("creationdata"), result:getDataInt("checkdata")}
		until not(result:next())
		result:free()
	end

	for id, v in ipairs(data) do
		local owner, created, check = v[1], v[2], v[3]
		if(created < (time - config.creationTime)) then
			result = db.getResult("SELECT `id`, `level` FROM `guild_ranks` WHERE `guild_id` = " .. id .. ";")
			if(result:getID() ~= -1) then
				local rank, ranks = 0, {}
				repeat
					ranks[result:getDataInt("id")] = result:getDataInt("level")
					if(result:getDataInt("level") == 1) then
						rank = result:getDataInt("id")
					end
				until not(result:next())
				result:free()

				local members = {0, 0, 0, 0}
				for k, v in ipairs(ranks) do
					result = db.getResult("SELECT COUNT(`id`) AS `count` FROM `players` WHERE `rank_id` = " .. k .. ";")
					if(result:getID() ~= -1) then
						members[v] = members[v] + result:getDataInt("count")
						result:free()
					end

					if(v == 2) then
						result = db.getResult("SELECT `p`.`id` FROM `players` p LEFT JOIN `accounts` a ON `p`.`account_id` = `a`.`id` WHERE `p`.`rank_id` = " .. k .. " AND (`a`.`premdays` = 0 OR (`a`.`lastday` + (`a`.`premdays` * 86400) <= 0));")
						if(result:getID() ~= -1) then
							local demote = ""
							repeat
								demote = demote .. result:getDataInt("id") .. ","
								members[2] = members[2] - 1
								members[1] = members[1] + 1
							until not(result:next())
							result:free()

							if(demote ~= "" and rank ~= 0) then
								db.executeQuery("UPDATE `players` SET `rank_id` = " .. rank .. " WHERE `id` IN (" .. demote:sub(1, -2) .. ");")
							end
						end
					end
				end

				for i = 1, 3 do
					members[4] = members[4] + members[i]
				end

				if(members[2] < config.viceCount or members[4] < config.memberCount) then
					if(check == 0) then
						db.executeQuery("UPDATE `guilds` SET `checkdata` = " .. (time + config.checkTime) .. " WHERE `id` = " .. id .. ";")
					elseif(check < time) then
						local tmp = ""
						for rank, _ in ipairs(ranks) do
							tmp = tmp .. rank .. ","
						end

						db.executeQuery("UPDATE `players` SET `rank_id` = 0, `guildnick` = '', `guildjoin` = 0 WHERE `rank_id` IN (" .. tmp:sub(1, -2) .. ");")
						db.executeQuery("DELETE FROM `guilds` WHERE `id` = " .. id .. ";")
					end
				end
			end
		end
	end

	db.executeQuery("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. " AND `online` > 0;")
	return true
end

function onGlobalSave()
	if(getGameState() ~= GAMESTATE_CLOSING) then
		return onStartup()
	end

	return true
end

Link para o post
Compartilhar em outros sites

Falta uma query na sua db '-'

YDmXTU2.png

 

Entenda tudo sobre VPS, DEDICADOS & HOSPEDAGENS. => Clique aqui

Global Full Download 10.9x - TFS 1.2/FERUMBRAS/KRAILOS. => Clique aqui

 

Muitos querem aquilo que você tem, 
mas vão desistir quando souberem o preço que você pagou.

 

skype-favicon.png lu.lukinha

message-16.png [email protected]

Link para o post
Compartilhar em outros sites
  • Solução

Mais fácil, altere no seu script, substitui seu script por este:

 

 

local config = {
    creationTime = 7 * 86400,
    checkTime = 7 * 86400,
    viceCount = 4,
    memberCount = 10
}

function onStartup()
    local data, time, result = {}, os.time(), db.getResult("SELECT `id`, `ownerid`, `creationdata`, `checkdata` FROM `guilds` WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
    if(result:getID() ~= -1) then
        repeat
            data[result:getDataInt("id")] = {result:getDataInt("ownerid"), result:getDataInt("creationdata"), result:getDataInt("checkdata")}
        until not(result:next())
        result:free()
    end

    for id, v in ipairs(data) do
        local owner, created, check = v[1], v[2], v[3]
        if(created < (time - config.creationTime)) then
            result = db.getResult("SELECT `id`, `level` FROM `guild_ranks` WHERE `guild_id` = " .. id .. ";")
            if(result:getID() ~= -1) then
                local rank, ranks = 0, {}
                repeat
                    ranks[result:getDataInt("id")] = result:getDataInt("level")
                    if(result:getDataInt("level") == 1) then
                        rank = result:getDataInt("id")
                    end
                until not(result:next())
                result:free()

                local members = {0, 0, 0, 0}
                for k, v in ipairs(ranks) do
                    result = db.getResult("SELECT COUNT(`id`) AS `count` FROM `players` WHERE `rank_id` = " .. k .. ";")
                    if(result:getID() ~= -1) then
                        members[v] = members[v] + result:getDataInt("count")
                        result:free()
                    end

                    if(v == 2) then
                        result = db.getResult("SELECT `p`.`id` FROM `players` p LEFT JOIN `accounts` a ON `p`.`account_id` = `a`.`id` WHERE `p`.`rank_id` = " .. k .. " AND (`a`.`premdays` = 0 OR (`a`.`lastday` + (`a`.`premdays` * 86400) <= 0));")
                        if(result:getID() ~= -1) then
                            local demote = ""
                            repeat
                                demote = demote .. result:getDataInt("id") .. ","
                                members[2] = members[2] - 1
                                members[1] = members[1] + 1
                            until not(result:next())
                            result:free()

                            if(demote ~= "" and rank ~= 0) then
                                db.executeQuery("UPDATE `players` SET `rank_id` = " .. rank .. " WHERE `id` IN (" .. demote:sub(1, -2) .. ");")
                            end
                        end
                    end
                end

                for i = 1, 3 do
                    members[4] = members[4] + members
                end

                if(members[2] < config.viceCount or members[4] < config.memberCount) then
                    if(check == 0) then
                        db.executeQuery("UPDATE `guilds` SET `checkdata` = " .. (time + config.checkTime) .. " WHERE `id` = " .. id .. ";")
                    elseif(check < time) then
                        local tmp = ""
                        for rank, _ in ipairs(ranks) do
                            tmp = tmp .. rank .. ","
                        end

                        db.executeQuery("UPDATE `players` SET `rank_id` = 0, `guildnick` = '', `guildjoin` = 0 WHERE `rank_id` IN (" .. tmp:sub(1, -2) .. ");")
                        db.executeQuery("DELETE FROM `guilds` WHERE `id` = " .. id .. ";")
                    end
                end
            end
        end
    end
    return true
end

function onGlobalSave()
    if(getGameState() ~= GAMESTATE_CLOSING) then
        return onStartup()
    end

    return true
end
 

YDmXTU2.png

 

Entenda tudo sobre VPS, DEDICADOS & HOSPEDAGENS. => Clique aqui

Global Full Download 10.9x - TFS 1.2/FERUMBRAS/KRAILOS. => Clique aqui

 

Muitos querem aquilo que você tem, 
mas vão desistir quando souberem o preço que você pagou.

 

skype-favicon.png lu.lukinha

message-16.png [email protected]

Link para o post
Compartilhar em outros sites

Explicando seu erro caso alguém tenha o mesmo problema:

 

Description:
data/globalevents/scripts/start.lua:78 attempt to call field 'executequery' <a nil value>

 

No erro mostra que o problema está na linha 78, use o notepad para ver a linha e retire o db check

 

Fico feliz por ter ajudado.

Bom Dia.

YDmXTU2.png

 

Entenda tudo sobre VPS, DEDICADOS & HOSPEDAGENS. => Clique aqui

Global Full Download 10.9x - TFS 1.2/FERUMBRAS/KRAILOS. => Clique aqui

 

Muitos querem aquilo que você tem, 
mas vão desistir quando souberem o preço que você pagou.

 

skype-favicon.png lu.lukinha

message-16.png [email protected]

Link para o post
Compartilhar em outros sites
  • 3 years later...
Em 30/05/2014 em 14:44, Absolute disse:

Explicando seu erro caso alguém tenha o mesmo problema:

 

Description:
data/globalevents/scripts/start.lua:78 attempt to call field 'executequery' <a nil value>

 

No erro mostra que o problema está na linha 78, use o notepad para ver a linha e retire o db check

 

Fico feliz por ter ajudado.

Bom Dia.

 Estou com o mesmo problema, poderia me ajudar?

 

[10/01/2018 11:22:50] data/globalevents/scripts/start.lua:1: attempt to call global 'executeQuery' (a nil value)
[10/01/2018 11:22:50] [Warning - Event::loadScript] Cannot load script (data/globalevents/scripts/start.lua)

 

executeQuery("DELETE FROM `guild_wars` WHERE `status` = 0 AND `begin` < " .. (os.time() - 2 * 86400) .. ";")
db.executeQuery("UPDATE `guild_wars` SET `status` = 5, `end` = " .. os.time() .. " WHERE `status` = 1 AND `end` > 0 AND `end` < " .. os.time() .. ";")

Link para o post
Compartilhar em outros sites
  • 1 year later...

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo