Postado Outubro 16, 2017 7 anos Fala galera do TK, então tenho esse script, só que ele tem um script. Como mostrado abaixo ele pede 60 itens do magic crystal para entregar tal storage. Porem o script ta com um bug que n precisa ter 60 só tendo 1 o npc ja entrega queria saber se alguem pode corrigir esse erroo para mim por favor??? e fazer só entregar sendo 60 ou ele fala que nao possui ainda Mostrar conteúdo oculto local id1 = 12469 --id do item a ser trocado local stor = 4151 -- storage que o npc vai adr pelo item local quantidade = 60 -- quantos itens player deve ter para trocar por storage local palavra = "entregar" --palavra chave pra falar com o npc pra trocar a storage local mensagem = "Voce ainda nao tem os 40 {magic crystal}." -- a mensagem que deve ser dita se ele não tiver o item 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 playerHaveItems(cid, itemid) local items = type(itemid) == "table" and itemid or {itemid} for i = 60, #items do if getPlayerItemCount(cid, items) <= 0 then return false end end return true end function doPlayerRemoveItems(cid, itemid, count) local items = type(itemid) == "table" and itemid or {itemid} for i = 60, #items do doPlayerRemoveItem(cid, items, count ~= nil and count or 1) end return nil end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, palavra) then if playerHaveItems(cid, {id1}) then doPlayerRemoveItems(cid, {id1}, quantidade) setPlayerStorageValue(cid, stor, 1) else selfSay(mensagem) end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Outubro 16, 2017 7 anos Em npcs/scripts crie um arquivo: npcstorage.lua Mostrar conteúdo oculto local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local npcTopic = {} 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 local t = { id = 12469, quantidade = 60, stor = 4151, palavra = "entregar" } function creatureSayCallback(cid, type, msg) local talkUser, msg = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, string.lower(msg) if(not npcHandler:isFocused(cid)) then if isInArray({"hi", "hello"}, msg) then npcHandler:addFocus(cid) npcHandler:say("Olá, "..getPlayerName(cid)..". Caso deseje, você pode {"..t.palavra.."} os itens necessários.", cid) npcTopic[talkUser] = 1 else return false end elseif msgcontains(msg, t.palavra) and npcTopic[talkUser] == 1 then if getPlayerStorageValue(cid, t.stor) ~= -1 then npcHandler:say("Você já recebeu minha permissão.", cid) npcTopic[talkUser] = 0 else if doPlayerRemoveItem(cid, t.id, t.quantidade) then setPlayerStorageValue(cid, t.stor, 1) npcHandler:say("Receba minha permissão.", cid) npcTopic[talkUser] = 0 else npcHandler:say("Você ainda não tem " .. t.quantidade .. " " .. getItemNameById(t.id) .. ".", cid) npcTopic[talkUser] = 0 end end elseif msgcontains(msg, "bye") then npcHandler:say("Bye.", cid) npcHandler:releaseFocus(cid) else npcHandler:say("Não tenho tempo para piadas...", cid) npcTopic[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) Aqui vai um xml como base, modifique a seu gosto: <?xml version="1.0" encoding="UTF-8"?> <npc name="Dwarfer" script="npcstorage.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="66"/> </npc> Contato: Email: dwarfer@sapo.pt Discord: Dwarfer#2715
Postado Outubro 16, 2017 7 anos Autor Em 16/10/2017 em 19:20, Dwarfer disse: Em npcs/scripts crie um arquivo: npcstorage.lua Mostrar conteúdo oculto Mostrar conteúdo oculto local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local npcTopic = {} 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 local t = { id = 12469, quantidade = 60, stor = 4151, palavra = "entregar" } function creatureSayCallback(cid, type, msg) local talkUser, msg = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, string.lower(msg) if(not npcHandler:isFocused(cid)) then if isInArray({"hi", "hello"}, msg) then npcHandler:addFocus(cid) npcHandler:say("Olá, "..getPlayerName(cid)..". Caso deseje, você pode {"..t.palavra.."} os itens necessários.", cid) npcTopic[talkUser] = 1 else return false end elseif msgcontains(msg, t.palavra) and npcTopic[talkUser] == 1 then if getPlayerStorageValue(cid, t.stor) ~= -1 then npcHandler:say("Você já recebeu minha permissão.", cid) npcTopic[talkUser] = 0 else if doPlayerRemoveItem(cid, t.id, t.quantidade) then setPlayerStorageValue(cid, t.stor, 1) npcHandler:say("Receba minha permissão.", cid) npcTopic[talkUser] = 0 else npcHandler:say("Você ainda não tem " .. t.quantidade .. " " .. getItemNameById(t.id) .. ".", cid) npcTopic[talkUser] = 0 end end elseif msgcontains(msg, "bye") then npcHandler:say("Bye.", cid) npcHandler:releaseFocus(cid) else npcHandler:say("Não tenho tempo para piadas...", cid) npcTopic[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) Aqui vai um xml como base, modifique a seu gosto: <?xml version="1.0" encoding="UTF-8"?> <npc name="Dwarfer" script="npcstorage.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="66"/> </npc> Irei testar! PERFEITO!!! QUeria saber um contato seu, via facebook ou skype... Editado Outubro 16, 2017 7 anos por gutalo (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.