Postado Março 5, 2020 5 anos Fala galera do TK! To usando um script de npc craft criado por @Dwarfer mas em meu servidor da um erro ai sair de perto do npc. Não consegui resolver, se alguém poder me ajudar. Desde já, MUITO OBRIGADO!!!! OBS: o Servidor esta em português! OBS: O servidor é 8.6 TFS 0.4 SCRIPT do NPC Citar local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local npcTopic, xmsg = {}, {} 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 craft = { ["demon helmet"] = {reward = {{2493, 1}}, items = {{id = 2160, count = 1}, {id = 2148, count = 1}}}, ["magic plate armor"] = {reward = {{2472, 1}}, items = {{id = 2160, count = 10}, {id = 2044, count = 2}}}, ["soft boots"] = {reward = {{6132, 1}}, items = {{id = 2160, count = 1}, {id = 2148, count = 1}}}, ["knight armor"] = {reward = {{2376, 1}}, items = {{id = 2160, count = 1}, {id = 2148, count = 1}}} } local function checkItemsNeeded(cid, items) local check = {} for i, v in pairs(items) do if getPlayerItemCount(cid, v.id) >= v.count then check[#check + 1] = 1 end end return #check end local function getItemsFromTable(items) local str = '' if table.maxn(items) > 0 then for i = 1, table.maxn(items) do str = str .. items.count .. ' ' .. getItemNameById(items.id)if i ~= table.maxn(items) then str = str .. ', ' end end endreturn strend local function craftingEffects(position, delay)local text = {"Ishhh!", "Kaboom", "Tic Tac", "BUM!", "Blop Blop!", "Cronch!"}local effects = {2, 6, 25, 31, 36,40, 54, 51, 65, 66, 67, 68}if delay ~= 0 thendoSendAnimatedText(position, text[math.random(1, #text)], math.random(1, 255))doSendMagicEffect(position, effects[math.random(1, #effects)])addEvent(craftingEffects, 1000, position, delay - 1)endend 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("Hi, "..getPlayerName(cid)..". I can craft some {items} for you, but I need specific items to do them.", cid) npcTopic[talkUser] = 1 else return false end elseif msgcontains(msg, "items") and npcTopic[talkUser] == 1 then local text = "" for i, v in pairs(craft) do text = text .. " {"..i.."}, " end npcHandler:say("I can make " .. text .. " which one do you want?", cid) npcTopic[talkUser] = 2 elseif craft[msg] and npcTopic[talkUser] == 2 then npcHandler:say("Oh, " .. msg .. " is a good choice. Let me see... I need " .. getItemsFromTable(craft[msg].items) .. ", do you have it?" , cid) npcTopic[talkUser] = 3 xmsg[talkUser] = msg elseif not craft[msg] and npcTopic[talkUser] == 2 then npcHandler:say("I am not crafting this item, perhaps I can consider your order later.", cid) npcTopic[talkUser] = 0 elseif msgcontains(msg, "yes") and npcTopic[talkUser] == 3 then local x = craft[xmsg[talkUser]] local delay = 6 if checkItemsNeeded(cid, x.items) == #x.items then craftingEffects(getCreaturePosition(getNpcCid()), delay) for i = 1, #x.items do doPlayerRemoveItem(cid, x.items.id, x.items.count) end addEvent(function() if isPlayer(cid) then for i = 1, #x.reward do doPlayerAddItem(cid, x.reward[1], x.reward[2]) end end end, delay*1000) local type = talkUser == 0 and TALKTYPE_SAY or TALKTYPE_PRIVATE_NP addEvent(doCreatureSay, delay*1000, getNpcCid(), "Thank you very much! Here is your item as I promised.", type, cid) npcTopic[talkUser] = 0 else npcHandler:say("Sorry, but you don't have the items that I need.", cid) npcTopic[talkUser] = 0 end elseif msgcontains(msg, "no") and npcTopic[talkUser] == 3 then npcHandler:say("Ok, maybe on the next.", cid) npcTopic[talkUser] = 0 elseif msgcontains(msg, "bye") then npcHandler:say("Bye.", cid) npcHandler:releaseFocus(cid) else npcHandler:say("I am very busy, I can not talk to you now.", cid) npcTopic[talkUser] = 0 end return trueendnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) NPC: <?xml version="1.0" encoding="UTF-8"?> <npc name="Frederick" script="frederick.lua" walkinterval="2000" floorchange="0"> <health now="150" max="150" /> <look type="130" head="114" body="0" legs="113" feet="76" addons="3" corpse="2212" /> </npc> ERRO: Citar [05/03/2020 00:47:18] [Error - Npc interface] [05/03/2020 00:47:18] data/npc/scripts/frederick.lua:onThink[05/03/2020 00:47:18] Description: [05/03/2020 00:47:19] data/npc/scripts/frederick.lua:47: bad argument #1 to 'lower' (string expected, got nil)[05/03/2020 00:47:19] stack traceback:[05/03/2020 00:47:19] [C]: in function 'lower'[05/03/2020 00:47:19] data/npc/scripts/frederick.lua:47: in function 'callback'[05/03/2020 00:47:20] data/npc/lib/npcsystem/npchandler.lua:539: in function 'onWalkAway'[05/03/2020 00:47:20] data/npc/lib/npcsystem/npchandler.lua:479: in function 'onThink'[05/03/2020 00:47:20] data/npc/scripts/frederick.lua:8: in function <data/npc/scripts/frederick.lua:8> Editado Março 5, 2020 5 anos por OfWar (veja o histórico de edições)
Postado Março 5, 2020 5 anos Autor @Anivia Bom dia! ta ai. OBS: O servidor é 8.6 TFS 0.4 Editado Março 5, 2020 5 anos por OfWar (veja o histórico de edições)
Postado Março 5, 2020 5 anos Autor @ikaroangelo21 Bom dia! O NPC que quero é exatamente o que postei, que faz craft e não que tenha uma moeda vi. EXEMPLO: preciso de 10 itens diferentes para fazer um item. Obrigado mesmo assim.
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.