Ir para conteúdo

Featured Replies

Postado
  • Este é um post popular.

Fala galera, pra quem não sabe eu fiz um novo task system pro meu servidor pessoal Empire e por isso decidi publicar a versão antiga dele já que não temos nenhuma intenção de usá-la mais.

ele é muito similar a um sistema que eu já havia compartilhado aqui, só que pras versões 0.X. 

O que é: um npc que te dá pequenas missões de matar monstros, qnd você terminar ele te paga uma recompensa pré definida.

O que ele tem de melhor comparado com a versão 0.4: Basicamente ele permite vc definir qualquer hierarquia entre as tasks, permite que tasks deem diversas formas de recompensas (isso era bem engessado no modelo antigo) porém ele não aceita tasks de coletar itens, nem tem dificuldades diferentes com premiações multiplicadas (ao menos não explicitamente).

 

Aqui tá a hierarquia que ele segue atualmente. Ou seja, para fazer task de Tarantula você precisa fazer Rat, depois Spider e por fim Tarantula.
task5.thumb.png.9b501e47a92a116cebf27674412f31da.png


O sistema é muito completo e eu vou postá-lo da exata forma que usávamos então prestem bastante atenção nos detalhes. Já aviso de antemão que eu não darei muito suporte aqui e que não irei explicar muita coisa, o sistema funciona e foi usado por uns 2 anos sem nenhum problema com o tfs original.

crie um arquivo em data/lib chamado tasklib.lua e coloque isso dentro dele:
Aqui temos todas as tasks e storages. Se você quiser adicionar recompensas novas vc só precisa fazer um elseif na função de getRewards. Siga o exemplo dos comentários para as rewards e se quiser todas as tasks liberadas sem precisar seguir uma ordem é só colocar needed = 0 para todas.

Spoiler

-- Task System LIB
-- [14020] tem que ser o primeiro e todos os outros seguirem a ordem "anterior + 1"
tasks = { 
-- tier 0
[14020] = {mob = {"Rat", "Cave Rat"}, count = 12, level = 0, needed = 0, -- ESSA PRECISA SER A PRIMEIRA
reward = {item = {{2148, 15}, {8704, 1}} --, addon = {male = {145, 2}, female = {145, 2}} , outfit = {male = 152, female = 149}, storage = 14281, mount = 14
}},
-- tier 1
[14021] = {mob = {"Troll"}, count = 10, level = 3, needed = 14020,
reward = {item = {{8704, 2}, {2649, 1}}
}},
[14022] = {mob = {"Spider", "Poison Spider"}, count = 12, level = 2, needed = 14020,
reward = {item = {{2148, 25}, {8704, 3}}, experience = 50
}},
[14023] = {mob = {"Skeleton", "Skeleton Warrior", "Undead Gladitor", "Undead Mine Worker"}, count = 18, level = 6, needed = 14020,
reward = {item = {{2148, 100}, {7618, 2}, {7620, 2}}
}},
[14024] = {mob = {"Rotworm", "Carrion Worm", "Rotworm Queen"}, count = 30, level = 8, needed = 14020,
reward = {item = {{2152, 3}, {7618, 4}, {7620, 3}}, experience = 3500
}},
[14025] = {mob = {"Crocodile", "The Snapper"}, count = 40, level = 8, needed = 14020,
reward = {item = {{2152, 3}, {7618, 3}, {7620, 2}}
}},
-- tier 2
[14026] = {mob = {"Minotaur", "Minotaur Archer", "Minotaur Guard", "Minotaur Mage"}, count = 16, level = 6, needed = 14021,
reward = {item = {{2512, 1}, {7618, 2}, {7620, 2}}
}},
[14027] = {mob = {"Orc", "Orc Spearman", "Orc Shaman", "Orc Leader", "Orc Berserker", "Orc Marauder", "Orc Rider", "Orc Warlord", "Orc Warrior", "Kraknaknork"}, count = 30, level = 6, needed = 14021,
reward = {item = {{2398, 1}, {7618, 2}, {7620, 2}}
}},
[14028] = {mob = {"Wasp"}, count = 20, level = 6, needed = 14022,
reward = {item = {{7618, 5}, {7620, 2}}, experience = 920
}},
[14029] = {mob = {"Larva"}, count = 35, level = 8, needed = 14022,
reward = {item = {{7618, 4}, {7620, 3}, {2152, 2}}, experience = 850
}},
[14030] = {mob = {"Tarantula"}, count = 60, level = 20, needed = 14022,
reward = {item = {{2152, 6}}, experience = 8600
}},
[14031] = {mob = {"Ghoul"}, count = 50, level = 12, needed = 14023,
reward = {item = {{2168, 1}},experience = 5270
}},
[14032] = {mob = {"Demon Skeleton"}, count = 80, level = 26, needed = 14023,
reward = {experience = 18510
}},
[14033] = {mob = {"Ghost"}, count = 80, level = 30, needed = 14023,
reward = {item = {{6527, 9}, {2152, 5}}, experience = 9600
}},
-- tier 3
[14034] = {mob = {"Wailing Widow"}, count = 80, level = 25, needed = 14030,
reward = {item = {{13307, 1, chance = 5}, {5879, 3}}, experience = 26500
}},
[14035] = {mob = {"Scarab", "Ancient Scarab"}, count = 55, level = 12, needed = 14029,
reward = {item = {{2162, 1}, {2159, 10}}
}},
[14036] = {mob = {"Dragon Hatchling", "Dragon Lord Hatchling", "Frost Dragon Hatchling"}, count = 60, level = 18, needed = 14025,
reward = {item = {{7618, 5}, {7620, 5}}, experience = 4900
}},
[14037] = {mob = {"Orc Leader", "Orc Warlord"}, count = 75, level = 30, needed = 14027,
reward = {item = {{6527, 6}, {2475, 1}}
}},
[14038] = {mob = {"Goblin", "Goblin Assassin", "Goblin Leader", "Goblin Scavenger"}, count = 50, level = 8, needed = 14027,
reward = {item = {{2152, 4}}, experience = 5000
}},
[14039] = {mob = {"Dwarf", "Dwarf Guard", "Dwarf Miner", "Dwarf Geomancer", "Dwarf Soldier"}, count = 50, level = 8, needed = 14026,
reward = {item = {{6527, 4}, {2543, 40}}, experience = 1620
}},
[14040] = {mob = {"Cyclops", "Cyclops Drone", "Cyclops Smith"}, count = 200, level = 15, needed = 14026,
reward = {experience = 13900
}},
[14041] = {mob = {"Amazon"}, count = 60, level = 10, needed = 14026,
reward = {item = {{7618, 10}, {7620, 6}}, experience = 6000
}},
[14042] = {mob = {"Mummy"}, count = 65, level = 28, needed = 14031,
reward = {item = {{7618, 25}, {7620, 15}, {6527, 5}},experience = 11000
}},
[14043] = {mob = {"undead monster"}, count = 100, level = 40, needed = 14032, -- banshee quest I
reward = {experience = 18000, storage = 14281
}},
[14044] = {mob = {"Spectre"}, count = 300, level = 68, needed = 14033,
reward = {item = {{6527, 15}}, experience = 126000
}},
-- tier 4
[14045] = {mob = {"Giant Spider"}, count = 60, level = 32, needed = 14034,
reward = {item = {{6527, 10}}, experience = 22000
}},
[14046] = {mob = {"Ancient Scarab"}, count = 90, level = 28, needed = 14035,
reward = {item = {{6527, 3}, {2152, 20}}, experience = 34000
}},
[14047] = {mob = {"Stampor"}, count = 80, level = 30, needed = 14036,
reward = {experience = 37000, mount = 11
}},
[14048] = {mob = {"Dragon", "Dragon Lord", "Demodras"}, count = 100, level = 20, needed = 14036,
reward = {item = {{2201, 1}, {2516, 1}}, experience = 10000
}},
[14049] = {mob = {"Cyclops Smith", "Cyclops Drone"}, count = 90, level = 28, needed = 14040,
reward = {item = {{7588, 10}, {2391, 1}}, experience = 22000
}},
[14050] = {mob = {"Dark Magician"}, count = 75, level = 18, needed = 14041,
reward = {item = {{7620, 25}}, experience = 13875
}},
[14051] = {mob = {"Valkyrie"}, count = 70, level = 12, needed = 14041,
reward = {mount = 13, experience = 7500
}},
[14052] = {mob = {"Vampire", "Vampire Bride", "Vampire Viscount"}, count = 150, level = 29, needed = 14042,
reward = {item = {{2534, 1, chance = 5}, {2152, 20}}, experience = 32210
}},
[14053] = {mob = {"undead monster"}, count = 150, level = 50, needed = 14043, -- banshee quest II
reward = {experience = 22000, storage = 14282
}},
[14054] = {mob = {"Phantasm"}, count = 80, level = 80, needed = 14044,
reward = {item = {{6527, 7}}, experience = 148715
}},
-- tier 5
[14055] = {mob = {"Hydra", "The Many"}, count = 210, level = 60, needed = 14047,
reward = {item = {{6527, 15}}, experience = 118650
}},
[14056] = {mob = {"Dragon Lord", "Demodras"}, count = 250, level = 55, needed = 14048,
reward = {item = {{2414, 1}, {2492, 1, chance = 3}, {7891, 1, chance = 6}}, experience = 112500
}},
[14057] = {mob = {"Wyrm", "Elder Wyrm", "Tyrn"}, count = 200, level = 52, needed = 14048,
reward = {item = {{10221, 1}}, experience = 66430
}},
[14058] = {mob = {"Behemoth"}, count = 200, level = 85, needed = 14049,
reward = {item = {{2454, 1}}, experience = 269230
}},
[14059] = {mob = {"Necromancer", "Necropharus"}, count = 175, level = 38, needed = 14050,
reward = {item = {{2185, 1}}, experience = 36250
}},
[14060] = {mob = {"Hero"}, count = 175, level = 42, needed = 14051,
reward = {item = {{6527, 6}}, experience = 42650
}},
[14061] = {mob = {"Banshee"}, count = 200, level = 50, needed = 14052,
reward = {item = {{2160, 1}}, experience = 49090
}},
[14062] = {mob = {"Vampire Viscount", "Vampire Bride"}, count = 175, level = 42, needed = 14052,
reward = {item = {{6527, 12}, {2152, 40}}, experience = 55115
}},
[14063] = {mob = {"undead monster"}, count = 250, level = 60, needed = 14053, -- banshee quest III
reward = {experience = 24000, storage = 14283, mount = 12
}},
-- tier 6
[14064] = {mob = {"Frost Dragon"}, count = 300, level = 80, needed = 14056,
reward = {item = {{6527, 15}}, experience = 126000
}},
[14065] = {mob = {"Demon", "Orshabaal"}, count = 400, level = 120, needed = 14058,
reward = {item = {{2472, 1, chance = 5}, {10305, 1}, {6527, 30}}, experience = 764100, outfit = {male = 289, female = 288}, mount = 39
}},
[14066] = {mob = {"Warlock"}, count = 280, level = 110, needed = 14059,
reward = {item = {{6527, 18}, {2123, 1, chance = 3}, {2466, 1, chance = 1}, {2656, 1, chance = 15}}, experience = 450000
}},
-- tier 3 extended
[14067] = {mob = {"Elf", "Elf Scout", "Elf Arcanist"}, count = 60, level = 10, needed = 14026,
reward = {item = {{2175, 1}, {7620, 10}}
}},
}

 config = { -- #tasks nao funciona, esse foi o jeito
first = 14020,
last = 14067
}

storages = {
firsttask = 14010, -- task1
secondtask = 14011, -- task2
countfirst = 14012, -- quantidade que já matou da task 1
countsecond = 14013 -- quantidade que já matou da task 2
}

function getFreeSlotTask(cid)
	if Player(cid):getStorageValue(storages.firsttask) > 0 then
		return storages.secondtask, storages.countsecond
	else
		return storages.firsttask, storages.countfirst
	end
end

function getFinishedTasks(cid)
	local self = Player(cid)
	local t1, t2 = 0, 0
	if tasks[self:getStorageValue(storages.firsttask)] or tasks[self:getStorageValue(storages.secondtask)] then
		if tasks[self:getStorageValue(storages.firsttask)] and (self:getStorageValue(storages.countfirst) >= tasks[self:getStorageValue(storages.firsttask)].count) then
			t1 = storages.firsttask
		end
		if tasks[self:getStorageValue(storages.secondtask)] and (self:getStorageValue(storages.countsecond) >= tasks[self:getStorageValue(storages.secondtask)].count) then
			t2 = storages.secondtask
		end
	end
	return t1, t2
end

function getRewards(cid, task)
	local self = Player(cid)
	local msg = "You've received for this task: "
	if tasks[self:getStorageValue(task)] then		
		for tipo, valor in pairs (tasks[self:getStorageValue(task)].reward) do 
			if tipo == "experience" then
				experience = valor --* Game.getExperienceStage(self:getLevel())
				msg = msg..experience.." of experience, "
				self:addExperience(experience)
			elseif tipo == "addon" then
				if self:getSex() == 0 then
					self:addOutfitAddon(valor.female[1], valor.female[2])				
				else
					self:addOutfitAddon(valor.male[1], valor.male[2])
				end
				msg = msg.."a new addon, "
			elseif tipo == "outfit" then
				if self:getSex() == 0 then
					self:addOutfit(valor.female)
				else
					self:addOutfit(valor.male)
				end
				msg = msg.."a new outfit, "
			elseif tipo == "storage" then
				self:setStorageValue(valor, 1)
				msg = msg.."a new mission avaiable, "
			elseif tipo == "item" then
				msg = msg.."the following itens: "
				for _, itens in ipairs (valor) do
					if itens.chance and itens.chance < math.random(1, 100) then goto continue end
					self:addItem(itens[1], itens[2])
					msg = msg..ItemType(itens[1]):getName()..", "
					::continue::
				end
			elseif tipo == "mount" then
				self:addMount(valor)
				msg = msg.."a new mount, "
			end
		end
		msg = msg.."enjoy your prize(s) and I'll wait you for the next task."
	end
return msg
end

-- isso aqui vai pruma lib */

 



Agora crie um arquivo em creaturescripts/scripts chamado killtasksystem.lua e coloque isso dentro dele:

Spoiler

dofile('data/lib/tasklib.lua')
local raceTypes = {
	[1] = "venom",
    [2] = "blood",
    [3] = "undead",
    [4] = "fire",
    [5] = "energy",
	}


function onKill(player, monstro)
	local creature = Player(player.uid)
	local target = Monster(monstro.uid)
	local t1 = creature:getStorageValue(storages.firsttask)
	local t2 = creature:getStorageValue(storages.secondtask)	
	if (t1 > 0 or t2 > 0) and target and type(target:getMaster()) == 'nil' then
		if t1 > 0 and tasks[t1] and (isInArray(tasks[t1].mob, target:getName()) or tasks[t1].mob[1]:match("%a+") == raceTypes[target:getType():getRace()]) then
			local store = creature:getStorageValue(storages.countfirst)
			if store < tasks[t1].count then
				creature:setStorageValue(storages.countfirst, store + 1)
				if store + 1 == tasks[t1].count then
					creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You finished your task.")
				elseif store + 1 <= tasks[t1].count then
					creature:sendCancelMessage("Killed ["..store + 1 .."/"..tasks[t1].count.."]")
				end
			end
		elseif t2 > 0 and tasks[t2] and (isInArray(tasks[t2].mob, target:getName()) or tasks[t2].mob[1]:match("%a+") == raceTypes[target:getType():getRace()]) then
			local store = creature:getStorageValue(storages.countsecond)
			if store < tasks[t2].count then
				creature:setStorageValue(storages.countsecond, store + 1)
				if store + 1 == tasks[t2].count then
					creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You finished your task.")
				elseif store + 1 <= tasks[t2].count then
					creature:sendCancelMessage("Killed ["..store + 1 .."/"..tasks[t2].count.."]")
				end
			end
		end
	end
return true
end

 

Tirando as mensagens, não acho que tenha nada que você possa editar aqui. Essa tabela racetypes eu coloquei pq queria fazer task de criaturas de um mesmo tipo: fire, undead, poison. Ele puxa esse valor de dentro do race definido no xml do monstro. (Veja a undead monsters como exemplo.)

em creaturescripts.xml coloque:
 

<event type="kill" name="tasksystem" script="killtasksystem.lua"/>

E em creaturescripts/scripts/login.lua antes do ultimo return true:

player:registerEvent("tasksystem")

Agora criaremos o npc chamado tasksystem.xml na pasta data/npcs:

Spoiler

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Magnus" script="tasksystem.lua" walkinterval="2000" floorchange="0" speechbubble="3">
  <health now="100" max="100" />
  <look type="143" head="39" body="113" legs="38" feet="0" addons="3"/>
<voices>
<voice text="True warriors don't show weakness." interval2="100" margin="1" yell="no"/>
</voices>
<parameters>
    <parameter key="message_greet" value="Hello |PLAYERNAME|, I've been wondering if you would never appear.. Are you interested in a {challenge} or you're just looking for your {reward}?"/>
    <parameter key="message_farewell" value="See you later |PLAYERNAME|."/>
	<parameter key="message_walkaway" value="I guess it's a goodbye." />
</parameters>
</npc>

 


E o script dele em data/npcs/scripts chamado tasksystem.lua: (sim, eu não sou criativo com nomes)
 

Spoiler

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
dofile('data/lib/tasklib.lua')
-- OTServ event handling functions start
function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                      npcHandler:onThink() end
function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid	
local player = Player(cid)	

if (msgcontains(msg, 'task') or msgcontains(msg, 'challenge')) then
	if not (player:getStorageValue(storages.firsttask) > 0 and player:getStorageValue(storages.secondtask) > 0) then
		npcHandler:say("Are you interested in the challenges I may have to you? Interesting...", cid)
		talkState[talkUser] = 1
	else 
		npcHandler:say("I already gave you two tasks, go finish them before you come here asking for more.", cid)
	end
elseif talkState[talkUser] == 1 and msgcontains(msg, 'yes') then
	local msg = ""
	local count = 0
	for i = config.first, config.last do
		if tasks[i] and player:getLevel() >= tasks[i].level and (tasks[i].needed == 0 or player:getStorageValue(tasks[i].needed) >= 1) and player:getStorageValue(i) < 0 then
			msg = count == 0 and msg.."{"..tasks[i].mob[1].."}" or msg..", {"..tasks[i].mob[1].."}"
			count = count + 1
		end
	end
	if count == 0 then
		npcHandler:say("Well, things are going pretty calm these days, I don't have anything in mind for you right now.", cid)
		talkState[talkUser] = 0
	elseif count == 1 then
		npcHandler:say("The only thing that's bothering me it's these damn ".. msg .."'s. If you take care of them I'll pay you well. Do you accept this challenge?", cid)
		talkState[talkUser] = 2
	else
		npcHandler:say("Well, I have problems with the following creatures: ".. msg ..". Would you help me with any of them?", cid)
		talkState[talkUser] = 3
	end
elseif talkState[talkUser] == 3 and msgcontains(msg, 'no') then
	npcHandler:say("If you can't handle any of the monsters I've just said then you better leave. This ain't a playground kid. ", cid)
	talkState[talkUser] = 0
elseif talkState[talkUser] == 3 and msgcontains(msg, 'yes') then
	local possible = {}
	for i = config.first, config.last do
		if player:getLevel() >= tasks[i].level and (tasks[i].needed == 0 or player:getStorageValue(tasks[i].needed) >= 1) and player:getStorageValue(i) < 0 then
			table.insert(possible, i)
		end
	end
	local quest = #possible >= 1 and possible[math.random(1, #possible)] or false
	if not quest then
		npcHandler:say("Something went terrible wrong, contact an admin.", cid)
	else
		npcHandler:say("Ok then, come back when you've killed {".. tasks[quest].count .. " ".. tasks[quest].mob[1].."'s}. I'll be waiting.", cid)
		local task, count = getFreeSlotTask(cid)
		player:setStorageValue(count, 0)
		player:setStorageValue(task, quest)
		player:setStorageValue(quest, 0)
	end
	talkState[talkUser] = 0	
elseif talkState[talkUser] == 3 then
	for i = config.first, config.last do
		if player:getLevel() >= tasks[i].level and (tasks[i].needed == 0 or player:getStorageValue(tasks[i].needed) >= 1) and player:getStorageValue(i) < 0 then
			if msgcontains(msg:lower(), (tasks[i].mob[1]):lower()) then				
				local task, count = getFreeSlotTask(cid)
				player:setStorageValue(count, 0)
				player:setStorageValue(task, i)
				player:setStorageValue(i, 0)
				talkState[talkUser] = 0
				return npcHandler:say("Ohh wise choice, come back when you've killed {".. tasks[i].count .." ".. tasks[i].mob[1] .."'s}. I'll be waiting.", cid)
			end
		end
	end
	npcHandler:say("That's the problem with choices, what you said doesn't match with any of the options...", cid)
elseif talkState[talkUser] == 2 and (msgcontains(msg, 'yes') or msgcontains(msg, 'ok')) then	
	local i = config.first
	local gotIt = false
	while (i <= config.last and not gotIt) do 	
		if player:getLevel() >= tasks[i].level and (tasks[i].needed == 0 or player:getStorageValue(tasks[i].needed) >= 1) and player:getStorageValue(i) < 0 then
			npcHandler:say("Ok then, come back when you've killed {".. tasks[i].count .. " ".. tasks[i].mob[1].."'s}. I'll be waiting.", cid)
			local task, count = getFreeSlotTask(cid)
			player:setStorageValue(count, 0)
			player:setStorageValue(task, i)
			player:setStorageValue(i, 0)
			gotIt = true			
		end
		i = i + 1
	end
	talkState[talkUser] = 0
elseif talkState[talkUser] == 2 and msgcontains(msg, 'no') then
	npcHandler:say("If you can't handle, then just leave.", cid)
	talkState[talkUser] = 0
elseif talkState[talkUser] == 1 and msgcontains(msg, 'no') then
	npcHandler:say("So why did you even started this conversation? Go away.", cid)
	talkState[talkUser] = 0
	---------- reward ------------
elseif msgcontains(msg, 'reward') then
	if player:getStorageValue(storages.firsttask) > 0 or player:getStorageValue(storages.secondtask) > 0 then 
		local task1, task2 = getFinishedTasks(cid)
		if task1 > 0 then
			npcHandler:say("First task\n "..getRewards(cid, task1), cid)			
			player:setStorageValue(player:getStorageValue(task1), 1)	
			player:setStorageValue(task1, -1)						
		elseif task2 > 0 then
			npcHandler:say("Second task\n "..getRewards(cid, task2), cid)			
			player:setStorageValue(player:getStorageValue(task2), 1)
			player:setStorageValue(task2, -1)				
		else
			npcHandler:say("You can't receive any reward since you didn't finish any task.", cid)			
		end
		talkState[talkUser] = 0		
	else
		npcHandler:say("Are you thinking about the rewards? You don't even started the challenge yet...", cid)
		talkState[talkUser] = 0
	end
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 


Por fim insira essa talkaction aqui no seu server, ela serve para gerar um arquivo chamado orderedtask.html na pasta do seu servidor (a mesma do executavel) com o código html do sistema de task (sim, eu tenho preguiça de escrever as coisas no site)

 

Spoiler

local function spairs(t, order)
    -- collect the keys
    local keys = {}
    for k in pairs(t) do keys[#keys+1] = k end

    -- if order function given, sort by it by passing the table and keys a, b,
    -- otherwise just sort the keys
    if order then
        table.sort(keys, function(a,b) return order(t, a, b) end)
    else
        table.sort(keys)
    end

    -- return the iterator function
    local i = 0
    return function()
        i = i + 1
        if keys[i] then
            return keys[i], t[keys[i]]
        end
    end
end

function onSay(player)
    if not player:getGroup():getAccess() then
  		return true
  	end

  	if player:getAccountType() < ACCOUNT_TYPE_GOD then
  		return false
  	end

  local file_ = io.open('orderedtask.html','w')

  for i,v in spairs(tasks, function(t,a,b) return t[b].level > t[a].level end) do
    local txt = "<tr>\n<td align=\"center\">".. v.level .."</td> <!--level necessario-->\n<td><div align=\"center\">\n"

    for i, v in ipairs(tasks[i].mob) do
      txt = txt..v.."<br>\n"
    end
    txt = txt.."</div></td>\n<td align=\"center\">".. tasks[i].count .. "</td> <!--quantidade-->\n<td align=\"center\" colspan=\"2\">"

    for tipo, valor in pairs(tasks[i].reward) do
      if tipo == 'item' then
        for j, v in pairs(valor) do
          if ItemType(v[1]) then
            local name = v[2] > 1 and ItemType(v[1]):getPluralName() or ItemType(v[1]):getName()
            if v[2] and v[2] > 1 then
              txt = txt.. v[2].." ".. name
            else
              txt = txt..name
            end
            if v.chance then
              txt = txt.. " (".. v.chance .."%)"
            end
            txt = txt .. "<br>\n"
          end
        end
      elseif tipo == 'experience' then
        txt = txt.. valor.. "xp <br>\n"
      elseif tipo == 'addon' then
        txt = txt.. "a new addon<br>\n"
      elseif tipo == 'outfit' then
        txt = txt.. "a new outfit<br>\n"
      elseif tipo == 'mount' then
        txt = txt.. "a new mount<br>\n"
      end
    end
    txt = txt.."</td>\n</tr>\n\n"
    file_:write(txt)
  end
  player:say("File was generated.", TALKTYPE_SAY)
return true
end

 


Coloque o nome que vc quiser e depois coloque a tag em talkactions.xml:

<talkaction words="/generatehtml" script="nome que vc quiser.lua" />


Note que o arquivo pode levar um tempinho para aparecer, até pq ele tá percorrendo toda a tabela pegando todas as informações e criando um arquivo html disso, é um processo que pode levar alguns segundos.

Se você quiser ser hackudo e pegar o html direto do meu site, seja livre: https://www.empirebr.com/tasks

Bom uso, se tiver qualquer dúvida ou comentário ou sugestão diz aí. ^^

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

  • Respostas 39
  • Visualizações 17.7k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Você tem que criar um novo arquivo em data/libs chamado tasksystem e colar esse conteúdo lá, e aí procurar qual a lib que carrega todas as libs (acho q fica na pasta core) e seguir o exemplo para mand

Posted Images

Postado

Parabéns, seu tópico de conteúdo foi aprovado!
Muito obrigado pela sua contribuição, nós do Tibia King agradecemos.
Seu conteúdo com certeza ajudará à muitos outros, você recebeu +1 REP.

Spoiler

Congratulations, your content has been approved!
Thank you for your contribution, we of Tibia King we are grateful.
Your content will help many other users, you received +1 REP.

 

                              _
                          .-'` `}
                  _./)   /       }
                .'o   \ |       }
                '.___.'`.\    {`
                /`\_/  , `.    }                                      ME DA UMA NOZ!
                \=' .-'   _`\  {
                 `'`;/      `,  }
                    _\   @   ;  }
                   /__`;-...'--'

Cluck!

Postado

@xWhiteWolf melhor não comentar, mas irei comentar apenas para deixar comentado que meu comentário não tem importância! HUFoahsd

Lindeza de algoritmo. O quê me surpreendeu foi esse código html gerado a parti das task configuradas para ser usada no site mostrando as task presentes do servidor(confere ? hausd), muito dahóra tio!!  

                                                              ezgif-1-98aab239f3.gif.1a897c9c3225228909e7b356a5cfb8e4.gif

Postado
  • Autor
On 16/02/2018 at 11:24 PM, KotZletY said:

@xWhiteWolf melhor não comentar, mas irei comentar apenas para deixar comentado que meu comentário não tem importância! HUFoahsd

Lindeza de algoritmo. O quê me surpreendeu foi esse código html gerado a parti das task configuradas para ser usada no site mostrando as task presentes do servidor(confere ? hausd), muito dahóra tio!!  

sim, é exatamente isso. Passar as tasks pro site é um trampo considerável visto que são umas 47 tasks ao todo, aí eu criei essa talkaction que gera o html pronto pra tu copiar e colar na aba do site referente as tasks. Prum usuário comum provavelmente nao vai fazer nenhuma diferença, mas se tiver algum webmaster q tenha noçãozinha ele consegue importar mt fácil esse arquivo.

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

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.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo