-
Total de itens
13 -
Registro em
-
Última visita
Histórico de Reputação
-
Samukajoga deu reputação a Yan Oliveira em npc pra resetar storage
Eu fiz com NPC, caso queira com item só falar que faço também.
Vai em Data/NPC e crie Resetador.xml (crie como codificação ANSI porque usei acentuação, mas caso use inglês, pode deixar no UTF-8 mesmo) e adicione o código dentro:
<?xml version="1.0" encoding="UTF-8"?> <npc name="Resetador" script="Resetador.lua" walkinterval="0" floorchange="0" access="5" level="1" maglevel="1"> <health now="150" max="150"/> <look type="1421" head="114" body="119" legs="114" feet="114" corpse="2212"/> <parameters> <parameter key="message_greet" value="Olá |PLAYERNAME|, o que você procura aqui? Diga {help} ou {ajuda} para mais informações."/> </parameters> </npc> Agora em Data/NPC/Scripts crie o arquivo Resetador.lua (crie como codificação ANSI porque usei acentuação, mas caso use inglês, pode deixar no UTF-8 mesmo) e adicione o código dentro:
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 -- VARIÁVEIS -- local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid msg = string.lower(msg) local level = 100 local storages = {100008, 100009, 100010} ----------------------------------- [ DIALOGO COM NPC] --------------------------------- if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') then selfSay("Se você for nível "..level.. " ou mais eu posso resetar todas as quests que você já fez. Gostaria de reseta-lás?", cid) talkState[talkUser] = 1 return true elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 1 then if getPlayerLevel(cid) >= level then for i = 1, #storages do if getPlayerStorageValue(cid, storages[i]) > 0 then doSendMagicEffect(getPlayerPosition(cid), 28) doPlayerSendTextMessage(cid, 27, "Todas as quests foram resetadas com sucesso. Agora você pode fazê-las novamente.") setPlayerStorageValue(cid, storages[i], 0) return true else selfSay("Todas as quests já foram resetadas.", cid) return true end end talkState[talkUser] = 0 end return true elseif (msgcontains(msg, 'no') or msgcontains(msg, 'não')) and talkState[talkUser] == 1 then selfSay("Ok então.", cid) talkState[talkUser] = 0 return true end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Eu fiz bem básico mesmo para ver se é assim que quer. Deixei a frase como storage porque não sei se irá adicionar o código em server online e os players não vão saber o que é storage, então deixei como quest a mensagem. Deixei apenas uma verificação para falar com npc se o player possuir nível 100 ou mais. Caso queira o NPC com mais validações só falar.
As storages que quiser resetar, adicione na tabela storages, deixei 3 de exemplo lá.
Testei aqui e está funcionando, mas qualquer problema me fala.
-
Samukajoga deu reputação a GuhPk em Evento De Natal
Lord, o npc funciona assim, você coloca isso aqui:
?xml version="1.0" encoding="UTF-8"?> <npc name="Papai Noel" script="papainoel.lua" walkinterval="350000" floorchange="0" speed="0"> <health now="150" max="150"/> <look type="160" head="0" body="112" legs="93" feet="95"/>
Em data/npcs, só fazer um arquivo lá Papai Noel.xml e colocar isso...
Depois vá em data/npcs/scripts cria um arquivo papainoel.lua e cole isso:
idDoDoll = 6512 -- Id do boneco(doll) idDaCaixa = 6497-- Id da caixa que da itens 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 if(msgcontains(msg, 'change doll')) then if doPlayerRemoveItem(cid, 6512, 1) then doPlayerAddItem(cid, 6497, 1) SelfSay('Marry Crystimas!!') else return selfSay('Sorry, you need a "..getItemNameById(idDoDoll)..".') end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Você estava colocando tudo junto... Por isso estava dando erro!! '-'
-
Samukajoga deu reputação a LordVinny em Evento De Natal
SmiX seu script tem um bug, quando eu abro a caixa de presentes aparece um sqm estranho em baixo do player, a box não some depois de ser usada , quando eu tento "sumonar" o npc não pega.
Olha ai :
[03/12/2012 19:44:08] [Warning - Npc::loadFromXml] Cannot load npc file (data/npc/papai noel.xml).
[03/12/2012 19:44:08] Line: 4, Info: Premature end of data in tag npc line 2
Então galerinha, está dando esse erro aqui:
E o script está assim
NPC
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Papai Noel" script="papainoel.lua" walkinterval="350000" floorchange="0" speed="0">
<health now="150" max="150"/>
<look type="160" head="0" body="112" legs="93" feet="95"/>
idDoDoll = 6512 -- Id do boneco(doll)
idDaCaixa = 6497-- Id da caixa que da itens
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
if(msgcontains(msg, 'change doll')) then
if doPlayerRemoveItem(cid, 6512, 1) then
doPlayerAddItem(cid, 6497, 1)
SelfSay('Marry Crystimas!!')
else
return selfSay('Sorry, you need a "..getItemNameById(idDoDoll)..".')
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
-
Samukajoga deu reputação a GuhPk em Evento De Natal
Acho que do SmiX ta melhor neh... Bem menor!!! uhsauhsau'
-
Quem Está Navegando 0 membros estão online
- Nenhum usuário registrado visualizando esta página.