Bom dia galera, eu gostaria de uma script de um npc que troca os seguintes itens ( uso TFS 0.3.6 )
5x de cada id > 8976 + 5x 8978 pelo 8980
1x > 4863 pelo 4864
10x 5894 ou o id 10x 5898 pelo id 5904 ( o player escolhe qual item dar )
Bom dia galera, eu gostaria de uma script de um npc que troca os seguintes itens ( uso TFS 0.3.6 )
5x de cada id > 8976 + 5x 8978 pelo 8980
1x > 4863 pelo 4864
10x 5894 ou o id 10x 5898 pelo id 5904 ( o player escolhe qual item dar )
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 = {
name = "Mana Fluid", -- Nome do item necessário para a troca (5x)
id = 8976 -- ID do item necessário para a troca
},
item2 = {
name = "Health Fluid", -- Nome do item necessário para a troca (5x)
id = 8978 -- ID do item necessário para a troca
},
item3 = {
name = "Life Fluid", -- Nome do item que será dado em troca
id = 8980 -- ID do item que será dado em troca
},
item4 = {
name = "Blank Rune", -- Nome do item necessário para a troca (1x)
id = 4863 -- ID do item necessário para a troca
},
item5 = {
name = "Ultimate Healing Rune", -- Nome do item que será dado em troca
id = 4864 -- ID do item que será dado em troca
},
item6 = {
name = "Great Mana Potion", -- Nome do item necessário para a troca (10x)
id = 5894 -- ID do item necessário para a troca
},
item7 = {
name = "Strong Mana Potion", -- Nome do item necessário para a troca (10x)
id = 5898 -- ID do item necessário para a troca
},
item8 = {
name = "Ultimate Mana Potion", -- Nome do item que será dado em troca
id = 5904 -- ID do item que será dado em troca
},
sto = 6464 -- Storage
}
if (msgcontains(msg, 'yes')) then
if (getPlayerStorageValue(cid, config.sto) == -1) then
if (getPlayerItemCount(cid, config.item1.id) >= 5 and getPlayerItemCount(cid, config.item2.id) >= 5) then
selfSay(cid, 'Você trocou 5 ' .. config.item1.name .. ' e 5 ' .. config.item2.name .. ' por um ' .. config.item3.name .. '.')
doPlayerAddItem(cid, config.item3.id, 1)
doPlayerRemoveItem(cid, config.item1.id, 5)
doPlayerRemoveItem(cid, config.item2.id, 5)
setPlayerStorageValue(cid, config.sto, 1)
elseif (getPlayerItemCount(cid, config.item4.id) >= 1) then
selfSay(cid, 'Você trocou um ' .. config.item4.name .. ' por um ' .. config.item5.name .. '.')
doPlayerAddItem(cid, config.item5.id, 1)
doPlayerRemoveItem(cid, config.item4.id, 1)
setPlayerStorageValue(cid, config.sto, 1)
elseif (getPlayerItemCount(cid, config.item6.id) >= 10 or getPlayerItemCount(cid, config.item7.id) >= 10) then
selfSay(cid, 'Qual item você deseja trocar? Digite "' .. config.item6.name .. '" ou "' .. config.item7.name .. '".')
talkState[talkUser] = 1
else
selfSay(cid, 'Você não possui os itens necessários para a troca.')
end
else
selfSay(cid, 'Você já realizou essa troca.')
end
return true
elseif (talkState[talkUser] == 1) then
if (msgcontains(msg, config.item6.name)) then
if (getPlayerItemCount(cid, config.item6.id) >= 10) then
selfSay(cid, 'Você trocou 10 ' .. config.item6.name .. ' por um ' .. config.item8.name .. '.')
doPlayerAddItem(cid, config.item8.id, 1)
doPlayerRemoveItem(cid, config.item6.id, 10)
setPlayerStorageValue(cid, config.sto, 1)
else
selfSay(cid, 'Você não possui os itens necessários para a troca.')
end
talkState[talkUser] = 0
elseif (msgcontains(msg, config.item7.name)) then
if (getPlayerItemCount(cid, config.item7.id) >= 10) then
selfSay(cid, 'Você trocou 10 ' .. config.item7.name .. ' por um ' .. config.item8.name .. '.')
doPlayerAddItem(cid, config.item8.id, 1)
doPlayerRemoveItem(cid, config.item7.id, 10)
setPlayerStorageValue(cid, config.sto, 1)
else
selfSay(cid, 'Você não possui os itens necessários para a troca.')
end
talkState[talkUser] = 0
else
selfSay(cid, 'Opção inválida. Digite "' .. config.item6.name .. '" ou "' .. config.item7.name .. '".')
end
return true
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
ai um simples que eu uso . TSF 0.3.6 msm
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
msg = string.lower(msg)
---------
local need = { --itens que o npc pede
{id = 12163, qt = 5000}, --seed
{id = 12155, qt = 300}, -- leaves
}
local rewards = { --item que o npc da
{id = 12618, qt = 1}, --booststone
}
local stoFinish = 92090
---------
if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') then
if getPlayerStorageValue(cid, stoFinish) >= 1 then
selfSay("Sorry, you already had done this quest.", cid)
talkState[talkUser] = 0
return true
end
selfSay("Hello my friend, can you bring to me: 5000 Seed and 300 Leaves? I will reward you!",cid)
talkState[talkUser] = 1
return true
elseif msgcontains(msg, 'yes') or msgcontains(msg, 'sim') and talkState[talkUser] == 1 then
if getPlayerItemCount(cid, need[1].id) < need[1].qt or getPlayerItemCount(cid, need[2].id) < need[2].qt then
selfSay("You don't brought to me all the items what i asked for...", cid)
selfSay("Remember, you need to bring to me 5000 Seed and 300 leaves...", cid)
talkState[talkUser] = 0
return true
end
for i = 1, #need do
doPlayerRemoveItem(cid, need[i].id, need[i].qt)
end
for i = 1, #rewards do
doPlayerAddItem(cid, rewards[i].id, rewards[i].qt)
doPlayerAddExperience(cid, 800000)
end
selfSay("thanks you, bye!", cid)
setPlayerStorageValue(cid, stoFinish, 1)
talkState[talkUser] = 0
return true
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())