Ir para conteúdo

Featured Replies

  • Respostas 12
  • Visualizações 715
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • mendigo.lua  local table = { stg = 99487, -- Não mudar cost = 1000, -- Quantia a ser doada pos = {x = xxxx, y = xxx, z = x} -- Pos que vai ser teleportado onde vai encontrar o outro NPC } local

  • local table = { stg = 99487, -- Não mudar stg2 = 99488, -- Não mudar itemid = 3184 -- Id do item que irá ganhar } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:n

  • Bruno Minervino
    Bruno Minervino

    Conforme nosso amigo Summ postou, eu fiz uma versão que ele pede esmola pra quem passa, segue: http://www.tibiaking.com/forum/topic/50904-npc-mendigo/   Abraço!

Postado

mendigo.lua 

local table = {
	stg = 99487, -- Não mudar	
	cost = 1000, -- Quantia a ser doada
	pos = {x = xxxx, y = xxx, z = x} -- Pos que vai ser teleportado onde vai encontrar o outro NPC
}

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

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
	
	
		if getPlayerStorageValue(cid, table.stg) > 0 then
			npcHandler:say('Obrigado amigo de bom coracao, voce ja me ajudou.', cid)
			return true
		else
		if msgcontains(msg, 'ajudar') then
			npcHandler:say('Voce teria '..table.cost..' gps pra me ajudar ?', cid)
			npcHandler.topic[cid] = 1
		
		elseif msgcontains(msg, 'sim') and npcHandler.topic[cid] == 1 then
			if doPlayerRemoveMoney(cid, table.cost) then
				npcHandler:say('Obrigado!', cid)
				doTeleportThing(cid, table.pos)
				setPlayerStorageValue(cid, table.stg, 1)
			else
				npcHandler:say('Voce tem pouco dinheiro! Melhor guardar, para não passar pela minha situacao', cid)
			end
			npcHandler.topic[cid] = 0
		elseif msgcontains(msg, 'nao') then
			npcHandler.topic[cid] = 0
			npcHandler:say('Espero que voce nunca precise de ajuda.', cid)
		end
	end
	
	return true
end

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

mendigo.xml

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Mendigo" script="data/npc/scripts/mendigo.lua" walkinterval="25" floorchange="0" access="5" lookdir="1" >
    <health now="150" max="150"/>
    <look type="133" head="95" body="86" legs="86" feet="38" addons="3"/>
    
    <parameters>
        <parameter key="message_greet" value="Ola |PLAYERNAME|! Voce pode me {ajudar}?"/>
    </parameters>
	
	<voices interval="10">
		<voice text="Sera que alguma pessoa poderia me ajudar?" yell="0"/>
	</voices>
</npc>

rico.lua

local table = {

		stg = 99487, -- Não mudar
		stg2 = 99488, -- Não mudar
		itemid = xxxx -- Id do item que irá ganhar
		
}

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

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
	
			if getPlayerStorageValue(cid, table.stg) > 0 then							
				if getPlayerStorageValue(cid, table.stg2) < 1 then
					if msgcontains(msg, 'mendigo') then
						npcHandler:say('Ah é você amigo, eu era aquele mendigo sim, aconteceu varias coisas e aqui estou hahaha... brincadeiras a parte, tenho {algo} pra te dar por ter me ajudado', cid)
						npcHandler.topic[cid] = 1
		
					elseif msgcontains(msg, 'algo') npcHandler.topic == 1 then
						npcHandler:say('Sim, faça bom proveito disso.')
						doPlayerAddItem(cid, table.itemid, 1)
						setPlayerStorageValue(cid, table.stg2, 1)
					end
				else
					npcHandler:say('Foi muito bom te conhecer cara, te considero até hoje')
					npcHandler.topic[cid] = 0
				end
			else
				npcHandler:say('Nem te conheço cara... vá embora')
				npcHandler.topic[cid] = 0
			end
	return true
end
					
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())				
						
					

rico.xml

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Rico" script="data/npc/scripts/rico.lua" walkinterval="25" floorchange="0" access="5" lookdir="1" >
    <health now="150" max="150"/>
    <look type="133" head="95" body="86" legs="86" feet="38" addons="3"/>
    
    <parameters>
        <parameter key="message_greet" value="Ola |PLAYERNAME|! Se eu te fala-se que eu era um mendigo tu acreditaria ?"/>
    </parameters>
	
</npc>

Configurações :

 

mendigo.lua = pos = {x = xxxx, y = xxx, z = x} -- Pos que vai ser teleportado onde vai encontrar o outro NPC

 

rico.lua = itemid = xxxx -- Id do item que irá ganhar

 

 

 

 

 

 

 

Agradecimentos ao Bruno Minervino por ter me ajudado e ensinado.

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

EQD4Qy4.gif

Postado
  • Autor

Vlw mais não esqueça de colocar meus creditos pela ideia ^^ 


mendigo.lua 

local table = {
	stg = 99487, -- Não mudar	
	cost = 1000, -- Quantia a ser doada
	pos = {x = xxxx, y = xxx, z = x} -- Pos que vai ser teleportado onde vai encontrar o outro NPC
}

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

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
	
	
		if getPlayerStorageValue(cid, table.stg) > 0 then
			npcHandler:say('Obrigado amigo de bom coracao, voce ja me ajudou.', cid)
			return true
		else
		if msgcontains(msg, 'ajudar') then
			npcHandler:say('Voce teria '..table.cost..' gps pra me ajudar ?', cid)
			npcHandler.topic[cid] = 1
		
		elseif msgcontains(msg, 'sim') and npcHandler.topic[cid] == 1 then
			if doPlayerRemoveMoney(cid, table.cost) then
				npcHandler:say('Obrigado!', cid)
				doTeleportThing(cid, table.pos)
				setPlayerStorageValue(cid, table.stg, 1)
			else
				npcHandler:say('Voce tem pouco dinheiro! Melhor guardar, para não passar pela minha situacao', cid)
			end
			npcHandler.topic[cid] = 0
		elseif msgcontains(msg, 'nao') then
			npcHandler.topic[cid] = 0
			npcHandler:say('Espero que voce nunca precise de ajuda.', cid)
		end
	end
	
	return true
end

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

mendigo.xml

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Mendigo" script="data/npc/scripts/mendigo.lua" walkinterval="25" floorchange="0" access="5" lookdir="1" >
    <health now="150" max="150"/>
    <look type="133" head="95" body="86" legs="86" feet="38" addons="3"/>
    
    <parameters>
        <parameter key="message_greet" value="Ola |PLAYERNAME|! Voce pode me {ajudar}?"/>
    </parameters>
	
	<voices interval="10">
		<voice text="Sera que alguma pessoa poderia me ajudar?" yell="0"/>
	</voices>
</npc>

rico.lua

local table = {

		stg = 99487, -- Não mudar
		stg2 = 99488, -- Não mudar
		itemid = xxxx -- Id do item que irá ganhar
		
}

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

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
	
			if getPlayerStorageValue(cid, table.stg) > 0 then							
				if getPlayerStorageValue(cid, table.stg2) < 1 then
					if msgcontains(msg, 'mendigo')
						npcHandler:say('Ah é você amigo, eu era aquele mendigo sim, aconteceu varias coisas e aqui estou hahaha... brincadeiras a parte, tenho {algo} pra te dar por ter me ajudado', cid)
						npcHandler.topic[cid] = 1
		
					elseif msgcontains(msg, 'algo') npcHandler.topic == 1 then
						npcHandler:say('Sim, faça bom proveito disso.')
						doPlayerAddItem(cid, table.itemid, 1)
						setPlayerStorageValue(cid, table.stg2, 1)
					end
				else
					npcHandler:say('Foi muito bom te conhecer cara, te considero até hoje')
					npcHandler.topic[cid] = 0
				end
			else
				npcHandler:say('Nem te conheço cara... vá embora')
				npcHandler.topic[cid] = 0
			end
	return true
end
					
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())				
						
					

rico.xml

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Rico" script="data/npc/scripts/rico.lua" walkinterval="25" floorchange="0" access="5" lookdir="1" >
    <health now="150" max="150"/>
    <look type="133" head="95" body="86" legs="86" feet="38" addons="3"/>
    
    <parameters>
        <parameter key="message_greet" value="Ola |PLAYERNAME|! Se eu te fala-se que eu era um mendigo tu acreditaria ?"/>
    </parameters>
	
</npc>

Configurações :

 

mendigo.lua = pos = {x = xxxx, y = xxx, z = x} -- Pos que vai ser teleportado onde vai encontrar o outro NPC

 

rico.lua = itemid = xxxx -- Id do item que irá ganhar

 

 

 

 

 

 

 

Agradecimentos ao Bruno Minervino por ter me ajudado e ensinado.

o npc mendigo funcionou tudo direitinho mais o npc rico não esta sendo sumonado no /n fica dando este erro :

 

[31/01/2015 23:21:08] [Error - LuaScriptInterface::loadFile] data/npc/scripts/rico.lua:29: 'then' expected near 'npcHandler'
[31/01/2015 23:21:08] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/rico.lua
[31/01/2015 23:21:08] data/npc/scripts/rico.lua:29: 'then' expected near 'npcHandler'

wq3bBzt.png
Pokémon Dust Evolution
 
É aonde começa sua nova aventura!! 

 

Facebook

 
Verifique Atualizações

 

Participe da conversa

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

Visitante
Responder

Quem Está Navegando 0

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

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo