Postado Junho 18, 2017 8 anos Olá, quem puder me ajudar, eu preciso de um script básico mesmo de um npc que troque 5 itens por 1. O player chega com os 5 itens, e fala "hi", "change", "yes", e recebe o item X.
Postado Junho 18, 2017 8 anos Solução XML <?xml version="1.0" encoding="UTF-8"?> <npc name="sensei" script="data/npc/scripts/npc.lua" walkinterval="2000" speed="0" floorchange="0"> <health now="100" max="100"/> <look type="45" head="19" body="113" legs="95" feet="115" addons="0"/> <parameters> <parameter key="message_greet" value="Olá , deseja trocar 5 item por 1 item ?? {yes}" /> </parameters> </npc> SCRIPT Spoiler 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 creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local config = { item1 = 8303, -- ID DO PRIMEIRO ITEM item2 = 2141, -- ID DO SEGUNDO ITEM item3 = 5785, -- ID DO TERCEIRO ITEM item4 = 3452, -- ID DO QUARTO ITEM item5 = 2643, -- ID DO QUINTO ITEM qnt1 = 1, -- QUANTIDADE DO PRIMEIRO ITEM QUE PRECISA qnt2 = 1, -- QUANTIDADE DO SEGUNDO ITEM QUE PRECISA qnt3 = 1, -- QUANTIDADE DO TERCEIRO ITEM QUE PRECISA qnt4 = 1, -- QUANTIDADE DO QUARTO ITEM QUE PRECISA qnt5 = 1, -- QUANTIDADE DO QUINTO ITEM QUE PRECISA items = 7958, -- ID DO ITEM QUE IRA GANHAR AO TROCAR qnts = 1, -- QUANTIDADE DO ITEM QUE GANHARA AO TROCAR sto = 34523 } if(msgcontains(msg, 'yes')) then if getPlayerStorageValue(cid, config.sto) == -1 then if getPlayerItemCount(cid, config.item1) >= config.qnt1 then if getPlayerItemCount(cid, config.item2) >= config.qnt2 then if getPlayerItemCount(cid, config.item3) >= config.qnt3 then if getPlayerItemCount(cid, config.item4) >= config.qnt4 then if getPlayerItemCount(cid, config.item5) >= config.qnt5 then doPlayerAddItem(cid, config.items, 1) selfSay(cid , 'Voce trocou 5 item por 1 item') setPlayerStorageValue(cid, config.sto, 1) doPlayerRemoveItem(cid, config.item1, config.qnt1) doPlayerRemoveItem(cid, config.item2, config.qnt2) doPlayerRemoveItem(cid, config.item3, config.qnt3) doPlayerRemoveItem(cid, config.item4, config.qnt4) doPlayerRemoveItem(cid, config.item5, config.qnt5) else selfSay('voce n tem o item ou a quantidade certa', cid) end else selfSay('voce n tem o item ou a quantidade certa', cid) end else selfSay('voce n tem o item ou a quantidade certa', cid) end else selfSay('voce n tem o item ou a quantidade certa', cid) end else selfSay('voce n tem o item ou a quantidade certa', cid) end else selfSay(cid, 'Voce ja trocou') end return true end 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.