Ir para conteúdo
  • Cadastre-se

(Resolvido)Npc que troca item por vida e mana


Ir para solução Resolvido por Agaka,

Posts Recomendados

Boa Tarde TibiaKing!!!

 

Bom estou precisando de um script não deve ser muito difícil !! (pra quem sabe :) !)

Quem poder ajudar já agradeço. ++ Rep

 

 

Seria um Npc Exemplo

Player :Hi

Npc: Ola (PLAYERNAME) gostaria de receber {buff} ?

 

Player: Buff 

Npc: Gostaria de receber qual, Buff 1, buff 2, buff 3,..... buff 12.

 

Player: Buff 12

Npc: voce precisar ter recebido o Buff Anterior (Buff 11) para receber o próximo Buff (Buff 12)

 

Player: Buff 1

Npc: você precisa do item xxxx <<< !! Alem do item uma storage certa e o level!

 

Player: Buff 1 "novamente <"

Npc: você já recebeu esse buff!

 

Config do npc

 

[buff 01] = life 1000000 (Permanente)

                  mana = 10000000 ( Permanente)

Level = 100 <!! ele so pode receber buff 01 no level 100 e assim em diante

Storage = 211100 ( caso ele não tenha < vai aparecer o seguinte "você não completou a missão dos buffs"

[buff 02] = life 1000000 (Permanente)

                  mana = 10000000 (Permanente)

Level = 200

Storage211101

 

 

 

o player só poderá receber o próximo buff se ele Receber o primeiro Buff antes (Ex ele so pode ter buff 02 se tiver recebido o buff 01) 

 

Espero que de para entender tudo!! 

 

 

 

 

 

 

 

Editado por Maniaco (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Este tópico foi movido para a área correta. Esta é uma mensagem automática!
Pedimos que leia as regras do fórum!

Spoiler

This topic has been moved to the correct area. This is an automated message!
Please read the forum rules.

 

Link para o post
Compartilhar em outros sites

Qual versão do TFS?

discord.pngDiscord: vankk #7765

Precisando de ajuda? Entre em contato comigo via Discord.

 

Muitos vêm seus muitos dias de glória, mas poucos vêm seus muitos dias de luta.

Link para o post
Compartilhar em outros sites
2 horas atrás, Maniaco disse:

0.4 esqueci de colocar !!!

 

é um item que o npc pede e recebe mana e vida?

Editado por ZikaLord (veja o histórico de edições)
O rei de seu proprio destino é aquele que luta pela gloria do amanhã!
Discord : ZoR#9373


 

Link para o post
Compartilhar em outros sites
13 horas atrás, Maniaco disse:

sim 

 

cara eu fiz um item

storage = 211100 -- storage checada 
local level = 100 -- level desejado
local item = 2545 -- item 1

function onUse(cid, item) -- função e parametros
if getPlayerLevel(cid) < level then -- level que ira verificar
	doPlayerSendTextMessage(cid, "Você não tem o level 100") -- mensagem caso não tenha o level necessario
elseif item == 2545 then -- verificando os item das variaveis (item e item2)
	doCreatureAddHealth(cid, 1000 * 1000) -- vida adicionda
	doCreatureAddMana(cid, 1000 * 1000) -- mana adicionada
	doPlayerSendTextMessage(cid, "Foi adicionado mana e vida a você") -- se não querer que essa msg apareca apague
elseif storage ~= 211100 then -- checando a storage
	doPlayerSendTextMessage(cid, "você não completou a missão dos buffs")	-- mensagem caso não tenha
	  end -- finaliza if
 return true 
end -- finaliza function

vou ver se consigo fazer o npc para você

O rei de seu proprio destino é aquele que luta pela gloria do amanhã!
Discord : ZoR#9373


 

Link para o post
Compartilhar em outros sites
Agora, ZikaLord disse:

cara eu fiz um item


storage = 211100 -- storage checada 
local level = 100 -- level desejado
local item = 2545 -- item 1

function onUse(cid, item) -- função e parametros
if getPlayerLevel(cid) < level then -- level que ira verificar
	doPlayerSendTextMessage(cid, "Você não tem o level 100") -- mensagem caso não tenha o level necessario
elseif item == 2545 then -- verificando os item das variaveis (item e item2)
	doCreatureAddHealth(cid, 1000 * 1000) -- vida adicionda
	doCreatureAddMana(cid, 1000 * 1000) -- mana adicionada
	doPlayerSendTextMessage(cid, "Foi adicionado mana e vida a você") -- se não querer que essa msg apareca apague
elseif storage ~= 211100 then -- checando a storage
	doPlayerSendTextMessage(cid, "você não completou a missão dos buffs")	-- mensagem caso não tenha
	  end -- finaliza if
 return true 
end -- finaliza function

vou ver se consigo fazer o npc para você

 

ótima ideia do item mais preciso mesmo o npc

Obrigado!

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

@Maniaco Me desculpe se esqueci de alguma verificação hahaha.

 

Npc.lua

Spoiler

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

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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
	return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

local buff_str = 211100 -- Storage da missao dos buffs
local buff = { -- Configurações

	[1] = {
	
		health = 100, -- Vida
		mana = 100, -- Mana
		req_lvl = 10, -- Level necessário
		req_item = 2160, -- Item necessário
		storage = 23123123 -- Storage do buff
	},
	[2] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[3] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[3] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[4] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[5] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[6] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[7] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[8] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[9] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[10] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[11] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[12] = {
		
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	}
}


--
-- Não modifique NADA abaixo
--

local b1 = {

	health = buff[1].health,
	mana = buff[1].mana,
	lvl = buff[1].req_lvl,
	item = buff[1].req_item,
	str = buff[1].storage
}

local b2 = {

	health = buff[2].health,
	mana = buff[2].mana,
	lvl = buff[2].req_lvl,
	item = buff[2].req_item,
	str = buff[2].storage
}

local b3 = {

	health = buff[3].health,
	mana = buff[3].mana,
	lvl = buff[3].req_lvl,
	item = buff[3].req_item,
	str = buff[3].storage
}

local b4 = {

	health = buff[4].health,
	mana = buff[4].mana,
	lvl = buff[4].req_lvl,
	item = buff[4].req_item,
	str = buff[4].storage
}

local b5 = {

	health = buff[5].health,
	mana = buff[5].mana,
	lvl = buff[5].req_lvl,
	item = buff[5].req_item,
	str = buff[5].storage
}

local b6 = {

	health = buff[6].health,
	mana = buff[6].mana,
	lvl = buff[6].req_lvl,
	item = buff[6].req_item,
	str = buff[6].storage
}

local b7 = {

	health = buff[7].health,
	mana = buff[7].mana,
	lvl = buff[7].req_lvl,
	item = buff[7].req_item,
	str = buff[7].storage
}

local b8 = {

	health = buff[8].health,
	mana = buff[8].mana,
	lvl = buff[8].req_lvl,
	item = buff[8].req_item,
	str = buff[8].storage
}

local b9 = {

	health = buff[9].health,
	mana = buff[9].mana,
	lvl = buff[9].req_lvl,
	item = buff[9].req_item,
	str = buff[9].storage
}

local b10 = {

	health = buff[10].health,
	mana = buff[10].mana,
	lvl = buff[10].req_lvl,
	item = buff[10].req_item,
	str = buff[10].storage
}

local b11 = {

	health = buff[11].health,
	mana = buff[11].mana,
	lvl = buff[11].req_lvl,
	item = buff[11].req_item,
	str = buff[11].storage
}

local b12= {

	health = buff[12].health,
	mana = buff[12].mana,
	lvl = buff[12].req_lvl,
	item = buff[12].req_item,
	str = buff[12].storage
}

if (msgcontains(msg, "buffs")) then
	selfSay("Muito bem, escolha um dos buffs.", cid)
	selfSay("{Buff um}, {buff dois},{buff tres}, {buff cinco}, {buff seis}, {buff sete}, {buff oito}, {buff nove}, {buff dez}, {buff onze}, {buff doze}.", cid)
end

if (msgcontains(msg, "buff um")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b1.str) <= 0 then
			if getPlayerItemCount(cid, b1.item) >= 1 then
				if getPlayerLevel(cid) >= b1.lvl then
					setCreatureMaxHealth(cid, b1.health)
					setCreatureMaxMana(cid, b1.mana)
					doPlayerRemoveItem(cid, b1.item, 1)
					setPlayerStorageValue(cid, b1.str, 1)
					selfSay("Voce recebeu o buff um.", cid)
				else
					selfSay("Voce precisa de no minimo level "..b1.lvl..".", cid)
				end
			else
				selfSay("Voce nao possui 1 "..getItemNameById(b1.item)..".", cid)
			end
		else
			selfSay("Voce ja adquiriu este buff uma vez.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff dois")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b1.str) >= 1 then
			if getPlayerStorageValue(cid, b2.str) <= 0 then
				if getPlayerItemCount(cid, b2.item) >= 1 then
					if getPlayerLevel(cid) >= b2.lvl then
						setCreatureMaxHealth(cid, b2.health)
						setCreatureMaxMana(cid, b2.mana)
						doPlayerRemoveItem(cid, b2.item, 1)
						setPlayerStorageValue(cid, b2.str, 1)
						selfSay("Voce recebeu o buff dois.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b2.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b2.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff tres")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b2.str) >= 1 then
			if getPlayerStorageValue(cid, b3.str) <= 0 then
				if getPlayerItemCount(cid, b3.item) >= 1 then
					if getPlayerLevel(cid) >= b3.lvl then
						setCreatureMaxHealth(cid, b3.health)
						setCreatureMaxMana(cid, b3.mana)
						doPlayerRemoveItem(cid, b3.item, 1)
						setPlayerStorageValue(cid, b3.str, 1)
						selfSay("Voce recebeu o buff tres.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b3.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b3.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff quatro")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b3.str) >= 1 then
			if getPlayerStorageValue(cid, b4.str) <= 0 then
				if getPlayerItemCount(cid, b4.item) >= 1 then
					if getPlayerLevel(cid) >= b4.lvl then
						setCreatureMaxHealth(cid, b4.health)
						setCreatureMaxMana(cid, b4.mana)
						doPlayerRemoveItem(cid, b4.item, 1)
						setPlayerStorageValue(cid, b4.str, 1)
						selfSay("Voce recebeu o buff quatro.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b4.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b4.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff cinco")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b4.str) >= 1 then
			if getPlayerStorageValue(cid, b5.str) <= 0 then
				if getPlayerItemCount(cid, b5.item) >= 1 then
					if getPlayerLevel(cid) >= b5.lvl then
						setCreatureMaxHealth(cid, b5.health)
						setCreatureMaxMana(cid, b5.mana)
						doPlayerRemoveItem(cid, b5.item, 1)
						setPlayerStorageValue(cid, b5.str, 1)
						selfSay("Voce recebeu o buff cinco.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b5.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b5.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff seis")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b5.str) >= 1 then
			if getPlayerStorageValue(cid, b6.str) <= 0 then
				if getPlayerItemCount(cid, b6.item) >= 1 then
					if getPlayerLevel(cid) >= b6.lvl then
						setCreatureMaxHealth(cid, b6.health)
						setCreatureMaxMana(cid, b6.mana)
						doPlayerRemoveItem(cid, b6.item, 1)
						setPlayerStorageValue(cid, b6.str, 1)
						selfSay("Voce recebeu o buff seis.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b6.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b6.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff sete")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b6.str) >= 1 then
			if getPlayerStorageValue(cid, b7.str) <= 0 then
				if getPlayerItemCount(cid, b7.item) >= 1 then
					if getPlayerLevel(cid) >= b7.lvl then
						setCreatureMaxHealth(cid, b7.health)
						setCreatureMaxMana(cid, b7.mana)
						doPlayerRemoveItem(cid, b7.item, 1)
						setPlayerStorageValue(cid, b7.str, 1)
						selfSay("Voce recebeu o buff sete.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b7.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b7.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff oito")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b7.str) >= 1 then
			if getPlayerStorageValue(cid, b8.str) <= 0 then
				if getPlayerItemCount(cid, b8.item) >= 1 then
					if getPlayerLevel(cid) >= b8.lvl then
						setCreatureMaxHealth(cid, b8.health)
						setCreatureMaxMana(cid, b8.mana)
						doPlayerRemoveItem(cid, b8.item, 1)
						setPlayerStorageValue(cid, b8.str, 1)
						selfSay("Voce recebeu o buff oito.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b8.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b8.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff nove")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b8.str) >= 1 then
			if getPlayerStorageValue(cid, b9.str) <= 0 then
				if getPlayerItemCount(cid, b9.item) >= 1 then
					if getPlayerLevel(cid) >= b9.lvl then
						setCreatureMaxHealth(cid, b9.health)
						setCreatureMaxMana(cid, b9.mana)
						doPlayerRemoveItem(cid, b9.item, 1)
						setPlayerStorageValue(cid, b9.str, 1)
						selfSay("Voce recebeu o buff nove.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b9.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b9.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff dez")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b9.str) >= 1 then
			if getPlayerStorageValue(cid, b10.str) <= 0 then
				if getPlayerItemCount(cid, b10.item) >= 1 then
					if getPlayerLevel(cid) >= b10.lvl then
						setCreatureMaxHealth(cid, b10.health)
						setCreatureMaxMana(cid, b10.mana)
						doPlayerRemoveItem(cid, b10.item, 1)
						setPlayerStorageValue(cid, b10.str, 1)
						selfSay("Voce recebeu o buff dez.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b10.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b10.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff onze")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b10.str) >= 1 then
			if getPlayerStorageValue(cid, b11.str) <= 0 then
				if getPlayerItemCount(cid, b11.item) >= 1 then
					if getPlayerLevel(cid) >= b11.lvl then
						setCreatureMaxHealth(cid, b11.health)
						setCreatureMaxMana(cid, b11.mana)
						doPlayerRemoveItem(cid, b11.item, 1)
						setPlayerStorageValue(cid, b11.str, 1)
						selfSay("Voce recebeu o buff onze.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b11.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b11.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff doze")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b11.str) >= 1 then
			if getPlayerStorageValue(cid, b12.str) <= 0 then
				if getPlayerItemCount(cid, b12.item) >= 1 then
					if getPlayerLevel(cid) >= b12.lvl then
						setCreatureMaxHealth(cid, b12.health)
						setCreatureMaxMana(cid, b12.mana)
						doPlayerRemoveItem(cid, b12.item, 1)
						setPlayerStorageValue(cid, b12.str, 1)
						selfSay("Voce recebeu o buff doze.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b12.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b12.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
end

return true
end

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

 

 

Npc.xml

Spoiler

<?xml version="1.0" encoding="UTF-8"?>
<npc name="NOME DO NPC" script="SEU ARQUIVO.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="128" head="17" body="54" legs="114" feet="0" addons="2"/>
	<parameters>
		<parameter key="message_greet" value="Ola |PLAYERNAME|. Se veio ate mim deve estar atras de {buffs}, nao?"/>
	</parameters>
</npc>

 

 

Link para o post
Compartilhar em outros sites
2 horas atrás, JoviM disse:

@Maniaco Me desculpe se esqueci de alguma verificação hahaha.

 

Npc.lua

  Mostrar conteúdo oculto


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

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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
	return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

local buff_str = 211100 -- Storage da missao dos buffs
local buff = { -- Configurações

	[1] = {
	
		health = 100, -- Vida
		mana = 100, -- Mana
		req_lvl = 10, -- Level necessário
		req_item = 2160, -- Item necessário
		storage = 23123123 -- Storage do buff
	},
	[2] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[3] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[3] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[4] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[5] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[6] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[7] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[8] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[9] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[10] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[11] = {
	
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	},
	[12] = {
		
		health = 100,
		mana = 100,
		req_lvl = 10,
		req_item = 2160,
		storage = 123123123
	}
}


--
-- Não modifique NADA abaixo
--

local b1 = {

	health = buff[1].health,
	mana = buff[1].mana,
	lvl = buff[1].req_lvl,
	item = buff[1].req_item,
	str = buff[1].storage
}

local b2 = {

	health = buff[2].health,
	mana = buff[2].mana,
	lvl = buff[2].req_lvl,
	item = buff[2].req_item,
	str = buff[2].storage
}

local b3 = {

	health = buff[3].health,
	mana = buff[3].mana,
	lvl = buff[3].req_lvl,
	item = buff[3].req_item,
	str = buff[3].storage
}

local b4 = {

	health = buff[4].health,
	mana = buff[4].mana,
	lvl = buff[4].req_lvl,
	item = buff[4].req_item,
	str = buff[4].storage
}

local b5 = {

	health = buff[5].health,
	mana = buff[5].mana,
	lvl = buff[5].req_lvl,
	item = buff[5].req_item,
	str = buff[5].storage
}

local b6 = {

	health = buff[6].health,
	mana = buff[6].mana,
	lvl = buff[6].req_lvl,
	item = buff[6].req_item,
	str = buff[6].storage
}

local b7 = {

	health = buff[7].health,
	mana = buff[7].mana,
	lvl = buff[7].req_lvl,
	item = buff[7].req_item,
	str = buff[7].storage
}

local b8 = {

	health = buff[8].health,
	mana = buff[8].mana,
	lvl = buff[8].req_lvl,
	item = buff[8].req_item,
	str = buff[8].storage
}

local b9 = {

	health = buff[9].health,
	mana = buff[9].mana,
	lvl = buff[9].req_lvl,
	item = buff[9].req_item,
	str = buff[9].storage
}

local b10 = {

	health = buff[10].health,
	mana = buff[10].mana,
	lvl = buff[10].req_lvl,
	item = buff[10].req_item,
	str = buff[10].storage
}

local b11 = {

	health = buff[11].health,
	mana = buff[11].mana,
	lvl = buff[11].req_lvl,
	item = buff[11].req_item,
	str = buff[11].storage
}

local b12= {

	health = buff[12].health,
	mana = buff[12].mana,
	lvl = buff[12].req_lvl,
	item = buff[12].req_item,
	str = buff[12].storage
}

if (msgcontains(msg, "buffs")) then
	selfSay("Muito bem, escolha um dos buffs.", cid)
	selfSay("{Buff um}, {buff dois},{buff tres}, {buff cinco}, {buff seis}, {buff sete}, {buff oito}, {buff nove}, {buff dez}, {buff onze}, {buff doze}.", cid)
end

if (msgcontains(msg, "buff um")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b1.str) <= 0 then
			if getPlayerItemCount(cid, b1.item) >= 1 then
				if getPlayerLevel(cid) >= b1.lvl then
					setCreatureMaxHealth(cid, b1.health)
					setCreatureMaxMana(cid, b1.mana)
					doPlayerRemoveItem(cid, b1.item, 1)
					setPlayerStorageValue(cid, b1.str, 1)
					selfSay("Voce recebeu o buff um.", cid)
				else
					selfSay("Voce precisa de no minimo level "..b1.lvl..".", cid)
				end
			else
				selfSay("Voce nao possui 1 "..getItemNameById(b1.item)..".", cid)
			end
		else
			selfSay("Voce ja adquiriu este buff uma vez.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff dois")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b1.str) >= 1 then
			if getPlayerStorageValue(cid, b2.str) <= 0 then
				if getPlayerItemCount(cid, b2.item) >= 1 then
					if getPlayerLevel(cid) >= b2.lvl then
						setCreatureMaxHealth(cid, b2.health)
						setCreatureMaxMana(cid, b2.mana)
						doPlayerRemoveItem(cid, b2.item, 1)
						setPlayerStorageValue(cid, b2.str, 1)
						selfSay("Voce recebeu o buff dois.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b2.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b2.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff tres")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b2.str) >= 1 then
			if getPlayerStorageValue(cid, b3.str) <= 0 then
				if getPlayerItemCount(cid, b3.item) >= 1 then
					if getPlayerLevel(cid) >= b3.lvl then
						setCreatureMaxHealth(cid, b3.health)
						setCreatureMaxMana(cid, b3.mana)
						doPlayerRemoveItem(cid, b3.item, 1)
						setPlayerStorageValue(cid, b3.str, 1)
						selfSay("Voce recebeu o buff tres.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b3.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b3.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff quatro")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b3.str) >= 1 then
			if getPlayerStorageValue(cid, b4.str) <= 0 then
				if getPlayerItemCount(cid, b4.item) >= 1 then
					if getPlayerLevel(cid) >= b4.lvl then
						setCreatureMaxHealth(cid, b4.health)
						setCreatureMaxMana(cid, b4.mana)
						doPlayerRemoveItem(cid, b4.item, 1)
						setPlayerStorageValue(cid, b4.str, 1)
						selfSay("Voce recebeu o buff quatro.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b4.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b4.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff cinco")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b4.str) >= 1 then
			if getPlayerStorageValue(cid, b5.str) <= 0 then
				if getPlayerItemCount(cid, b5.item) >= 1 then
					if getPlayerLevel(cid) >= b5.lvl then
						setCreatureMaxHealth(cid, b5.health)
						setCreatureMaxMana(cid, b5.mana)
						doPlayerRemoveItem(cid, b5.item, 1)
						setPlayerStorageValue(cid, b5.str, 1)
						selfSay("Voce recebeu o buff cinco.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b5.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b5.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff seis")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b5.str) >= 1 then
			if getPlayerStorageValue(cid, b6.str) <= 0 then
				if getPlayerItemCount(cid, b6.item) >= 1 then
					if getPlayerLevel(cid) >= b6.lvl then
						setCreatureMaxHealth(cid, b6.health)
						setCreatureMaxMana(cid, b6.mana)
						doPlayerRemoveItem(cid, b6.item, 1)
						setPlayerStorageValue(cid, b6.str, 1)
						selfSay("Voce recebeu o buff seis.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b6.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b6.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff sete")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b6.str) >= 1 then
			if getPlayerStorageValue(cid, b7.str) <= 0 then
				if getPlayerItemCount(cid, b7.item) >= 1 then
					if getPlayerLevel(cid) >= b7.lvl then
						setCreatureMaxHealth(cid, b7.health)
						setCreatureMaxMana(cid, b7.mana)
						doPlayerRemoveItem(cid, b7.item, 1)
						setPlayerStorageValue(cid, b7.str, 1)
						selfSay("Voce recebeu o buff sete.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b7.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b7.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff oito")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b7.str) >= 1 then
			if getPlayerStorageValue(cid, b8.str) <= 0 then
				if getPlayerItemCount(cid, b8.item) >= 1 then
					if getPlayerLevel(cid) >= b8.lvl then
						setCreatureMaxHealth(cid, b8.health)
						setCreatureMaxMana(cid, b8.mana)
						doPlayerRemoveItem(cid, b8.item, 1)
						setPlayerStorageValue(cid, b8.str, 1)
						selfSay("Voce recebeu o buff oito.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b8.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b8.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff nove")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b8.str) >= 1 then
			if getPlayerStorageValue(cid, b9.str) <= 0 then
				if getPlayerItemCount(cid, b9.item) >= 1 then
					if getPlayerLevel(cid) >= b9.lvl then
						setCreatureMaxHealth(cid, b9.health)
						setCreatureMaxMana(cid, b9.mana)
						doPlayerRemoveItem(cid, b9.item, 1)
						setPlayerStorageValue(cid, b9.str, 1)
						selfSay("Voce recebeu o buff nove.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b9.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b9.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff dez")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b9.str) >= 1 then
			if getPlayerStorageValue(cid, b10.str) <= 0 then
				if getPlayerItemCount(cid, b10.item) >= 1 then
					if getPlayerLevel(cid) >= b10.lvl then
						setCreatureMaxHealth(cid, b10.health)
						setCreatureMaxMana(cid, b10.mana)
						doPlayerRemoveItem(cid, b10.item, 1)
						setPlayerStorageValue(cid, b10.str, 1)
						selfSay("Voce recebeu o buff dez.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b10.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b10.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff onze")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b10.str) >= 1 then
			if getPlayerStorageValue(cid, b11.str) <= 0 then
				if getPlayerItemCount(cid, b11.item) >= 1 then
					if getPlayerLevel(cid) >= b11.lvl then
						setCreatureMaxHealth(cid, b11.health)
						setCreatureMaxMana(cid, b11.mana)
						doPlayerRemoveItem(cid, b11.item, 1)
						setPlayerStorageValue(cid, b11.str, 1)
						selfSay("Voce recebeu o buff onze.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b11.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b11.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
elseif (msgcontains(msg, "buff doze")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, b11.str) >= 1 then
			if getPlayerStorageValue(cid, b12.str) <= 0 then
				if getPlayerItemCount(cid, b12.item) >= 1 then
					if getPlayerLevel(cid) >= b12.lvl then
						setCreatureMaxHealth(cid, b12.health)
						setCreatureMaxMana(cid, b12.mana)
						doPlayerRemoveItem(cid, b12.item, 1)
						setPlayerStorageValue(cid, b12.str, 1)
						selfSay("Voce recebeu o buff doze.", cid)
					else
						selfSay("Voce precisa de no minimo level "..b12.lvl..".", cid)
					end
				else
					selfSay("Voce nao possui 1 "..getItemNameById(b12.item)..".", cid)
				end
			else
				selfSay("Voce ja adquiriu este buff uma vez.", cid)
			end
		else
			selfSay("Voce precisa adquirir o buff anterior.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
end

return true
end

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

 

 

Npc.xml

  Ocultar conteúdo


<?xml version="1.0" encoding="UTF-8"?>
<npc name="NOME DO NPC" script="SEU ARQUIVO.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="128" head="17" body="54" legs="114" feet="0" addons="2"/>
	<parameters>
		<parameter key="message_greet" value="Ola |PLAYERNAME|. Se veio ate mim deve estar atras de {buffs}, nao?"/>
	</parameters>
</npc>

 

 

 

Bom Primeiramente gostaria de agradecer pelo trabalho todo que você teve para fazer o script do npc! (Tá enorme) desculpa ter dado todo esse trabalho!

então se n for muito difícil tem como colocar script nesse link ? https://pastebin.com/

Pois copiar diretamente do Fórum sempre vem um symbol indesejado!

image.png.5de166336f46bd08db7117b1f1c3d648.png

 

Obrigado mesmo vou fazer bom uso!

 

Link para o post
Compartilhar em outros sites
3 horas atrás, JoviM disse:

@Maniaco Relaxa mano, faço isso por que gosto...

Tenho até conta no pastebin mas não costumo usar AHSUAHS.

Tá aqui: https://pastebin.com/RV89Jmer

 

Perfeito Mano Funcionando certinho!!!! 

 

Muito Obrigado e desculpa pelo trabalho todo!

Link para o post
Compartilhar em outros sites
  • 2 months later...

@hiquezerah Qualquer erro ou dúvida só marcar.

Spoiler

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

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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
	return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

local buff_str = 211100 -- Storage da missao dos buffs
local buff = {

	health = 100, -- Vida
	mana = 100, -- Mana
	req_lvl = 10, -- Level necessário
	req_item = 2160, -- Item necessário
	storage = 23123123 -- Storage do buff
}

if (msgcontains(msg, "buff")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, buff.storage) <= 0 then
			if getPlayerItemCount(cid, buff.req_item) >= 1 then
				if getPlayerLevel(cid) >= buff.req_lvl then
					setCreatureMaxHealth(cid, buffbuff.health)
					setCreatureMaxMana(cid, buffbuff.mana)
					doPlayerRemoveItem(cid, buffbuff.req_item, 1)
					setPlayerStorageValue(cid, buffbuff.storage, 1)
					selfSay("Voce recebeu o buff um.", cid)
				else
					selfSay("Voce precisa de no minimo level "..buff.req_lvl..".", cid)
				end
			else
				selfSay("Voce nao possui 1 "..getItemNameById(buff.req_item)..".", cid)
			end
		else
			selfSay("Voce ja adquiriu este buff uma vez.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
	return true
end

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

 

 

Link para o post
Compartilhar em outros sites
4 horas atrás, JoviM disse:

@hiquezerah Qualquer erro ou dúvida só marcar.

  Ocultar conteúdo


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

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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
	return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

local buff_str = 211100 -- Storage da missao dos buffs
local buff = {

	health = 100, -- Vida
	mana = 100, -- Mana
	req_lvl = 10, -- Level necessário
	req_item = 2160, -- Item necessário
	storage = 23123123 -- Storage do buff
}

if (msgcontains(msg, "buff")) then
	if getPlayerStorageValue(cid, buff_str) >= 1 then
		if getPlayerStorageValue(cid, buff.storage) <= 0 then
			if getPlayerItemCount(cid, buff.req_item) >= 1 then
				if getPlayerLevel(cid) >= buff.req_lvl then
					setCreatureMaxHealth(cid, buffbuff.health)
					setCreatureMaxMana(cid, buffbuff.mana)
					doPlayerRemoveItem(cid, buffbuff.req_item, 1)
					setPlayerStorageValue(cid, buffbuff.storage, 1)
					selfSay("Voce recebeu o buff um.", cid)
				else
					selfSay("Voce precisa de no minimo level "..buff.req_lvl..".", cid)
				end
			else
				selfSay("Voce nao possui 1 "..getItemNameById(buff.req_item)..".", cid)
			end
		else
			selfSay("Voce ja adquiriu este buff uma vez.", cid)
		end
	else
		selfSay("Voce precisa completar a missao dos buffs.", cid)
	end
	return true
end

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

 

 

 

está dando esse erro na distro mano e muito obrigado por estar ajudando.

Screenshot_1.png

Link para o post
Compartilhar em outros sites

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.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.


  • Conteúdo Similar

    • Por ambrozii0
      Gostaria de fazer um pedido de um NPC de Task progressiva,

      Ele iniciaria dando missões para level 8 para caçar Troll, Rotworm e Ghoul.
       
      No level 30 liberaria: Cyclops, Dragon e Wyrm... e assim em diante se puder deixar comentado eu faço as criaturas na sequencia dos leveis seguintes.
       
      O jogador pode fazer as tasks dos leveis anteriores mesmo que já tenha ultrapassado o level do próximo nível de task.
       
      E o jogador ao terminar a missão poderia escolher a recompensa em gold ou experiência. As tasks podem se repetir sem problema, mas apenas pode pegar uma de cada vez.
       
      Ao finalizar todas as tasks o jogador ganha uma montaria.
       
      Minha versão de cliente é 12.91
      Versão da Canary 2.6.1
      Não sei qual o TFS do meu servidor.
    • Por Garou
      QUIZ







      Fala, grande reino! Tudo beleza?

      Eu estava aqui a deriva, sem nada para fazer, quando um colega me chamou no msn e pediu para eu revisar um código que ele havia feito para um NPC. A função era bem simples, o tal NPC iria fazer perguntas ao jogador que devia responder-las corretamente, caso errasse, duas criaturas configuráveis iriam aparecer.

      Quando eu dei uma olhada no código, tomei um grande susto, era algo caótico, tudo embaralhado. Se você quer dar uma olhada, tenha certeza de ter um coração forte.



      --[[ NPC de Perguntas e Respostas Criado por Bruno Lopes / Lpz &#169; 2011 TibiaKing ]]-- local focuses = {} local talk_start = 0 local topic = {} local var = 0 local quiz = { [1] = {"What is the ring of mana?", "energy ring"}, [2] = {"Who sells addons?", "raphael"} } local monster = {"Orc", 2} local prize = { question = 100, all = 10000 } function onCreatureSay(cid, type, msg) local msg = msg:lower() or "" if getNpcDistanceTo(cid) > 3 then return false end if doMessageCheck(msg, {"hi", "hello"}) and not(isFocused(cid, focuses)) then selfSay("Hello, ".. getCreatureName(cid) ..". Can you answer my questions? heh...", cid) addFocus(cid, focuses) selfFocus(cid) topic[cid] = 100 talk_start = os.clock() elseif doMessageCheck(msg, {"hi", "hello"}) and #focuses ~= 0 then selfSay("Sorry, ".. getCreatureName(cid) ..". I am talking with another person, wait!", cid) end if doMessageCheck(msg, {"bye", "farewell", "goodbye"}) and isFocused(cid, focuses) then selfSay("Bye-bye, hehe!", cid) removeFocus(cid, focuses) end if topic[cid] == 100 then if doMessageCheck(msg, "yes") then selfSay("To start my challenge, just say {ready}. I will ask you some questions.", cid) topic[cid] = 1 elseif doMessageCheck(msg, "no") then selfSay("Huh? Why are you here then?", cid) removeFocus(cid, focuses) topic[cid] = 0 end elseif topic[cid] == 1 then if var == 0 then if doMessageCheck(msg, "ready") then var = 1 selfSay(quiz[var][1], cid) end elseif var >= 1 then if var <= #quiz then if doMessageCheck(msg, quiz[var][2]) then selfSay("CORRECT!", cid) doPlayerAddMoney(cid, prize.question) var = var+1 if var > #quiz then selfSay("CONGRATULATIONS! YOU HAVE FINISHED ALL QUESTIONS!", cid) doPlayerAddMoney(cid, prize.all) else selfSay(quiz[var][1], cid) end else selfSay("YOU HAVE WRONG MY QUESTION! GUARDS, COME HERE!", cid) var = 0 topic[cid] = 0 removeFocus(cid, focuses) for i = 1, monster[2] do doCreateMonster(monster[1], getNpcPos()) end end end end end return true end function onThink() for _, cid in ipairs(focuses) do if isPlayer(cid) and isFocused(cid, focuses) then if os.clock() > (talk_start + 180) then talk_start = 0 selfSay("Hmph!") closeShopWindow(cid) removeFocus(cid, focuses) elseif getNpcDistanceTo(cid) > 3 then talk_start = 0 selfSay("How Rude!") closeShopWindow(cid) removeFocus(cid, focuses) end end end lookAtFocus(focuses) end Bom, eu fiz o arquivo .lua que você iria associar a algum npc de seu servidor, deixo o arquivo .xml por sua conta. Como é um NPC que faz perguntas, você pode configurar o seu NPC do jeito que você quiser, com as perguntas que você quiser. Veja abaixo como proceder: local quiz = { [1] = {"What is the ring of mana?", "energy ring"}, [2] = {"Who sells addons?", "raphael"} } Para adicionar novas perguntas, basta você colocar uma vírgula na última linha e criar uma nova linha conforme o modelo: local quiz = { [1] = {"What is the ring of mana?", "energy ring"}, [2] = {"Who sells addons?", "raphael"}, [3] = {"PERGUNTA", "RESPOSTA"}, [4] = {"PERGUNTA", "RESPOSTA"} } Há também algumas outras configurações básicas para você fazer, as criaturas que irão aparecer caso o jogador erre a pergunta e a quantidade. Também você pode configurar a quantidade de dinheiro que o jogador ganha quando acerta uma pergunta e a quantidade de dinheiro do prêmio final. local monster = {"Orc", 2} local prize = { question = 100, all = 10000 } OBSERVAÇÕES Para evitar quaisquer erros no script, substitua o conteúdo de npc.lua em data/npc/lib por este que estou passando abaixo:



      É isso aê, galerinha do tibiaKing!

      Até o próximo tópico.
    • Por Codex NG
      Sorry I don't speak spanish so you will have to bare with me.
       
      This is a new way for people to create npc's which use different types of currency, rather than a coming up with different items to trade with the npc or trying to edit the npc modules this method simplifies everything by providing the npc with a npc currency id.
       
      All this npc currency id is, is a storage value.. pretty simple eh?
      If the npc doesn't have a currency id then it will use the normal currency e.g. gold, plat, cc etc..
       
      I originally posted this on otland, but fuck them xD
       
      Using Lailene here you can see she has a currency attribute with id of 123456
      <?xml version="1.0" encoding="UTF-8"?> <npc name="Lailene" currency="123456" script="lailene.lua" walkinterval="2000" floorchange="0" speechbubble="2"> <health now="100" max="100"/> <look type="279" head="114" body="94" legs="113" feet="114" addons="0"/> </npc>  
      Now any player who has a storage value of 123456 can purchase things from her shop provided they have enough value stored within the storage, similar to having money in the bank.
      The money or in this case the storage value is added and removed from the player in real time.
       
      Lets get to the code
       
      game.cpp
      Find this
      bool Game::removeMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) Replace the whole function with this.
      bool Game::removeMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) { if (cylinder == nullptr) { return false; } if (money == 0) { return true; } uint32_t currencyId = 0; Player* player; if (Creature* creature = cylinder->getCreature()) { if (Player* p = creature->getPlayer()) { currencyId = p->getNpcCurrencyId(); player = p; } } if (!currencyId) { std::vector<Container*> containers; std::multimap<uint32_t, Item*> moneyMap; uint64_t moneyCount = 0; for (size_t i = cylinder->getFirstIndex(), j = cylinder->getLastIndex(); i < j; ++i) { Thing* thing = cylinder->getThing(i); if (!thing) { continue; } Item* item = thing->getItem(); if (!item) { continue; } Container* container = item->getContainer(); if (container) { containers.push_back(container); } else { const uint32_t worth = item->getWorth(); if (worth != 0) { moneyCount += worth; moneyMap.emplace(worth, item); } } } size_t i = 0; while (i < containers.size()) { Container* container = containers[i++]; for (Item* item : container->getItemList()) { Container* tmpContainer = item->getContainer(); if (tmpContainer) { containers.push_back(tmpContainer); } else { const uint32_t worth = item->getWorth(); if (worth != 0) { moneyCount += worth; moneyMap.emplace(worth, item); } } } } if (moneyCount < money) { return false; } for (const auto& moneyEntry : moneyMap) { Item* item = moneyEntry.second; if (moneyEntry.first < money) { internalRemoveItem(item); money -= moneyEntry.first; } else if (moneyEntry.first > money) { const uint32_t worth = moneyEntry.first / item->getItemCount(); const uint32_t removeCount = (money / worth) + 1; addMoney(cylinder, (worth * removeCount) - money, flags); internalRemoveItem(item, removeCount); break; } else { internalRemoveItem(item); break; } } } else { int32_t value; player->getStorageValue(currencyId, value); if (value < money) { return false; } player->addStorageValue(currencyId, value - money); } return true; } Next find this
      void Game::addMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) Replace the whole function with this
      void Game::addMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) { if (money == 0) { return; } if (Creature* creature = cylinder->getCreature()) { if (Player* player = creature->getPlayer()) { if(uint32_t currencyId = player->getNpcCurrencyId()){ int32_t value; player->getStorageValue(currencyId, value); player->addStorageValue(currencyId, value + money); return; } } } uint32_t crystalCoins = money / 10000; money -= crystalCoins * 10000; while (crystalCoins > 0) { const uint16_t count = std::min<uint32_t>(100, crystalCoins); Item* remaindItem = Item::CreateItem(ITEM_CRYSTAL_COIN, count); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if (ret != RETURNVALUE_NOERROR) { internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); } crystalCoins -= count; } uint16_t platinumCoins = money / 100; if (platinumCoins != 0) { Item* remaindItem = Item::CreateItem(ITEM_PLATINUM_COIN, platinumCoins); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if (ret != RETURNVALUE_NOERROR) { internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); } money -= platinumCoins * 100; } if (money != 0) { Item* remaindItem = Item::CreateItem(ITEM_GOLD_COIN, money); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if (ret != RETURNVALUE_NOERROR) { internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); } } }  
      npc.cpp
      Look for this
      pugi::xml_attribute attr; if ((attr = npcNode.attribute("speed"))) { baseSpeed = pugi::cast<uint32_t>(attr.value()); } else { baseSpeed = 100; } Right underneath that you are going to place this.
      if ((attr = npcNode.attribute("currency"))) { currency = pugi::cast<uint32_t>(attr.value()); }  
      npc.h
      Look for this
      bool isPushable() const final { return walkTicks > 0; } Place this right underneath
      uint32_t getCurrencyId() const { return currency; } Look for this
      uint32_t walkTicks; Place this right underneath
      uint32_t currency;  
      player.cpp
      Find this
      void Player::openShopWindow(Npc* npc, const std::list<ShopInfo>& shop) Replace that function with this
      void Player::openShopWindow(Npc* npc, const std::list<ShopInfo>& shop) { shopItemList = shop; sendShop(npc); sendSaleItemList(npc); } Next find this
      bool Player::updateSaleShopList(const Item* item) Replace that function with this
      bool Player::updateSaleShopList(const Item* item) { uint16_t itemId = item->getID(); if (itemId != ITEM_GOLD_COIN && itemId != ITEM_PLATINUM_COIN && itemId != ITEM_CRYSTAL_COIN) { auto it = std::find_if(shopItemList.begin(), shopItemList.end(), [itemId](const ShopInfo& shopInfo) { return shopInfo.itemId == itemId && shopInfo.sellPrice != 0; }); if (it == shopItemList.end()) { const Container* container = item->getContainer(); if (!container) { return false; } const auto& items = container->getItemList(); return std::any_of(items.begin(), items.end(), [this](const Item* containerItem) { return updateSaleShopList(containerItem); }); } } if (client) { client->sendSaleItemList(shopOwner, shopItemList); } return true; } Next you are going to look for
      uint64_t Player::getMoney() const Now right underneath that function you are going to place these.
      uint64_t Player::getMoney(Npc* npc) const { uint64_t cash; setNpcCurrencyId(npc); uint32_t currencyId = getNpcCurrencyId(); if (currencyId) { int32_t value; getStorageValue(currencyId, value); cash = (uint64_t)value; } else { cash = getMoney(); } return cash; } void Player::setNpcCurrencyId(Npc* npc) const{ currencyId = npc->getCurrencyId(); } uint32_t Player::getNpcCurrencyId() const { return currencyId; }  
      player.h
      Look for this
      uint64_t getMoney() const; Place this right underneath
      uint64_t getMoney(Npc*) const; void setNpcCurrencyId(Npc*) const; uint32_t getNpcCurrencyId() const; Find this
      void sendShop(Npc* npc) const { if (client) { client->sendShop(npc, shopItemList); } } Place this right underneath
      void sendSaleItemList(Npc* npc) const { if (client) { client->sendSaleItemList(npc, shopItemList); } } Find this
      uint32_t manaMax; Place this right underneath
      mutable uint32_t currencyId;  
      protocolgame.cpp
      Now find this function
      void ProtocolGame::sendSaleItemList(const std::list<ShopInfo>& shop) Place this right underneath
      void ProtocolGame::sendSaleItemList(Npc* npc, const std::list<ShopInfo>& shop) { NetworkMessage msg; msg.addByte(0x7B); msg.add<uint64_t>(player->getMoney(npc)); std::map<uint16_t, uint32_t> saleMap; if (shop.size() <= 5) { // For very small shops it's not worth it to create the complete map for (const ShopInfo& shopInfo : shop) { if (shopInfo.sellPrice == 0) { continue; } int8_t subtype = -1; const ItemType& itemType = Item::items[shopInfo.itemId]; if (itemType.hasSubType() && !itemType.stackable) { subtype = (shopInfo.subType == 0 ? -1 : shopInfo.subType); } uint32_t count = player->getItemTypeCount(shopInfo.itemId, subtype); if (count > 0) { saleMap[shopInfo.itemId] = count; } } } else { // Large shop, it's better to get a cached map of all item counts and use it // We need a temporary map since the finished map should only contain items // available in the shop std::map<uint32_t, uint32_t> tempSaleMap; player->getAllItemTypeCount(tempSaleMap); // We must still check manually for the special items that require subtype matches // (That is, fluids such as potions etc., actually these items are very few since // health potions now use their own ID) for (const ShopInfo& shopInfo : shop) { if (shopInfo.sellPrice == 0) { continue; } int8_t subtype = -1; const ItemType& itemType = Item::items[shopInfo.itemId]; if (itemType.hasSubType() && !itemType.stackable) { subtype = (shopInfo.subType == 0 ? -1 : shopInfo.subType); } if (subtype != -1) { uint32_t count; if (!itemType.isFluidContainer() && !itemType.isSplash()) { count = player->getItemTypeCount(shopInfo.itemId, subtype); // This shop item requires extra checks } else { count = subtype; } if (count > 0) { saleMap[shopInfo.itemId] = count; } } else { std::map<uint32_t, uint32_t>::const_iterator findIt = tempSaleMap.find(shopInfo.itemId); if (findIt != tempSaleMap.end() && findIt->second > 0) { saleMap[shopInfo.itemId] = findIt->second; } } } } uint8_t itemsToSend = std::min<size_t>(saleMap.size(), std::numeric_limits<uint8_t>::max()); msg.addByte(itemsToSend); uint8_t i = 0; for (std::map<uint16_t, uint32_t>::const_iterator it = saleMap.begin(); i < itemsToSend; ++it, ++i) { msg.addItemId(it->first); msg.addByte(std::min<uint32_t>(it->second, std::numeric_limits<uint8_t>::max())); } writeToOutputBuffer(msg); }  
      protocolgame.h
      Find this
      void sendSaleItemList(const std::list<ShopInfo>& shop); Place this right underneath
      void sendSaleItemList(Npc* npc, const std::list<ShopInfo>& shop);  
      luascript.cpp
      Find
      int LuaScriptInterface::luaPlayerAddMoney(lua_State* L) Replace that whole function with this
      int LuaScriptInterface::luaPlayerAddMoney(lua_State* L) { // player:addMoney(money[, currencyId]) uint64_t money = getNumber<uint64_t>(L, 2); uint32_t currencyId = getNumber<uint32_t>(L, 3); Player* player = getUserdata<Player>(L, 1); if (player) { if (currencyId) { int32_t value; player->getStorageValue(currencyId, value); player->addStorageValue(currencyId, value + money); } else { g_game.addMoney(player, money); } pushBoolean(L, true); } else { lua_pushnil(L); } return 1; } Next find this function which should be right below it.
      int LuaScriptInterface::luaPlayerRemoveMoney(lua_State* L) Replace that whole function with this
      int LuaScriptInterface::luaPlayerRemoveMoney(lua_State* L) { // player:removeMoney(money[, currencyId]) Player* player = getUserdata<Player>(L, 1); if (player) { uint64_t money = getNumber<uint64_t>(L, 2); uint32_t currencyId = getNumber<uint32_t>(L, 3); if (currencyId) { int32_t value; player->getStorageValue(currencyId, value); if (value < money) { pushBoolean(L, false); return 1; } player->addStorageValue(currencyId, value - money); pushBoolean(L, true); } else { pushBoolean(L, g_game.removeMoney(player, money)); } } else { lua_pushnil(L); } return 1; }  
    • Por MatteusDeli
      Olá Tibianos do Tibia King. (Vou direto para o script) 
       
      Vamos lá: Vá até a pasta data/npc copie e cole algum arquivo XML renomeie para stoned.xml e substitua por isto: (OBS esse é o NPC 1, vocações Paladin, Druid e Sorcerer)
       
       
      Em Roxo você pode alterar o looktype dele e o nome (Entre aspas). -- Não é obrigatório alterar isso--
       
      Agora volte para a pasta data/npc e copie e cole outro arquivo XML e renomeie para stonedkina.xml e substitua por isto:
       
       
      (--Mesma coisa do anterior --)
      Em Roxo você pode alterar o looktype dele e o nome (Entre aspas). -- Não é obrigatório alterar isso--
       
      ----SCRIPT DO NPC DE PALADIN, SORCERER E DRUID----
       
      Vá na pasta data/npc/scripts copie e cole algum arquivo, renomeie para stoned.lua e cole isso dentro:
       
       
      Em Verde é o ID dos itens que o player vai precisar para ganhar a quantidade de skill.
      Em Azul são os efeitos que vai aparecer embaixo do Player. Se quiser deixe com esses efeitos mesmo :D ---(Os efeitos vão de 1 a 68, caso queira vê-los apenas digite /z 1.. 68 com o GOD)
      Em Laranja é a quantidade de EXP de skill o Player vai ganhar ao entregar o ITEM. (Eu aconselho não colocar numero exorbitante como 9999999, pode acontecer de o script travar pela quantidade de skill adicionada).
      Em Vermelho é a quantidade do ITEM que ele vai precisar ter. (Caso for itens como Armors, Legs, Swords, Axes etc... Deixe 1 se for itens agrupáveis como TALONS, SCARAB COINS etc... Você pode colocar de 1 até 100).
       
      -----SCRIPT DO NPC DE KNIGHT------
       
      Vá na pasta data/npc/scripts copie e cole algum arquivo, renomeie para stonedkina.lua e cole isso dentro:
       
       
      <-> As Configurações são as mesmas <->
       
      Em Verde é o ID dos itens que o player vai precisar para ganhar a quantidade de skill.
      Em Azul é o efeito que vai aparecer embaixo do Player. Se quiser deixe com esses efeitos mesmo :D ---(Os efeitos vão de 1 a 68, caso queira vê-los apenas digite /z 1.. 68 com o GOD)
      Em Laranja é a quantidade de EXP de skill o Player vai ganhar ao entregar o ITEM. (Eu aconselho não colocar numero exorbitante como 9999999, pode acontecer de o script travar pela quantidade de skill adicionada).
      Em Vermelho é a quantidade do ITEM que ele vai precisar ter. (Caso for itens como Armors, Legs, Swords, Axes etc... Deixe 1 se for itens agrupáveis como TALONS, SCARAB COINS etc... Você pode colocar de 1 até 100).
       
      Por fim é só Importar os NPC'S pelo mapa Editor e adicionar! :D
       
      Obrigado e Bom uso do script!!!
       
       
    • Por Ayron5
      Antes de tudo quero deixar claro que pesquisei no fórum, Não encontrei. Resolvi fazer o meu  
      Este NPC faz oq o titulo diz  vende Stone ou Item por Diamond. Npc simples e configurável  Testado em Poketibia 8.54  tfs 0.3.6 
       
      Em data/npc, coloque um novo arquivo com o nome Ditem.xml e cole isso dentro:
       
      Na pasta data/npc/script, crie um arquivo chamado "Ditem.lua" e cole isso:
       
      Para adicionar mais itens:
       
      1º -  adiciona o nome do item para o player falar o nome dele, caso queira comprar - 
      selfSay('Eu vendo Fire stone, Water stone, Leaf stone. Diga qual voce quer adquirir.', cid) 2º - Após o ultimo 
      talkState[talkUser] = 3 Vc adiciona isso - 
      elseif(msgcontains(msg, '----NOME DO ITEM----') or msgcontains(msg, '---nome do item---')) then selfSay('O item Custa 3 Diamonds, Voce vai querer?', cid) talkState[talkUser] = 4 ----- Aqui coloca 4 pq ja tem a 3 3º - Na parte de  -- Confirmação da Compra -- Depois de  um      
      talkState[talkUser] = 0 end Adicione --  elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then ---Coloque 4 por causa da ---talkState[talkUser] = 4--- if(doPlayerRemoveItem(cid, 2145, 3) == true) then ----Item q sera removido no caso 2145 Diamonds e 3 é a quantidade. selfSay('Thanks!', cid) doPlayerAddItem(cid, 11447, 1) ----- 11447 é o item q será entregue no caso é a fire stone, o 1 é a quantidade de itens. talkState[talkUser] = 0 else selfSay('Voce nao tem diamonds suficiente.', cid) talkState[talkUser] = 0 end Bom é isso espero ajudar alguém rsrsrs  
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo