Postado Fevereiro 11, 2016 9 anos 1 hora atrás, Daniel augusto silva disse: agora do n no npc nao da nada Ele responde que não tem os items? Caso não, verifica se essa função está no lugar certo. doPlayerAddItem(cid, 2090, 1)
Postado Fevereiro 11, 2016 9 anos 1 hora atrás, Daniel augusto silva disse: ele n ta mais no/n em nada Posta o script como está sendo usado.
Postado Fevereiro 11, 2016 9 anos Autor function playerHaveItems(cid, items) if not (type (items) == "table") then return false end for item, quant in pairs (items) do if getPlayerItemCount(cid, item) < quant then return false end end return true end function doPlayerRemoveItems(cid, items) if not (type (items) == "table") then return false end if not (playerHaveItems(cid, iremos)) then return false end for itemid, quant in pairs(items) do doPlayerRemoveItem(cid, itemid, quant) end return true end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end e no .xml <?xml version="1.0" encoding="UTF-8"?> -<npc floorchange="0" walkinterval="2000" script="trocaitems.lua" name="Fernando"><health max="100" now="100"/><look addons="2" feet="0" legs="114" body="86" head="114" type="1813"/>-<parameters><parameter value="Ola, diga {trocar} para trocar 3 items por 1." key="message_greet"/></parameters></npc> if msgcontains(msg, "trocar") then local items = { -- [itemid] = quantidade [2134] = 1, [2174] = 1, [2159] = 1 } if (doPlayerRemoveItems(cid,items)) then doPlayerAddItem(cid, 2090, 1) else selfSay("Você Não tem os itens necessarios.") end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Editado Fevereiro 11, 2016 9 anos por Daniel augusto silva (veja o histórico de edições)
Postado Fevereiro 11, 2016 9 anos 1 hora atrás, Daniel augusto silva disse: function playerHaveItems(cid, items) if not (type (items) == "table") then return false end for item, quant in pairs (items) do if getPlayerItemCount(cid, item) < quant then return false end end return true end function doPlayerRemoveItems(cid, items) if not (type (items) == "table") then return false end if not (playerHaveItems(cid, iremos)) then return false end for itemid, quant in pairs(items) do doPlayerRemoveItem(cid, itemid, quant) end return true end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, "trocar") then local items = { -- [itemid] = quantidade [2134] = 1, [2174] = 1, [2159] = 1 } if (doPlayerRemoveItems(cid,items)) then doPlayerAddItem(cid, 2090, 1) else selfSay("Você Não tem os itens necessarios.") end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Jesus, Maria e José... oque é isso? Não era para retirar nada além do que eu pedi que fosse moeificado, isso continua no script, sem ele o npc não funciona: Citar 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
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.