Postado Fevereiro 19, 2019 6 anos Oi pessoal, espero de coração que possam me ajudar, estou a bastante tempo neste pepino e nada até agora.. O código que eu vou postar lá embaixo funciona da seguinte forma: QUando eu digo YES ou SIM para o NPC, ele pega 20 runas com cargas 2x e me dá um outro item... Até aqui tudo funcionando perfeitamente, ou quase... Tem duas coisas que não estão funcionando como eu gostaria neste script: Primeira: SE eu tenho mais do que o número necessário de runas (20 runas) ele remove todas elas, incluindo as adicionais (se eu tenho 30, invés de pegar só as 20 ele pega as 30) Segunda: Gostaria de uma função para que também remova a BACKPACK que se encontrava as 20 runas... ou seja, além de pegar as 20 runas, também pegar a backpack em que as 20 runas estavam... pode ser só um ID.. tipo a Backpack marrom mesmo, caso for mais complicado colocar outras... Senão toda vez que trocarem, caso o OT tenha bastante player, vai ENCHER de backpack no chão da sala onde o NPC está, causando LAG e problemas de FPS... Agradeço desde já! Aqui está a tabela de troca de itens... Code: ['ultimate healing rune'] = {cost = 20, items = {{2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}}, outfit_female = 26612, outfit_male = 26612, addon = 1, storageID = 10042}, Ignorem o que diz respeito a outfit_male e outras coisas... é só o nome que está trocado, mas a função funciona igual (fui um pouco relaxado em não trocar) Lua: outfit_male = 26612 Este é o ID do item que eu recebo ao dar as 20 runas (e se possível, com a backpack também)Aqui está o código de toda a função em questão... Lua: elseif msgcontains(msg, "yes") or msgcontains(msg, "sim") then if (talkState[talkUser] > 10010 and talkState[talkUser] < 10100) then local items_number = 0 if table.maxn(addoninfo[rtnt[talkUser]].items) > 0 then for i = 1, table.maxn(addoninfo[rtnt[talkUser]].items) do local item = addoninfo[rtnt[talkUser]].items[i] if (getPlayerItemCount(cid,item[1]) >= item[2]) then items_number = items_number + 1 end end end if(getPlayerMoney(cid) >= addoninfo[rtnt[talkUser]].cost) and (items_number == table.maxn(addoninfo[rtnt[talkUser]].items)) then doPlayerRemoveMoney(cid, addoninfo[rtnt[talkUser]].cost) if table.maxn(addoninfo[rtnt[talkUser]].items) > 0 then for i = 1, table.maxn(addoninfo[rtnt[talkUser]].items) do local item = addoninfo[rtnt[talkUser]].items[i] doPlayerRemoveItem(cid,item[1],item[2]) if container:getSize() == 0 then container:remove() end end end doPlayerAddItem(cid, addoninfo[rtnt[talkUser]].outfit_male) npcHandler:say('Aqui está seu pacote.', cid) else npcHandler:say('Você não tem as runas, cargas ou o dinheiro necessário!', cid) end rtnt[talkUser] = nil talkState[talkUser] = 0 npcHandler:resetNpc() return true end E é isto, não coloquei todo o código, pois o resto não tem nada a ver com o que eu quero fazer (acho eu) então não coloquei para não confundir mais a cabeça de todos! Muito obrigado desde já
Postado Fevereiro 20, 2019 6 anos @Camilo Salvadori um problema que pode ocorrer é se a runa estiver na backpack principal do player e o npc for pegar vai pegar com tudo dentro .... você pode aumentar o x de cargas que cada runa pode ter também seria uma boa opção Projeto ATS (Naruto)Informações AbaixoFacebookYoutubeDiscord Tutoriais / ConteúdosClique Aqui
Postado Fevereiro 20, 2019 6 anos posta o npc inteiro [*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*] DISCORD: vodkart#6090
Postado Fevereiro 21, 2019 6 anos Autor local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) local talkState = {} local rtnt = {} 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 npcHandler:setMessage(MESSAGE_GREET, "Seja bem vindo |PLAYERNAME|. Eu sou responsável pela venda de pacote de runas.. Diga {runas} para ver a lista de disponibilidade, ou {ajuda} para entender melhor o processo.") addoninfo = { ['ultimate healing rune'] = {cost = 20, items = {{2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}, {2273,2}}, outfit_female = 26612, outfit_male = 26612, addon = 1, storageID = 10042}, ['heavy magic missile rune'] = {cost = 20, items = {{2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}, {2311,8}}, outfit_female = 26613, outfit_male = 26613, addon = 1, storageID = 10043}, ['explosion rune'] = {cost = 20, items = {{2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}, {2313,4}}, outfit_female = 26614, outfit_male = 26614, addon = 1, storageID = 10044}, ['sudden death rune'] = {cost = 20, items = {{2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}, {2268,2}}, outfit_female = 26615, outfit_male = 26615, addon = 1, storageID = 10045}, ['magic wall rune'] = {cost = 20, items = {{2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}, {2293,3}}, outfit_female = 26616, outfit_male = 26616, addon = 1, storageID = 10046}, ['great fireball rune'] = {cost = 20, items = {{2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}, {2304,4}}, outfit_female = 26617, outfit_male = 26617, addon = 1, storageID = 10047}, ['fireball rune'] = {cost = 20, items = {{2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}, {2302,5}}, outfit_female = 26618, outfit_male = 26618, addon = 1, storageID = 10048}, ['holy missile rune'] = {cost = 20, items = {{2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}, {2295,1}}, outfit_female = 26620, outfit_male = 26620, addon = 1, storageID = 10049}, ['energy bomb rune'] = {cost = 20, items = {{2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}, {2262,4}}, outfit_female = 26621, outfit_male = 26621, addon = 1, storageID = 10050}, ['paralyse rune'] = {cost = 20, items = {{2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}, {2278,2}}, outfit_female = 26622, outfit_male = 26622, addon = 1, storageID = 10051}, ['energy field rune'] = {cost = 20, items = {{2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}, {2277,5}}, outfit_female = 26623, outfit_male = 26623, addon = 1, storageID = 10011}, ['energy wall rune'] = {cost = 20, items = {{2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}, {2279,6}}, outfit_female = 26624, outfit_male = 26624, addon = 1, storageID = 10012}, ['intense healing rune'] = {cost = 20, items = {{2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}, {2265,2}}, outfit_female = 28263, outfit_male = 28263, addon = 1, storageID = 10013}, ['destroy field rune'] = {cost = 20, items = {{2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}, {2261,5}}, outfit_female = 26626, outfit_male = 26626, addon = 1, storageID = 10014}, ['fire wall rune'] = {cost = 20, items = {{2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}, {2303,6}}, outfit_female = 26625, outfit_male = 26625, addon = 1, storageID = 10015}, ['fire bomb rune'] = {cost = 20, items = {{2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}, {2305,4}}, outfit_female = 26628, outfit_male = 26628, addon = 1, storageID = 10016}, ['poison bomb rune'] = {cost = 20, items = {{2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}, {2286,4}}, outfit_female = 26629, outfit_male = 26629, addon = 1, storageID = 10017}, ['light magic missile rune'] = {cost = 20, items = {{2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}, {2287,10}}, outfit_female = 26630, outfit_male = 2630, addon = 1, storageID = 10018}, ['fire field rune'] = {cost = 20, items = {{2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}, {2301,5}}, outfit_female = 26631, outfit_male = 26631, addon = 1, storageID = 10019}, ['great iceball rune'] = {cost = 20, items = {{28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}, {28247,3}}, outfit_female = 28246, outfit_male = 28246, addon = 1, storageID = 10020} -- next storage 10052 -- next storage 10052 -- next storage 10052 -- next storage 10052 -- next storage 10052 -- next storage 10052 -- next storage 10052 -- } local o = {'intense healing rune', 'ultimate healing rune', 'light magic missile rune', 'heavy magic missile rune', 'holy missile rune', 'explosion rune', 'sudden death rune', 'magic wall rune', 'fireball rune', 'great fireball rune', 'great iceball rune', 'paralyse rune', 'destroy field rune', 'energy field rune', 'energy wall rune', 'energy bomb rune', 'fire field rune', 'fire wall rune', 'fire bomb rune', } function creatureSayCallback(cid, type, msg) local talkUser = cid if(not npcHandler:isFocused(cid)) then return false end if addoninfo[msg] ~= nil then if (getPlayerStorageValue(cid, addoninfo[msg].storageID) ~= -1) then npcHandler:say('Parece que ocorreu algum erro!', cid) npcHandler:resetNpc() else local itemsTable = addoninfo[msg].items local items_list = '' if table.maxn(itemsTable) > 0 then for i = 1, table.maxn(itemsTable) do local item = itemsTable[i] items_list = items_list .. item[2] .. ' ' .. ItemType(item[1]):getName() if i ~= table.maxn(itemsTable) then items_list = items_list .. ', ' end end end local text = '' if (addoninfo[msg].cost > 0) then text = addoninfo[msg].cost .. ' gp' elseif table.maxn(addoninfo[msg].items) then text = items_list elseif (addoninfo[msg].cost > 0) and table.maxn(addoninfo[msg].items) then text = items_list .. ' e ' .. addoninfo[msg].cost .. ' gp' end npcHandler:say('Para ' .. msg .. ' você precisará de 20 destas runas com suas cargas e 20gps. Você tem todas com suas devidas cargas com você?', cid) rtnt[talkUser] = msg talkState[talkUser] = addoninfo[msg].storageID return true end elseif msgcontains(msg, "yes") or msgcontains(msg, "sim") then if (talkState[talkUser] > 10010 and talkState[talkUser] < 10100) then local items_number = 0 if table.maxn(addoninfo[rtnt[talkUser]].items) > 0 then for i = 1, table.maxn(addoninfo[rtnt[talkUser]].items) do local item = addoninfo[rtnt[talkUser]].items[i] if (getPlayerItemCount(cid,item[1]) >= item[2]) then items_number = items_number + 1 end end end if(getPlayerMoney(cid) >= addoninfo[rtnt[talkUser]].cost) and (items_number == table.maxn(addoninfo[rtnt[talkUser]].items)) then doPlayerRemoveMoney(cid, addoninfo[rtnt[talkUser]].cost) if table.maxn(addoninfo[rtnt[talkUser]].items) > 0 then for i = 1, table.maxn(addoninfo[rtnt[talkUser]].items) do local item = addoninfo[rtnt[talkUser]].items[i] doPlayerRemoveItem(cid,item[1],item[2]) if container:getSize() == 0 then container:remove() end end end doPlayerAddItem(cid, addoninfo[rtnt[talkUser]].outfit_male) npcHandler:say('Aqui está seu pacote.', cid) else npcHandler:say('Você não tem as runas, cargas ou o dinheiro necessário!', cid) end rtnt[talkUser] = nil talkState[talkUser] = 0 npcHandler:resetNpc() return true end elseif msgcontains(msg, "runas") then npcHandler:say('Ofereço suporte para troca por pacotes nas seguintes runas: {' .. table.concat(o, "}, {") .. '}', cid) rtnt[talkUser] = nil talkState[talkUser] = 0 npcHandler:resetNpc() return true elseif msgcontains(msg, "ajuda") then npcHandler:say('Para trocar pelos pacotes você necessita de 20 runas respectivamente conjuradas e com suas devidas cargas originais. Para trocar, basta dizer o nome da runa completo referente a lista na aba {runas}. Exemplo: {ultimate healing rune}.', cid) rtnt[talkUser] = nil talkState[talkUser] = 0 npcHandler:resetNpc() return true else if talkState[talkUser] ~= nil then if talkState[talkUser] > 0 then npcHandler:say('Volte quando obtiver as runas e cargas necessárias.', cid) rtnt[talkUser] = nil talkState[talkUser] = 0 npcHandler:resetNpc() return true end end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Oi @Vodkart, valeu o retorno e obrigado por ajudar! Editado Fevereiro 21, 2019 6 anos por Camilo Salvadori (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.