Ir para conteúdo
Entre para seguir isso  
Criticoo

[NPC] Spell Seller por Trade

Recommended Posts

Criticoo    4
Criticoo

Explicação:

É um npc diferenciado, onde você compra a spells com npc pelo trade!

 

ZDUid.png

 

 

 

 

Spell Seller.xml

<?xml version="1.0"?>
<npc name="Spell Seller" script="data/npc/scripts/spell_trade.lua" walkinterval="50000" floorchange="0">
<health now="100" max="100"/>
<look type="129" head="95" body="116" legs="121" feet="115" addons="3"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|.I have many {spells} to sell for you! {trade}" />
</parameters>
</npc>

 

 

 

 

spell_trade.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 shopWindow = {}
local spells = {
{id=1950, buy = 150, name = "Exana Pox", spell_name = "Andidote", vocations = {1,2,3,4,5,6,7,8}, level = 10},
{id=1950, buy = 2500, name = "Exori", spell_name = "Berserk", vocations = {4,8}, level = 35},
{id=1950, buy = 80, name = "Exiva", spell_name = "Find Person", vocations = {1,2,3,4,5,6,7,8}, level = 8},
{id=2182, buy = 5000, name = "Exori Flam", spell_name = "Flame Strike", vocations = {1,2,5,6}, level = 12},
{id=1950, buy = 8000, name = "Utito Tempo", spell_name = "Blood Rage", vocations = {4,8}, level = 60},
{id=1950, buy = 2000, name = "Exeta Res", spell_name = "Challenge", vocations = {8}, level = 20},
{id=1950, buy = 5000, name = "Exori Gran", spell_name = "Fierce Berserk", vocations = {4,8}, level = 70},
{id=1950, buy = 500, name = "Utevo Gran Lux", spell_name = "Great Light", vocations = {1,2,3,4,5,6,7,8}, level = 13},
{id=1950, buy = 1500, name = "Exori Mas", spell_name = "Groundshaker", vocations = {4,8}, level = 33},
{id=1950, buy = 1500, name = "Exana Mort", spell_name = "Wound Cleansing", vocations = {4,8}, level = 30}
}
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if not getPlayerLearnedInstantSpell(cid, shopWindow[item].Words) then
if getPlayerLevel(cid) >= shopWindow[item].Level then
if isInArray(shopWindow[item].Vocs, getPlayerVocation(cid)) then
doPlayerRemoveMoney(cid, shopWindow[item].Price)
doPlayerLearnInstantSpell(cid, shopWindow[item].Words)
npcHandler:say("You have learned "..shopWindow[item].Words, cid)
else
npcHandler:say("This spell is not for your vocation.", cid)
end
else
npcHandler:say("You need to obtain a level of "..shopWindow[item].Level.." or higher to be able to learn this spell.", cid)
end
else
npcHandler:say("You already know this spell.", cid)
end
return true
end
if msgcontains(msg, 'trade') or msgcontains(msg, 'spells') then
for var, item in pairs(spells) do
shopWindow[item.id] = {Level = item.level, Vocs = item.vocations, item_id = item.id, Price = item.buy, subType = 0, Words = item.spell_name, SpellName = item.name}
end
openShopWindow(cid, spells, onBuy, onSell)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Editado por Criticoo

Compartilhar este post


Link para o post
Tio Gordo    8
Tio Gordo

Entendi o script perfeitamente, porém não há uma descrição sobre o real funcionamento dela. Algumas pessoas podem não entender.

Idente-a de maneira mais clara por favor.

Você tem 72 horas, caso contrário, o tópico será fechado.

 

Edit: Bem, melhorou um pouco em relação à introdução. Estarei aprovando o tópico porém, num futuro novo conteúdo tente ser mais claro e melhor formatado o código, ok?

 

Obrigado pela contribuição!

Editado por Tio Gordo

Compartilhar este post


Link para o post
Criticoo    4
Criticoo
Entendi o script perfeitamente, porém não há uma descrição sobre o real funcionamento dela. Algumas pessoas podem não entender.

Idente-a de maneira mais clara por favor.

Você tem 72 horas, caso contrário, o tópico será fechado.

 

Edit: Bem, melhorou um pouco em relação à introdução. Estarei aprovando o tópico porém, num futuro novo conteúdo tente ser mais claro e melhor formatado o código, ok?

 

Obrigado pela contribuição!

 

Ser mais claro? mais claro para você de certo, porque o titulo do tópico já é auto explicativo, SPELL SELLER POR TRADE!

Quem não iria entender isso? para que ficar dando detalhes do óbvio?

Compartilhar este post


Link para o post
MaXwEllDeN    13
MaXwEllDeN
Ser mais claro? mais claro para você de certo, porque o titulo do tópico já é auto explicativo, SPELL SELLER POR TRADE!

Quem não iria entender isso? para que ficar dando detalhes do óbvio?

 

 

Eu não entendí ):

 

 

 

 

 

 

Brink's. Gostei da ideia hein :D

Compartilhar este post


Link para o post
iuniX    4
iuniX

Indentação? NEVER!

Compartilhar este post


Link para o post
Conde2    0
Conde2
Indentação? NEVER!

 

No caso foi o quote do fórum que quebrou a identaçao.

legal o script ta de parabéns bom trabalho

Compartilhar este post


Link para o post
nykee29    0
nykee29

Nossa Cara Muito Legal, Super Original =D

Compartilhar este post


Link para o post
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×