Ir para conteúdo
Banner com Efeitos

Featured Replies

  • Respostas 7
  • Visualizações 3.2k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Tenta assim amigo : "data/npc/scripts/trocaitems.lua" : local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local tal

Postado

Tenta assim amigo :

"data/npc/scripts/trocaitems.lua" :

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 playerHaveItems(cid, itemid)
local items = type(itemid) == "table" and itemid or {itemid}
for i = 1, #items do
if getPlayerItemCount(cid, items[i]) <= 0 then
return false
end
end
return true
end

function doPlayerRemoveItems(cid, itemid, count)
local items = type(itemid) == "table" and itemid or {itemid}
for i = 1, #items do
doPlayerRemoveItem(cid, items[i], count ~= nil and count or 1)
end
return nil
end

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then
return false
end

if msgcontains(msg, "trocar") then
if playerHaveItems(cid, {1234, 1235, 1236, 1237, 1238, 1239, 1240}) then
doPlayerRemoveItems(cid, {1234, 1235, 1236, 1237, 1238, 1239, 1240}, 10)
doPlayerAddItem(cid, 2160, 10)
else
selfSay("Voce precisa de 1 item, 1 item, 1 item, 1 item, 1 item, 1 item e 1 item, para conseguir trocar por um item.")
end
end 
return true

endnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

"data/npc/Osvaldo.xml"

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Osvaldo" script="trocaitems.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="146" head="123" body="74" legs="123" feet="0" addons="2"/>
<parameters>
<parameter key="message_greet" value="Olá,fale {trocar} para trocar items por comigo."/>
</parameters>
</npc>

obs : caso não entenda como funciona o script fale que eu posto como "citar" e com cores para você identificar melhor! ^^

Postado

if playerHaveItems(cid, {1234, 1235, 1236, 1237, 1238, 1239, 1240}) then
doPlayerRemoveItems(cid, {1234, 1235, 1236, 1237, 1238, 1239, 1240}, 10)
doPlayerAddItem(cid, 2160, 10)

 

Se vc tiver 10 quantiodades de playerHaveItems(cid, {1234, 1235, 1236, 1237, 1238, 1239, 1240})  fça... remova 10 quantidade desses itens e de 10 do item 2160 para o player(10 cristal)

Scripter: |||||||||| 10%

 

 

Te ajudei?? REP + e ficamos quites...  ;D

 

Atenciosamente,

                   Lucas.

Abraços!

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo