Ir para conteúdo
  • 0

[Pedido] Gostaria de um Npc que de Outfit por x item


kaleudd

Pergunta

como diz o titulo do topico,gostaria de um npc que dá x outfit por x item [Configuraveis] 7

Ex:

 

Player:Hi

NPC:Olá,diga outfits para ver todas as outfits a venda.

Player:outfits

npc:Bem tenho as seguintes Outfits,Gengar,Blastoise,Pikachu e Azumaril,escolha uma e repita o nome da escolhida.

Player:Gengar

Npc:Você comprou a outfit Gengar,parabens.

Player:Bye.

Npc:Tchau.

 

Mais ou menos isso,obg!

 

Link para o comentário
Compartilhar em outros sites

13 respostass a esta questão

Posts Recomendados

  • 0

Tente:

 

 

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 outs = {
["outfit_name1"] = {Storage_Outfit1, Preço},
["outfit_name2"] = {Storage_Outfit2, Preço},
}
msg = string.lower(msg)
local diamond = ID_DO_ITEM
if (msgcontains(msg, 'outfit') or msgcontains(msg, 'outfits')) then
selfSay("I sell these clothes: {Outfit_name1} and {Outfit_name2}, what you want?", cid)
talkState[talkUser] = 2
elseif outs[msg] and talkState[talkUser] == 2 then
selfSay("Are you sure you want to buy this outfit?", cid)
outfit = outs[tostring(msg)]
talkState[talkUser] = 3
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
if getPlayerStorageValue(cid, outfit[1]) <= 0 then
if outfit[2] then
if doPlayerRemoveItem(cid, diamond, outfit[2]) then
setPlayerStorageValue(cid, outfit[1], 1)
else
selfSay("You need ".. outfit[2] .." Diamonds to buy that clothe!", cid)
talkState[talkUser] = 0
return false
end
else
if getPlayerMoney(cid) >= 20000 then
doPlayerRemoveMoney(cid, 20000)
setPlayerStorageValue(cid, outfit[1], 1)
else
selfSay("Voce precisa 200dl para comprar essa roupa!", cid) -- Ignore
talkState[talkUser] = 0
return false
end
end
else
selfSay("You already have that outfit, please choose another outfit...", cid)
talkState[talkUser] = 0
return false
end
selfSay("Ok... Here it is.", cid)
talkState[talkUser] = 0
return true
elseif msgcontains(msg, 'no') and talkState[talkUser] == 3 then
selfSay("So... Please choose another outfit...", cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Editado por AdminGabriel
Link para o comentário
Compartilhar em outros sites

  • 0

[09/08/2015 19:42:46] [Error - LuaScriptInterface::loadFile] data/npc/scripts/out.lua:1: unexpected symbol near 'ï'
[09/08/2015 19:42:46] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/out.lua
[09/08/2015 19:42:46] data/npc/scripts/out.lua:1: unexpected symbol near 'ï'

Link para o comentário
Compartilhar em outros sites

  • 0

mesmo problema,quando dou /n Toms

 

[09/08/2015 21:03:15] [Error - LuaScriptInterface::loadFile] data/npc/scripts/out.lua:1: unexpected symbol near 'ï'
[09/08/2015 21:03:15] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/out.lua
[09/08/2015 21:03:15] data/npc/scripts/out.lua:1: unexpected symbol near 'ï'

Link para o comentário
Compartilhar em outros sites

  • 0


 

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 outs = {

["outfit_name1"] = {Storage_Outfit1, Preço},

["outfit_name2"] = {Storage_Outfit2, Preço},

}

msg = string.lower(msg)

local diamond = ID_DO_ITEM

 

 

if (msgcontains(msg, 'outfit') or msgcontains(msg, 'outfits')) then

selfSay("I sell these clothes: {Outfit_name1} and {Outfit_name2}, what you want?", cid)

talkState[talkUser] = 2

elseif outs[msg] and talkState[talkUser] == 2 then

selfSay("Are you sure you want to buy this outfit?", cid)

outfit = outs[tostring(msg)]

talkState[talkUser] = 3

elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then

if getPlayerStorageValue(cid, outfit[1]) <= 0 then

if outfit[2] then

if doPlayerRemoveItem(cid, diamond, outfit[2]) then

setPlayerStorageValue(cid, outfit[1], 1)

else

selfSay("You need ".. outfit[2] .." Diamonds to buy that clothe!", cid)

talkState[talkUser] = 0

return false

end

else

if getPlayerMoney(cid) >= 20000 then

doPlayerRemoveMoney(cid, 20000)

setPlayerStorageValue(cid, outfit[1], 1)

else

selfSay("Voce precisa 200dl para comprar essa roupa!", cid) -- Ignore

talkState[talkUser] = 0

return false

end

end

else

selfSay("You already have that outfit, please choose another outfit...", cid)

talkState[talkUser] = 0

return false

end

selfSay("Ok... Here it is.", cid)

talkState[talkUser] = 0

return true

elseif msgcontains(msg, 'no') and talkState[talkUser] == 3 then

selfSay("So... Please choose another outfit...", cid)

talkState[talkUser] = 0

end

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

 

Link para o comentário
Compartilhar em outros sites

  • 0
["outfit_name1"] = {Storage_Outfit1, Preço},

Em outfit_name1, você coloca nome da outfit com todas letras minúsculas;

Em Storage_Outfit1, você coloca a storage da outfit no seu outfits.xml na pasta XML, ou seja, o tag da outfit precisa estar com quest="181613"> com storage diferente;

<outfit id="47" quest="181644">
<list gender="0" lookType="1414" name="Catcher"/>
<list gender="1" lookType="1413" name="Catcher"/>
</outfit> 

E em Preço, já ta na cara.

 

Depois,

Se for por diamonds, você deixa assim:

local diamond = 2145

Caso não seja, troque o ID.

 

Depois,

Aqui você coloca o nome da outfit que irá aparecer na fala do npc:

I sell these clothes: {Outfit_name1} and {Outfit_name2}, what you want?

Exemplo:

local outs = {
["charizard"] = {123456, 10},
["blastoise"] = {654321, 10},
}
msg = string.lower(msg)
local diamond = 2145
 
   
   if (msgcontains(msg, 'outfit') or msgcontains(msg, 'outfits')) then
  selfSay("I sell these clothes: {Charizard} and {Blastoise}, what you want?", cid)

Para adicionar mais outfits na fala do npc, basta deixar assim:

{Charizard}, {Blastoise} and {Venusaur}

Os { } é para deixar destacado.
Link para o comentário
Compartilhar em outros sites

  • 0

Configurei tudo Certinho como vc falou e não funcionou! olha:

 

 

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 outs = {
["Athletic"] = {24124, 15},
["Hiker"] = {12424, 20},
}
msg = string.lower(msg)
local diamond = 2145
 
   
   if (msgcontains(msg, 'outfit') or msgcontains(msg, 'outfits')) then
  selfSay("I sell these clothes: {Athletic} and {Hiker}, what you want?", cid)
  talkState[talkUser] = 2
   elseif outs[msg] and talkState[talkUser] == 2 then
  selfSay("Are you sure you want to buy this outfit?", cid)
  outfit = outs[tostring(msg)]
  talkState[talkUser] = 3
   elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
  if getPlayerStorageValue(cid, outfit[1]) <= 0 then
                if outfit[2] then
   if doPlayerRemoveItem(cid, diamond, outfit[2]) then
  setPlayerStorageValue(cid, outfit[1], 1)
   else
  selfSay("You need ".. outfit[2] .." Diamonds to buy that clothe!", cid)
  talkState[talkUser] = 0
  return false
   end 
                else
                    if getPlayerMoney(cid) >= 20000 then
                        doPlayerRemoveMoney(cid, 20000)
   setPlayerStorageValue(cid, outfit[1], 1)
                    else
   selfSay("Voce precisa 200dl para comprar essa roupa!", cid)    -- Ignore
   talkState[talkUser] = 0
   return false
                    end
                end
            else
  selfSay("You already have that outfit, please choose another outfit...", cid)
  talkState[talkUser] = 0
  return false
  end
  selfSay("Ok... Here it is.", cid)   
  talkState[talkUser] = 0
  return true
   elseif msgcontains(msg, 'no') and talkState[talkUser] == 3 then
  selfSay("So... Please choose another outfit...", cid)
  talkState[talkUser] = 0      
   end
return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Link para o comentário
Compartilhar em outros sites

  • 0

 

Configurei tudo Certinho como vc falou e não funcionou! olha:

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 outs = {
["Athletic"] = {24124, 15},
["Hiker"] = {12424, 20},
}
msg = string.lower(msg)
local diamond = 2145
 
   
   if (msgcontains(msg, 'outfit') or msgcontains(msg, 'outfits')) then
  selfSay("I sell these clothes: {Athletic} and {Hiker}, what you want?", cid)
  talkState[talkUser] = 2
   elseif outs[msg] and talkState[talkUser] == 2 then
  selfSay("Are you sure you want to buy this outfit?", cid)
  outfit = outs[tostring(msg)]
  talkState[talkUser] = 3
   elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
  if getPlayerStorageValue(cid, outfit[1]) <= 0 then
                if outfit[2] then
   if doPlayerRemoveItem(cid, diamond, outfit[2]) then
  setPlayerStorageValue(cid, outfit[1], 1)
   else
  selfSay("You need ".. outfit[2] .." Diamonds to buy that clothe!", cid)
  talkState[talkUser] = 0
  return false
   end 
                else
                    if getPlayerMoney(cid) >= 20000 then
                        doPlayerRemoveMoney(cid, 20000)
   setPlayerStorageValue(cid, outfit[1], 1)
                    else
   selfSay("Voce precisa 200dl para comprar essa roupa!", cid)    -- Ignore
   talkState[talkUser] = 0
   return false
                    end
                end
            else
  selfSay("You already have that outfit, please choose another outfit...", cid)
  talkState[talkUser] = 0
  return false
  end
  selfSay("Ok... Here it is.", cid)   
  talkState[talkUser] = 0
  return true
   elseif msgcontains(msg, 'no') and talkState[talkUser] == 3 then
  selfSay("So... Please choose another outfit...", cid)
  talkState[talkUser] = 0      
   end
return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Deu algum erro?

Link para o comentário
Compartilhar em outros sites

  • 0

@@kaleudd,

 

Tenta assim:

 

XML:

 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="A Prisoner" script="data/npc/scripts/outseller.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="130" head="81" body="40" legs="55" feet="94" addons="0"/>
</npc>

 

 

Em data/npc/scripts/outseller.lua

 

local config = {
	["citizen"]	= {id = {136, 128}, item = {2160, 10}, storage = 15000},
	["barbarian"]	= {id = {147, 143}, item = {2160, 10}, storage = 15001},
	["oriental"]	= {id = {150, 146}, item = {2160, 10}, storage = 15001}
}

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 creatureSayCallback(cid, type, msg)
	msg = string.lower(msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if not npcHandler:isFocused(cid) then
		return false
	end

	if msgcontains(msg, 'hi') then
 		selfSay('Olá ' .. getPlayerName(cid) .. ', diga {outfits} para ver todas as outfits a venda.')
		talkState[talkUser] = 1

  	elseif msgcontains(msg, 'outfits') and talkState[talkUser] == 1 then
		local str = ""

		for i, _ in pairs(config) do
			str = str .. ", ".. i
		end
		selfSay('Bem, tenho os seguintes outfits: ' .. string.sub(str, 3, #str) .. '.')
		talkState[talkUser] = 2

	elseif talkState[talkUser] == 2 then
		local outfit = config[msg]

		if not outfit then
			selfSay('Desculpe, mas eu não vendo esse outfit!')
			talkState[talkUser] = 0
		end

		if getPlayerStorageValue(cid, outfit.storage) < 1 then
			if doPlayerRemoveItem(cid, outfit.item[1], outfit.item[2]) then
				selfSay('Parabéns! Você comprou o outfit com sucesso.')
				doPlayerAddOutfit(cid, outfit.id[1], 0)
				doPlayerAddOutfit(cid, outfit.id[2], 0)
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
				setPlayerStorageValue(cid, outfit.storage, 1)
				talkState[talkUser] = 0
			else
				selfSay('Você precisa de ' .. outfit.item[2] .. 'x ' .. getItemNameById(outfit.item[1]) .. ' para comprar esse outfit.')
				talkState[talkUser] = 0
			end
		else
			selfSay('Você já comprou esse outfit!')
			talkState[talkUser] = 0
		end

	elseif msgcontains(msg, 'bye') then
		selfSay('Tchau.')
		talkState[talkUser] = 0
	end	
	return true
end

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

 

 

Explicação:

id = {136, 128} -- id do outfit female, male

item = {2160, 10} -- id e quantidade do item

storage = 15000 -- storage de controle

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...