Ir para conteúdo

Featured Replies

Postado

Acabei de fazer aqui, mas nao testei:

local function doPlayerAddDepotItems(pid, item, count)
    local result = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = "..pid.." ORDER BY `sid` DESC LIMIT 1;")
    if (result:getID() ~= -1) then
        local ls = tonumber(result:getDataInt("sid"))
        return db.executeQuery("INSERT INTO `player_depotitems` (`player_id`, `sid`, `pid`, `itemtype`, `count`, `attributes`) VALUES ("..pid..", "..(ls+1)..", 101, "..item..", "..count..", '');")
    end
end

local config = {
--[posiçao do rank] = {premio, quantidade}
	[1] = {2160,100}, -- TOP 1
	[2] = {2160,60}, -- TOP 2
	[3] = {2160,40}, -- TOP 3
	[4] = {2160,20}, -- TOP 4
	[5] = {2160,10} -- TOP 5
}
local days = {"sunday"} -- {Segunda = Monday, Terça = Tuesday, Quarta = Wednesday, Quinta = Thursday, Sexta = Friday, Sabado = Saturday, Domingo = Sunday}

local players = {}
function onTimer(interval)
	for d = 1, #days do
		if os.date("%A"):lower() ~= days[d]:lower() then return true end
	end
	local string = "Ganhadores dos premios TOP Rank:\n"
	for i = 1, #config do
		local result = db.getResult("SELECT `name`, `id` FROM `players` WHERE `group_id` < 3 AND deleted = 0 ORDER BY `level` DESC, `experience` DESC LIMIT "..(i-1)..", "..i..";")
		table.insert(players, result:getDataInt("id"))
		local name = result:getDataString("name")
		local on = getPlayerByNameWildcard(name)
		if isCreature(on) then
			doPlayerAddItem(on, config[i][1], config[i][2])
		else
			doPlayerAddDepotItems(players[i], config[i][1], config[i][2])
		end
		string = string..""..i.." "..name..", premio: "..config[i][2].." "..getItemNameById(config[i][1])..""..(config[i][2] > 1 and "s" or "").."\n"
	end
	return doBroadcastMessage(string, MESSAGE_EVENT_ADVANCE)
end

TAG:

<globalevent name="TopReward" time="21:00" event="script" value="Nome Do Arquivo.lua"/>
  • Respostas 9
  • Visualizações 438
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Acabei de fazer aqui, mas nao testei: local function doPlayerAddDepotItems(pid, item, count) local result = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = "..pid.." ORDE

  • em globalevents

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo