Postado Setembro 19, 2020 4 anos 0.4 Boa tarde povo, eu gostaria de uma ajuda num script que eu tenho sobre NPC. Esse script faz o npc dar uma task pro player quando ele fala as palavras certas, e ele funciona 100%, porém, eu gostaria de algo a mais (e tentei fazer sozinho, mas não sirvo pra essas coisas) Eu gostaria que o Npc checasse se o player tivesse X storage, se ele tiver, o player poderá pegar a quest com o npc. Se o player não tiver X storage, o npc vai falar pra ele que ele não é confiável ou algo assim, aqui está a script do NPC (por favor, se for possivel, use ela como base): local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local quest = 11475 local reward = 70000 local markTable = { -- {markPos = Coordenadas da marcação, markType = Tipo de marcação, markDescription = Descrição da marcação} {markPos = {x = , y = , z = }, markType = MAPMARK_SWORD, markDescription = ""} } 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 func_addMark = doPlayerAddMapMark if(not func_addMark) then func_addMark = doAddMapMark end if(msgcontains(msg, "location")) then for mark, x in pairs(markTable) do func_addMark(cid, x.markPos, x.markType, x.markDescription ~= nil and x.markDescription or "") end selfSay("", cid) end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(not npcHandler:isFocused(cid)) then return false elseif msgcontains(msg, "") and talkState[talkUser] == 1 then npcHandler:say("", cid) talkState[talkUser] = 2 elseif msgcontains(msg, "") and talkState[talkUser] == 2 then if(getPlayerStorageValue(cid,11476) < 4) then <!-- A storage que o npc reconhece, pra dar ou não a quest pro player --> npcHandler:say("", cid) setPlayerStorageValue(cid, quest, 2) talkState[talkUser] = 0 else npcHandler:say('', cid) <!-- Msg que ele vai falar pro player que não tiver a storage (SEM DAR A QUEST) --> end elseif msgcontains(msg, "") then local str = getPlayerStorageValue(cid, quest) if(str < 2) then npcHandler:say("", cid) talkState[talkUser] = 1 return true elseif(str == 2) then npcHandler:say("", cid) elseif(str == 3) then npcHandler:say("", cid) setPlayerStorageValue(cid, quest, 4) elseif(str == 4) then npcHandler:say("", cid) talkState[talkUser] = 0 end end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Eu tentei fazer por conta própria, literalmente na tentativa e erro, botando aquela linha do storage em todo o lugar, mas sem sucesso. No lugar em que está agora, o npc ignora completamente essa parte e da a quest pro player mesmo se ele não tiver a storage.
Postado Setembro 20, 2020 4 anos Autor Só tirar as duas partes, @Pisces, mas eu mando sim! local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local quest = 11475 local reward = 70000 local markTable = { -- {markPos = Coordenadas da marcação, markType = Tipo de marcação, markDescription = Descrição da marcação} {markPos = {x = , y = , z = }, markType = MAPMARK_SWORD, markDescription = ""} } 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 func_addMark = doPlayerAddMapMark if(not func_addMark) then func_addMark = doAddMapMark end if(msgcontains(msg, "location")) then for mark, x in pairs(markTable) do func_addMark(cid, x.markPos, x.markType, x.markDescription ~= nil and x.markDescription or "") end selfSay("", cid) end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(not npcHandler:isFocused(cid)) then return false elseif msgcontains(msg, "") and talkState[talkUser] == 1 then npcHandler:say("", cid) talkState[talkUser] = 2 elseif msgcontains(msg, "") and talkState[talkUser] == 2 then npcHandler:say("", cid) setPlayerStorageValue(cid, quest, 2) talkState[talkUser] = 0 elseif msgcontains(msg, "") then local str = getPlayerStorageValue(cid, quest) if(str < 2) then npcHandler:say("", cid) talkState[talkUser] = 1 return true elseif(str == 2) then npcHandler:say("", cid) elseif(str == 3) then npcHandler:say("", cid) setPlayerStorageValue(cid, quest, 4) elseif(str == 4) then npcHandler:say("", cid) talkState[talkUser] = 0 end end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Setembro 21, 2020 4 anos Solução Cara complicado te ajuda vc mando um script limpo avulso, e pediu uma verificação de storage, onde? ao falar hi? ao conversa? Faz o seguinte vou te manda esse limpo q normalmente uso pra criar npc e ele com verificação de storage das duas forma vc compara e faz do jeito que quiser. Mostrar conteúdo oculto Limpo! local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg:lower()) end function onThink() npcHandler:onThink() end local talkState = {} function onCreatureSay(cid, type, msg) npcHandler:setMessage(MESSAGE_GREET, "Ola " ..getCreatureName(cid).. " você quer uma missão?") npcHandler:setMessage(MESSAGE_WALKAWAY, "Semprem fogem") npcHandler:setMessage(MESSAGE_FAREWELL, "Até... "..getCreatureName(cid)..".") npcHandler:onCreatureSay(cid, type, msg) 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 -- INICIO DE CONVERSA -- if isInArray({"yes", "sim"}, msg) then npcHandler:say("bla bla bla bla bla", cid) end if isInArray({"no", "nao"}, msg) then npcHandler:say("bla bla bla bla bla", cid) end -- fim -- return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Com verificações de storage no hi (onCreatureSay) e nas falas seguintes (creatureSayCallback) local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg:lower()) end function onThink() npcHandler:onThink() end local talkState = {} function onCreatureSay(cid, type, msg) if getPlayerStorageValue(cid, 0000) >= 1 then npcHandler:setMessage(MESSAGE_GREET, "Ola " ..getCreatureName(cid).. " você quer uma missão?") else npcHandler:setMessage(MESSAGE_GREET, "Ola " ..getCreatureName(cid).. " não tenho nenhuma missão para você!") end npcHandler:setMessage(MESSAGE_WALKAWAY, "Semprem fogem") npcHandler:setMessage(MESSAGE_FAREWELL, "Até... "..getCreatureName(cid)..".") npcHandler:onCreatureSay(cid, type, msg) 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 -- INICIO DE CONVERSA -- if isInArray({"yes", "sim"}, msg) then if getPlayerStorageValue(cid, 0000) >= 1 then npcHandler:say("bla bla bla bla bla", cid) else npcHandler:say("ble ble ble ble ble", cid) end end -- fim return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Discord: Naze#3578 Ter Linux Dentro de Windows com Acesso 'localhost' para testes e + AutoLoot Otimizado Direto na Source (tfs 0.4/otx) // Pirataria é crime, original é roubo, compartilhar é legal.
Postado Setembro 21, 2020 4 anos Autor @Naze Cara, não importa onde seria a verificação. Pode ser no Hi, pode ser no meio, pode ser na ultima fala antes de pegar a quest. Eu só queria que o NPC não desse a quest se o player não tivesse uma storage E desse a quest se ele tivesse a storage. Eu vou conseguir testar só mais tarde o que você mandou, ai aviso Edit: Cara, não usei o seu script, mas eu vi que faltava um "=" onde ele checava storage, obrigado por isso Editado Setembro 22, 2020 4 anos por Zazeros Resolvido (veja o histórico de ediçõ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.