Não intendi nada. quem compra? o player ou o npc?
explica detalhado rapaz, se não ninguém vai te ajudar -.-
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

Não intendi nada. quem compra? o player ou o npc?
explica detalhado rapaz, se não ninguém vai te ajudar -.-
info
Grupo: Cavaleiro
Registrado: 13/06/11
Posts: 172
Reputação: +6

aquilo "(compra)" é o npc que vai compra de vc tendeu?
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
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 greetCallback(cid)
talkState[talkUser] = 0
return true
end
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
return false
end
local trade = {
{id=2434, sell=2000, name="dragon hammer"},
{id=2393, sell=17000, name="giant sword"},
{id=2430, sell=2000, name="knight axe"},
{id=2411, sell=50, name="poison dagger"}
}
local items = {}
for _, item in ipairs(trade) do
items[item.id] = {item_id = item.id, sellPrice = item.sell, subType = 0, realName = item.name}
end
local onSell = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if items[item].sellPrice ~= 0 then
doPlayerAddMoney(cid, items[item].sellPrice * amount)
doPlayerRemoveItem(cid, items[item].item_id, amount)
end
end
if msgcontains(msg, 'trade') then
if getPlayerItemCount(cid, 2123) >= 1 then
openShopWindow(cid, trade, onBuy, onSell)
else
selfSay("Não compro nada para você!", cid)
end
return true
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
só terminar de adicionar o item, preço e nome do item aqui na tabela
local trade = {
{id=2434, sell=2000, name="dragon hammer"},
{id=2393, sell=17000, name="giant sword"},
{id=2430, sell=2000, name="knight axe"},
{id=2411, sell=50, name="poison dagger"}
}
info
Grupo: Cavaleiro
Registrado: 13/06/11
Posts: 172
Reputação: +6

ajuda ai ![]()

a vlw
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

já terminei, só falta você completar a tabela
info
Grupo: Cavaleiro
Registrado: 13/06/11
Posts: 172
Reputação: +6

eu nao sei fazer isso mais eu vo tentar '-'
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

o que? é só ir no items.xml e dar ctrl + f e procurar o nome da arma, ai você pega o id dela e depois coloca o preço ali na tabela '-'
info
Grupo: Cavaleiro
Registrado: 13/06/11
Posts: 172
Reputação: +6

mais mais nao sei onde coloka nem pastas onde coloka eu sou um inutil
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

então faz o seguinte, a tabela você sabe afzer ali? quando vc termina vc me mostra, que eu faço os arquivo lua e xml do npc
flw
info
Grupo: Cavaleiro
Registrado: 13/06/11
Posts: 172
Reputação: +6

local trade = {
{id=2434, sell=2000, name="dragon hammer"},
{id=2393, sell=17000, name="giant sword"},
{id=2430, sell=2000, name="knight axe"},
{id=2411, sell=50, name="poison dagger"}
{id=2419, sell=150, name="scimitar"}
{id=2409, sell=900, name="serpent sword"}
{id=2436, sell=6000, name="skull staff"}
{id=2396, sell=5000, name="ice rapier"}
{id=2489, sell=400, name="dark armor"}
{id=2476, sell=5000, name="knight armor"}
{id=2490, sell=250, name="dark helmet"}
{id=2663, sell=150, name="mystic turban"}
{id=2479, sell=500, name="strange helmet"}
{id=2475, sell=5000, name="warrior helmet"}
{id=2477, sell=5000, name="knight legs"}
{id=2532, sell=900, name="ancient shield"}
{id=2529, sell=800, name="black shield"}
{id=2528, sell=8000, name="tower shield"}
{id=2534, sell=15000, name="vampire shield"}
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

Npc
Nome do seu npc.xml
<?xml version="1.0"?> <npc name="Nome do seu npc" script="data/npc/scripts/trade_honor.lua" walkinterval="50000" floorchange="0"> <health now="1000" max="1000"/> <look type="130" head="0" body="114" legs="114" feet="0" addons="0"/> <parameters> <parameter key="message_greet" value="Hello |PLAYERNAME|. I buy swords, clubs, axes, helmets, boots, legs, shields and armors."/> </parameters> </npc>
NPC/script
trade_honor.lua
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
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 greetCallback(cid)
talkState[talkUser] = 0
return true
end
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
return false
end
local trade = {
{id=2434, sell=2000, name="dragon hammer"},
{id=2393, sell=17000, name="giant sword"},
{id=2430, sell=2000, name="knight axe"},
{id=2411, sell=50, name="poison dagger"},
{id=2419, sell=150, name="scimitar"},
{id=2409, sell=900, name="serpent sword"},
{id=2436, sell=6000, name="skull staff"},
{id=2396, sell=5000, name="ice rapier"},
{id=2489, sell=400, name="dark armor"},
{id=2476, sell=5000, name="knight armor"},
{id=2490, sell=250, name="dark helmet"},
{id=2663, sell=150, name="mystic turban"},
{id=2479, sell=500, name="strange helmet"},
{id=2475, sell=5000, name="warrior helmet"},
{id=2477, sell=5000, name="knight legs"},
{id=2532, sell=900, name="ancient shield"},
{id=2529, sell=800, name="black shield"},
{id=2528, sell=8000, name="tower shield"},
{id=2534, sell=15000, name="vampire shield"}
}
local items = {}
for _, item in ipairs(trade) do
items[item.id] = {item_id = item.id, sellPrice = item.sell, subType = 0, realName = item.name}
end
local onSell = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if items[item].sellPrice ~= 0 then
doPlayerAddMoney(cid, items[item].sellPrice * amount)
doPlayerRemoveItem(cid, items[item].item_id, amount)
end
end
if msgcontains(msg, 'trade') then
if getPlayerItemCount(cid, 2123) >= 1 then
openShopWindow(cid, trade, onBuy, onSell)
else
selfSay("Não compro nada para você!", cid)
end
return true
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
info
Grupo: Cavaleiro
Registrado: 13/06/11
Posts: 172
Reputação: +6
quero um npc que só funcione se vc estiver usando uma medal of honour
( apenas com medal of honour )
-- Armas (Compra)
Dragon hammer (2000gps), Giant Sword (17000gps), Knight Axe (2000gps), Poison dagger (50gps), Scimitar (150gps), Serpent sword (900gps), Skull staff (6000gps)
(Vende)
Ice Rapier (5000gps), Serpent sword (6000gps)
-- Armor (Compra)
Dark Armor (400gps), Knight Armor (5000gps)
(Vende)
Dark Armor (1000gps)
-- Helmet Compra)
Dark helmet (250gps), Mystic turban (150gps), Strange Helmet (500gps), Warrior helmet (5000gps)
(Vende)
Dark Helmet (1000gps)
-- Legs (Compra)
Knight legs (5000gps) -- Shields (Compra)
Ancient shield (900gps), Black Shield (800gps), Tower shield (8000gps), Vampire Shield (15000gps)
(Vende)
Ancient Shield (5000gps)
ot 8.60
Editado Maio 1 por neero102