Postado Outubro 10, 2022 2 anos Boa noite, queria saber se é possível fazer um ESTOQUE DE ITEM em um NPC, ele irá aceitar como pagamento "X MOEDA". Exemplo: Vou colocar 10 quantidades de X item, porém, só é possível comprar 1 por vez. Ou se for possível adicionar essa função no SHOP do site MordenACC.
Postado Outubro 11, 2022 2 anos Veja se é isso o que você está procurando. TFS 0.4: em data > npc > Testador.xml: <?xml version="1.0" encoding="UTF-8"?> <npc name="Testador" script="data/npc/scripts/Testador.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="160" head="77" body="79" legs="56" feet="115" addons="0"/> <parameters> <parameter key="message_greet" value="Ola |PLAYERNAME|! Deseja {comprar} alguma coisa?"/> </parameters> </npc> data > npc > scripts > Testador.lua: -- Imperius ~ Alecrim 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 = {} local configNPC = { storage = 40004400, estoque = 10, -- Quantas vezes o player poderá comprar este item? itemID = 2400, -- ID do item que será vendido pelo NPC moedaID = 6500, -- ID da moeda de troca customizada. valor = 45, -- Quantas moedas o player precisará ter para comprar o item? } function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if getPlayerStorageValue(cid, configNPC.storage) < 0 then setPlayerStorageValue(cid, configNPC.storage, configNPC.estoque) end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local msg = string.lower(msg) local itemName = getItemNameById(configNPC.itemID) local moedaName = getItemNameById(configNPC.moedaID) if isInArray({"comprar", "buy"}, msg) then if getPlayerStorageValue(cid, configNPC.storage) < 1 then selfSay("Voce já comprou todo o meu estoque.", cid) npcHandler:releaseFocus(cid) else selfSay("Voce quer trocar 1x {"..itemName.."} por "..configNPC.valor.."x {"..moedaName.."}?", cid) talkState[talkUser] = 1 end end if isInArray({"sim", "yes"}, msg) and talkState[talkUser] == 1 then talkState[talkUser] = 0 if getPlayerItemCount(cid, configNPC.moedaID) >= configNPC.valor then setPlayerStorageValue(cid, configNPC.storage, getPlayerStorageValue(cid, configNPC.storage) - 1) -- Atualiza o estoque do player doPlayerRemoveItem(cid, configNPC.moedaID, configNPC.valor) -- Remove as moedas do player doPlayerAddItemEx(cid, doCreateItemEx(configNPC.itemID, 1)) -- Da o item ao player doSendMagicEffect(getThingPos(cid), 13) -- Da um efeitinho no player selfSay("Certo! Troca realizada.", cid) else selfSay("Você não tem a quantidade de "..moedaName.." o suficiente", cid) npcHandler:releaseFocus(cid) end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
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.