LE

Npc Que Vende Itens Por Outro Tipo De Dinheiro

Por lelvillela, 15 de fev. de 2012 em Archived

script
3
982
lelvillelaL
15 de fevereiro de 2012 às 20:32

Olá, estou com um servidor 8.6, baiak ice e não tenho muita experiência com scripts.

 

Estava procurando um NPC que venda os itens vips que eu editei em meu servidor, mas não pelo dinheiro convencional. Queria que ele vendesse por Gold Nuggets, Golg Ingots, ou qualquer outro tipo de item!

 

Desde já, obrigado pela atenção!

VodkartV
17 de fevereiro de 2012 às 11:49

Nome do seu npc.xml

<?xml version="1.0"?>
<npc name="Nome do seu npc" script="data/npc/scripts/nome do seu script.lua" walkinterval="5000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
<parameters>
<parameter key="message_greet" value="Ola |PLAYERNAME|. eu posso vender alguns itens... {trade} ? " />
</parameters>
</npc>

 

em npc/script

 

nome do seu script.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 creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

local moeda = 2157
local t = {
     ["boots of haste"] = {15, 2195},
     ["demon helmet"] = {25, 2493},
     ["frozen starlight"] = {30, 2361},
     ["royal crossbow"] = {20, 8851},
     ["solar axe"] = {30, 8925},
     ["soft boots"] = {50, 2640},
     ["demon armor"] = {100, 2494},
     ["firewalker boots"] = {50, 9932},
     ["magic plate armor"] = {70, 2472},
     ["flame blade"] = {100, 8931}
     }

if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
local str = ""
str = str .. "Eu vendo estes items: "
for name, pos in pairs(t) do
str = str.." {"..name.."} = "..pos[1].." Moedas /"
end
str = str .. "." 
npcHandler:say(str, cid)
elseif t[msg] then
       if doPlayerRemoveItem(cid,moeda,t[msg][1]) then
           doPlayerAddItem(cid,t[msg][2],1)
           npcHandler:say("Aqui está seu ".. getItemNameById(t[msg][2]) .."!", cid)
       else
           npcHandler:say("você não tem "..t[msg][1].." ".. getItemNameById(moeda), cid)
       end
end 
return TRUE 
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

 

só ir adicionando...

 

["nome do item"] = {quantidade de gold nugget , id do item que será vendido}

lelvillelaL
22 de fevereiro de 2012 às 17:13

Brigadão! Depois eu testo e falo se funcionou :D