Ir para conteúdo

Featured Replies

Postado
local config = {
    monsters = {
      -- ["Name"] = {amount = quantidade}
      ["Demon"] = {amount = 30},
      ["Hydra"] = {amount = 10},
    },
    storage = 54661, -- Não mexer se não souber editar
    money = 100 -- Dinheiro
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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

local function releasePlayer(cid)
	if not Player(cid) then
		return
	end

	npcHandler:releaseFocus(cid)
	npcHandler:resetNpc(cid)
end

local function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end

  	local player = Player(cid)
	if msgcontains(msg, "mission") then
		if player:getStorageValue(config.storage) < 1 then
			selfSay("A missão para promovido custa " .. config.money .. " você aceita fazer ?", cid)
			npcHandler.topic[cid] = 1
		elseif player:getStorageValue(config.storage) == (2 + #config.monsters) then
			selfSay("Você já cumpriu a missão peça pra ser {promovido}.", cid)
			npcHandler.topic[cid] = 2
		elseif player:getStorageValue(config.storage) == (3 + #config.monsters) then
			selfSay("Voce já terminou as missões, pode ir em embora!", cid)
			releasePlayer(cid)
		end
	elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 1 then
		if player:removeMoney(config.money) then
			local text = ""
			for monsters, v in pairs(config.monsters) do
				text = text .. ", "
				text = text .. v.amount .. " {" .. monsters .. "}"
			end
			npcHandler:say("A missão é matar esses monstros para mim" .. text .. ".", cid)
			for i, _ in pairs(config.monsters) do
				player:setStorageValue(i, 0)
			end
			player:setStorageValue(config.storage, 1)
		else
			selfSay("Você não tem money suficiente!", cid)
		end
		npcHandler.topic[cid] = 0
	elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 2 then
		selfSay("Até logo!", cid)
		npcHandler.topic[cid] = 0
	end

	if msgcontains(msg, "lista") and player:getStorageValue(config.storage) < (#config.monster + 3) then
		local text, n = "", 0
		for monsters, v in pairs(config.monsters) do
			local sto = player:getStorageValue(monsters)
			if  sto < v.amount then
				n = n + 1
				text = text .. ", "
				text = text .. (tostring(sto) < tostring(1) and v.amount or (tostring(v.amount) - tostring(sto))) .. " {" .. monsters .. "}"
			end
		end
	elseif msgcontains(msg, "promovido") and npcHandler.topic[cid] == 2 then
		selfSay("Aqui está sua promoção jovem soldado!!", cid)
		player:setVocation(player:getVocation() + 4)
		player:setStorageValue(config.storage, (#config.monsters + 3))
		for monsters, _ in pairs(config.monsters) do
			player:setStorageValue(monsters, -1)
		end
		npcHandler.topic[cid] = 0
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
local config = {
    monsters = {
      -- ["Name"] = {amount = quantidade}
      ["Demon"] = {amount = 30},
      ["Hydra"] = {amount = 10},
    },
    storage = 54661, -- Não mexer se não souber editar
}

function onKill(creature, target)
	local monster = config.monsters[target:getName():lower()]
	if not monster or not target:isMonster() then
		return false
	end

	if player:getStorageValue(config.storage) >= (2 + #config.storage) then
		return false
	end

	local sto = player:getStorageValue(monster)
	if sto < (monster.amount - 1) then
		player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Task message: ["  .. (sto + 1) ..  "/" .. monster.amount .. "] of " .. target:getName() .. ".")
		player:setStorageValue(monster, (sto + 1))
	elseif sto == (monster.amount - 1)
		player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations!! you have killed"  .. (sto + 1) ..  "/" .. monster.amount .. "] of " .. target:getName() .. "s ands and completed the task.")
		player:setStorageValue(monster, (sto + 1)) 
		player:setStorageValue(config.storage, (player:getStorageValue(config.storage) + 1))
	end
	return true
end

function onLogin(player)
	player:registerEvent('taskNpc')
	return true
end

 

Editado por FlavioHulk (veja o histórico de edições)

  • Respostas 12
  • Visualizações 1.3k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • local config = { monsters = { -- ["Name"] = {amount = quantidade} ["Demon"] = {amount = 30}, ["Hydra"] = {amount = 10}, }, storage = 54661, -- Não mexer se não souber edi

  • Editei o post acima! E quando a colocar pra uma vocação especifica, é possível sim...

Posted Images

Postado
  • Autor

eu gostaria de fazer 4, 1 pra cada vocação, possível colocar para que só uma vocação especifica possa falar com ele ?.

 

e esta ocorrendo esse erro aqui: hi, mission ai da esse erro.

erro.thumb.png.ece96f3dbf4c4f8cb2e51cd1a73485bf.png

 

Editado por amoxicilina (veja o histórico de edições)

Postado
1 hora atrás, amoxicilina disse:

eu gostaria de fazer 4, 1 pra cada vocação, possível colocar para que só uma vocação especifica possa falar com ele ?.

 

e esta ocorrendo esse erro aqui: hi, mission ai da esse erro.

erro.thumb.png.ece96f3dbf4c4f8cb2e51cd1a73485bf.png

 

 

Editei o post acima! E quando a colocar pra uma vocação especifica, é possível sim...

Postado

problema que o sistema poderia ser confundido vejo que ele pode pegar qualquer tarefa sem terminar um não há restrição

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