Ir para conteúdo

[Encerrado] NPC QUE TROCA ITEM POR OUTFIT


lol08

Posts Recomendados

Vai em outftis.xml

e cria uma outfit

<outfit id="ID" premium="yes" quest="66565">
<list gender="0" lookType="look" name="nome"/>
<list gender="1" lookType="look" name="nome"/>
</outfit>

Crie um NPC e no arquivo lua dele cole isso:

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
                                                  --alterado v2.8 \/ peguem ele todo!
local outs = {
["NOME"] = {66565},


}
quant = QUANTIDADE
item = ID ITEM
msg = string.lower(msg)


        
        if (msgcontains(msg, 'outfit') or msgcontains(msg, 'outfits')) then
           selfSay("I sell this outfits: {NOME}??", cid)
           talkState[talkUser] = 2
        elseif outs[msg] and talkState[talkUser] == 2 then
           selfSay("Are you sure which want trade item for  that outfit?", cid)
           outfit = outs[tostring(msg)]
           talkState[talkUser] = 3
        elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
                 if doPlayerRemoveItem(cid, item, quant)then
                    doPlayerRemoveItem(cid, item, quant)
                    setPlayerStorageValue(cid, outs[1], 1)
                 else
                     selfSay("You need "..quant.."x "..getItemNameById(item).." to get this outfit!", cid)
                     talkState[talkUser] = 0
                     return false
                 end
           else
               selfSay("You already have this outfit, so please, choose another outfit...", cid)
               talkState[talkUser] = 0
               return false
           end
           selfSay("So... Here 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


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

Não testei aqui, vê se dá certo ai.

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

erro na linha 52

[02/02/2016 20:37:56] [Error - LuaScriptInterface::loadFile] data/npc/scripts/roupas.lua:52: 'end' expected (to close 'function' at line 9) near 'elseif'

[02/02/2016 20:37:56] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/roupas.lua
[02/02/2016 20:37:56] data/npc/scripts/roupas.lua:52: 'end' expected (to close 'function' at line 9) near 'elseif'
Link para o comentário
Compartilhar em outros sites

 

erro na linha 52

[02/02/2016 20:37:56] [Error - LuaScriptInterface::loadFile] data/npc/scripts/roupas.lua:52: 'end' expected (to close 'function' at line 9) near 'elseif'

[02/02/2016 20:37:56] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/roupas.lua
[02/02/2016 20:37:56] data/npc/scripts/roupas.lua:52: 'end' expected (to close 'function' at line 9) near 'elseif'

 

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
                                                  --alterado v2.8 \/ peguem ele todo!
local outs = {
["NOME"] = {66565},

}
quant = QUANTIDADE
item = ID ITEM
msg = string.lower(msg)

        
        if (msgcontains(msg, 'outfit') or msgcontains(msg, 'outfits')) then
           selfSay("I sell this outfits: {NOME}??", cid)
           talkState[talkUser] = 2
        elseif outs[msg] and talkState[talkUser] == 2 then
           selfSay("Are you sure which want trade item for  that outfit?", cid)
           outfit = outs[tostring(msg)]
           talkState[talkUser] = 3
        elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
                 if doPlayerRemoveItem(cid, item, quant)then
                    doPlayerRemoveItem(cid, item, quant)
                    setPlayerStorageValue(cid, outs[1], 1)
                 else
                     selfSay("You need "..quant.."x "..getItemNameById(item).." to get this outfit!", cid)
                     talkState[talkUser] = 0
                     return false
                 end
           else
               selfSay("You already have this outfit, so please, choose another outfit...", cid)
               talkState[talkUser] = 0
               return false
           selfSay("So... Here 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
		end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())             
Link para o comentário
Compartilhar em outros sites

DEU ISSO AGR [02/02/2016 20:44:39] [Error - LuaScriptInterface::loadFile] data/npc/scripts/roupas.lua:45: 'end' expected (to close 'if' at line 25) near 'selfSay'

[02/02/2016 20:44:40] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/roupas.lua
[02/02/2016 20:44:40] data/npc/scripts/roupas.lua:45: 'end' expected (to close 'if' at line 25) near 'selfSay'
Link para o comentário
Compartilhar em outros sites


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

--alterado v2.8 \/ peguem ele todo!

local outs = {

["NOME"] = {66565},

 

}

quant = QUANTIDADE

item = ID ITEM

msg = string.lower(msg)

 

 

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

selfSay("I sell this outfits: {NOME}??", cid)

talkState[talkUser] = 2

end

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

selfSay("Are you sure which want trade item for that outfit?", cid)

outfit = outs[tostring(msg)]

talkState[talkUser] = 3

end

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

if doPlayerRemoveItem(cid, item, quant)then

doPlayerRemoveItem(cid, item, quant)

setPlayerStorageValue(cid, outs[1], 1)

else

selfSay("You need "..quant.."x "..getItemNameById(item).." to get this outfit!", cid)

talkState[talkUser] = 0

return false

end

end

if getPlayerStorageValue(cid, outs[1]) == 1 then

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

talkState[talkUser] = 0

return false

selfSay("So... Here 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

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

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

erro

[02/02/2016 20:52:46] [Error - LuaScriptInterface::loadFile] data/npc/scripts/roupas.lua:45: 'then' expected near 'selfSay'
[02/02/2016 20:52:46] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/roupas.lua
[02/02/2016 20:52:46] data/npc/scripts/roupas.lua:45: 'then' expected near 'selfSay'

 

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
--alterado v2.8 \/ peguem ele todo!
local outs = {
["picachu"] = {66565},
}
quant = 300
item = 5911
msg = string.lower(msg)
if (msgcontains(msg, 'outfit') or msgcontains(msg, 'outfits')) then
selfSay("I sell this outfits: {NOME}??", cid)
talkState[talkUser] = 2
elseif outs[msg] and talkState[talkUser] == 2 then
selfSay("Are you sure which want trade item for that outfit?", cid)
outfit = outs[tostring(msg)]
talkState[talkUser] = 3
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
if doPlayerRemoveItem(cid, item, quant)then
doPlayerRemoveItem(cid, item, quant)
setPlayerStorageValue(cid, outs[1], 1)
else
selfSay("You need "..quant.."x "..getItemNameById(item).." to get this outfit!", cid)
talkState[talkUser] = 0
return false
end
else
selfSay("You already have this outfit, so please, choose another outfit...", cid)
talkState[talkUser] = 0
return false
selfSay("So... Here 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
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Link para o comentário
Compartilhar em outros sites


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

--alterado v2.8 \/ peguem ele todo!

local outs = {

["NOME"] = {sto = 66565, item = item, quant = quant},

 

}

msg = string.lower(msg)

 

 

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

selfSay("I sell this outfits: {NOME}??")

talkState[talkUser] = 2

end

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

selfSay("Are you sure which want trade item for that outfit?")

outfit = outs[tostring(msg)]

talkState[talkUser] = 3

end

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

if doPlayerRemoveItem(cid, outs[1].item, outs[1].quant)then

doPlayerRemoveItem(cid, outs[1].item, outs[1].quant)

setPlayerStorageValue(cid, outs[1].sto, 1)

else

selfSay("You need "..outs[1].quant.."x "..getItemNameById(outs[1].item).." to get this outfit!")

talkState[talkUser] = 0

return false

end

end

if getPlayerStorageValue(cid, outs[1].sto) == 1 then

selfSay("You already have this outfit, so please, choose another outfit...")

talkState[talkUser] = 0

return false

selfSay("So... Here is.")

talkState[talkUser] = 0

return true

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

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

talkState[talkUser] = 0

end

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Link para o comentário
Compartilhar em outros sites

mesmo erro [03/02/2016 10:05:15] [Error - LuaScriptInterface::loadFile] data/npc/scripts/roupas.lua:46: 'end' expected (to close 'if' at line 42) near 'selfSay'
[03/02/2016 10:05:15] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/roupas.lua
[03/02/2016 10:05:15] data/npc/scripts/roupas.lua:46: 'end' expected (to close 'if' at line 42) near 'selfSay'

Link para o comentário
Compartilhar em outros sites

mesmo erro [03/02/2016 10:05:15] [Error - LuaScriptInterface::loadFile] data/npc/scripts/roupas.lua:46: 'end' expected (to close 'if' at line 42) near 'selfSay'

[03/02/2016 10:05:15] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/roupas.lua

[03/02/2016 10:05:15] data/npc/scripts/roupas.lua:46: 'end' expected (to close 'if' at line 42) near 'selfSay'

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
                                                  --alterado v2.8 \/ peguem ele todo!
local outs = {
["NOME"] = {sto = 66565, item = item, quant = quant},

}
msg = string.lower(msg)

        
        if (msgcontains(msg, 'outfit') or msgcontains(msg, 'outfits')) then
           selfSay("I sell this outfits: {"..outs[1].."}??")
           talkState[talkUser] = 2
		   end
        if outs[msg] and talkState[talkUser] == 2 then
           selfSay("Are you sure which want trade item for  that outfit?")
           outfit = outs[tostring(msg)]
           talkState[talkUser] = 3
		   end
        if msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
                 if doPlayerRemoveItem(cid, outs[1].item, outs[1].quant)then
                    doPlayerRemoveItem(cid, outs[1].item, outs[1].quant)
                    setPlayerStorageValue(cid, outs[1].sto, 1)
			elfSay("So... Here is.")   
           talkState[talkUser] = 0
           return true
                 else
                     selfSay("You need "..outs[1].quant.."x "..getItemNameById(outs[1].item).." to get this outfit!")
                     talkState[talkUser] = 0
                     return false
                 end
           end
		   if getPlayerStorageValue(cid, outs[1].sto) == 1 then
               selfSay("You already have this outfit, so please, choose another outfit...")
               talkState[talkUser] = 0
               return false
        elseif msgcontains(msg, 'no') and talkState[talkUser] == 3 then
           selfSay("So... Please choose another outfit...")
           talkState[talkUser] = 0                             
        end
		end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())             
Link para o comentário
Compartilhar em outros sites

  • 2 years later...
A questão neste tópico de suporte foi encerrada por falta de respostas. Este tópico está fechado e foi movido para Suporte - Tópicos Sem Resposta.

+ Caso a dúvida não tenha sido resolvida você poderá criar outro tópico solicitando ajuda.
* Lembre-se que é permitido dar UP no tópico a cada 24 horas para assim o destacar e manter movimentado.
Link para o comentário
Compartilhar em outros sites

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