olá, eu gostaria de saber se alguém pode me ajudar cm um npc pra resetar a storege dos players pra q eles possam fazer as quests dnv, em troca de um certo item, ou até msm um item q reseta a storage q dai faço o npc q troca ele pelo outro item, tentei algumas formas, mas n consigo resetar tds as storeges ;-; , bem axo q é isso desde já obgd
npc pra resetar storage

Mas você quer que um único item resete todas as storages ou cada item irá resetar storage de determinada quest?
Em 20/12/2019 em 00:57, Yan18 disse:Mas você quer que um único item resete todas as storages ou cada item irá resetar storage de determinada quest?
1 item ou npc reset todas
Em 24/01/2020 em 18:41, Samukajoga disse:1 item ou npc reset todas
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.
mt obgd moço vou testar aqui ❤️ ❤️
51 minutos atrás, Samukajoga disse:mt obgd moço vou testar aqui ❤️ ❤️
De nada! Testa ai, qualquer problema você me fala.
Em 29/01/2020 em 16:34, Yan18 disse:De nada! Testa ai, qualquer problema você me fala.
fui testar e diz '' todas as quests ja foram resetadas'' mas na vdd nao resetou nada ;-;
1 hora atrás, Samukajoga disse:fui testar e diz '' todas as quests ja foram resetadas'' mas na vdd nao resetou nada ;-;
Você mexeu em algo no script? Colocou as storages certo? Coloque o script com suas storages, ou coloque todas as storages que quer resetar que eu coloco no código para você.
Em 31/01/2020 em 13:51, Yan18 disse:Você mexeu em algo no script? Colocou as storages certo? Coloque o script com suas storages, ou coloque todas as storages que quer resetar que eu coloco no código para você.
sim eu colokei, pera vo te mandar como ficou, desculpa o sumiço. meu HD queimou ;-; fiquei sme pc um tempo mas o npc ficou assim
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 = 497
local storages = {9361, 9363, 9366, 9364, 9365, 9367, 9368, 9369, 9370, 9371, 9372, 9373, 9374, 9375, 9376, 9377, 9378, 9379, 9380, 9381, 9382, 9383, 9384, 9385, 9386, 9387, 9388, 9389, 9390, 9391, 9392, 9393, 9394, 9395, 9396, 9397, 9398, 9399, 9400}
----------------------------------- [ 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) > 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, 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())
37 minutos atrás, Samukajoga disse:sim eu colokei, pera vo te mandar como ficou, desculpa o sumiço. meu HD queimou ;-; fiquei sme pc um tempo mas o npc ficou assim
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() endfunction 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 = 497
local storages = {9361, 9363, 9366, 9364, 9365, 9367, 9368, 9369, 9370, 9371, 9372, 9373, 9374, 9375, 9376, 9377, 9378, 9379, 9380, 9381, 9382, 9383, 9384, 9385, 9386, 9387, 9388, 9389, 9390, 9391, 9392, 9393, 9394, 9395, 9396, 9397, 9398, 9399, 9400}----------------------------------- [ 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 trueelseif (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) > 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, 0)
return true
else
selfSay("Todas as quests já foram resetadas.", cid)
return true
end
end
talkState[talkUser] = 0
end
return trueelseif (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())
Sem problemas, e que chato pelo seu HD .
Sobre o post, pelo que vi foi erro meu, pois não estava setando a tabela, por isso não estava funcionando. Mas eu arrumei e testei aqui funcionou:
E observação que testei com as suas storages, setei todas para 1 para testar e funcionou.
Mas testa ai esse script e vê se funciona:
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 = {9361, 9363, 9366, 9364, 9365, 9367, 9368, 9369, 9370, 9371, 9372, 9373, 9374, 9375, 9376, 9377, 9378, 9379, 9380, 9381, 9382, 9383, 9384, 9385, 9386, 9387, 9388, 9389, 9390, 9391, 9392, 9393, 9394, 9395, 9396, 9397, 9398, 9399, 9400} ----------------------------------- [ 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 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) selfSay("Todas as quests foram resetadas com sucesso! Agora você pode fazê-las novamente.", cid) 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())
Se der erro ou não funcionar, manda print do que aparece na distro.
realmente nao deu certo fiz exatamente como vc disse
Em 21/02/2020 em 10:49, Samukajoga disse:realmente nao deu certo
fiz exatamente como vc disse
Olá amigo, desculpe a demora, o fórum não notificou que você respondeu, só está notificando quando cita o post.
Vamos lá, realmente foi erro meu no código, pois eu usei o for errado, substitua o código por este:
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 = {9361, 9363, 9366, 9364, 9365, 9367, 9368, 9369, 9370, 9371, 9372, 9373, 9374, 9375, 9376, 9377, 9378, 9379, 9380, 9381, 9382, 9383, 9384, 9385, 9386, 9387, 9388, 9389, 9390, 9391, 9392, 9393, 9394, 9395, 9396, 9397, 9398, 9399, 9400} ----------------------------------- [ 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 elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 1 then if getPlayerLevel(cid) >= level then for _, i in pairs(storages) do if getPlayerStorageValue(cid, storages[i]) >= 0 then setPlayerStorageValue(cid, storages[i], -1) end end doSendMagicEffect(getPlayerPosition(cid), 28) selfSay("Todas as quests que você já fez foram resetadas com sucesso! Agora você pode fazê-las novamente.", cid) talkState[talkUser] = 0 return true else selfSay("Você não tem level suficiente para resetar as quests. É necessário ter " ..level " ou mais para resetar as quests.", cid) talkState[talkUser] = 0 return true end 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())
Teste e me fale se deu algum problema, mas é para funcionar assim.