Eu fiz para o Dark Onix, mas como está offline irei postar.
Com esse script, quando um player falar 'buy 100 sudden death', ao invéz de dar uma runa de 100x de sd, irá dar 100 runas de sd com 3x (ou a quantidade de charges que você colocou no script).
Primeiro, vamos a function. Abra o arquivo npc/scripts/lib/npc.lua vá até o final, depois do último end e adcione:
-- buy runes as global by Yuniefunction buyrunes(cid, runeid, count, countcharges, costrune)
count1 = 0
amount = count
cost = count*costrune
if doPlayerRemoveMoney(cid, cost) == 1 then
selfSay('It was a pleasure dealing with you. Back here when you need more magic things.')
while count > count1 do
doPlayerAddItem(cid, runeid, countcharges)
count1 = count1 + 1
end
else
selfSay('Sorry, you don\'t have enough money.')
end
end
Salve e feche.
Agora explicando a function.
Sintaxe:
buyrunes(cid, runeid, count, countcharges, costrune)
NPC:
Agora, um NPC já pronto com essa function.
Crie um arquivo em npc/scripts com o nome de runesbyyunie.lua, nele adcione:
local focus = 0local talk_start = 0
local target = 0
local following = false
local attacking = false
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_start = 0
end
end
function onCreatureTurn(creature)
end
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
function onCreatureSay(cid, type, msg)
local msg = string.lower(msg)
if msgcontains(msg, 'hi') and focus == 0 and getDistanceToCreature(cid) < 4 then
selfSay('Hello ' .. creatureGetName(cid) .. '! I sell runes, potions, wands and rods.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and focus ~= cid and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'runes') then
selfSay('I sell heavy magic missile (125 gold coins each), great fireball (175 gold coins each), ultimate healing (175 gold coins each), explosion (250 gold coins each), sudden death (325 gold coins each), magic wall (350 gold coins each), destroy (100 gold coins each), firebomb (275 gold coins each).')
elseif msgcontains(msg, 'wands') then
selfSay('I sell wand of inferno (15000 gold coins), cosmic energy (10000 gold coins), decay (5000 gold coins), dragonbreath (1000 gold coins) and vortex (free).')
elseif msgcontains(msg, 'rods') then
selfSay('I sell hailstorm (15000 gold coins), terra (10000 gold coins), necrotic (5000 gold coins), moonlight (1000 gold coins) and snakebite (free).')
elseif msgcontains(msg, 'potions') then
selfSay('I sell health (50 gold coins each), mana (50 gold coins each), stronghealth (100 gold coins each), strongmana (80 gold coins each), greathealth (190 gold coins each) and greatmana (120 gold coins each).')
-- inicio da venda de wands =)
elseif msgcontains(msg, 'inferno') then
count = getCount(msg)
if count > 0 then
buy(cid,2187,count,15000)
end
elseif msgcontains(msg, 'decay') then
count = getCount(msg)
if count > 0 then
buy(cid,2188,count,5000)
end
elseif msgcontains(msg, 'cosmic energy') then
count = getCount(msg)
if count > 0 then
buy(cid,2189,count,10000)
end
elseif msgcontains(msg, 'vortex') then
count = getCount(msg)
if count > 0 then
buy(cid,2190,count,0)
end
elseif msgcontains(msg, 'dragonbreath') then
count = getCount(msg)
if count > 0 then
buy(cid,2191,count,1000)
end
-- fim da venda de wands =)
-- inicio da venda de rods =)
elseif msgcontains(msg, 'terra') then
count = getCount(msg)
if count > 0 then
buy(cid,2181,count,10000)
end
elseif msgcontains(msg, 'snakebite') then
count = getCount(msg)
if count > 0 then
buy(cid,2182,count,0)
end
elseif msgcontains(msg, 'hailstorm') then
count = getCount(msg)
if count > 0 then
buy(cid,2183,count,15000)
end
elseif msgcontains(msg, 'necrotic') then
count = getCount(msg)
if count > 0 then
buy(cid,2185,count,5000)
end
elseif msgcontains(msg, 'moonlight') then
count = getCount(msg)
if count > 0 then
buy(cid,2186,count,1000)
end
-- fim da venda de rods =)
-- inicio da venda de runas =)
elseif msgcontains(msg, 'heavy magic missile') then
count = getCount(msg)
if count > 0 then
buyrunes(cid, 2311, getCount(msg), 10, 125)
end
elseif msgcontains(msg, 'ultimate healing') then
count = getCount(msg)
if count > 0 then
buyrunes(cid, 2273, getCount(msg), 2, 175)
end
elseif msgcontains(msg, 'great fireball') then
count = getCount(msg)
if count > 0 then
buyrunes(cid, 2304, getCount(msg), 3, 175)
end
elseif msgcontains(msg, 'explosion') then
count = getCount(msg)
if count > 0 then
buyrunes(cid, 2313, getCount(msg), 6, 250)
end
elseif msgcontains(msg, 'sudden death') then
count = getCount(msg)
if count > 0 then
buyrunes(cid, 2268, getCount(msg), 3, 325)
end
elseif msgcontains(msg, 'magic wall') then
count = getCount(msg)
if count > 0 then
buyrunes(cid, 2293, getCount(msg), 3, 350)
end
elseif msgcontains(msg, 'destroy') then
count = getCount(msg)
if count > 0 then
buyrunes(cid, 2261, getCount(msg), 3, 100)
end
elseif msgcontains(msg, 'firebomb') then
count = getCount(msg)
if count > 0 then
buyrunes(cid, 2305, getCount(msg), 3, 275)
end
elseif msgcontains(msg, 'blank') then
count = getCount(msg)
if count > 0 then
buyrunes(cid, 2260, getCount(msg), 1, 10)
end
-- fim da venda de runas =)
-- inicio da venda de potions
elseif msgcontains(msg, 'health') then
count = getCount(msg)
if count > 0 then
buy(cid,7618,count,50)
end
elseif msgcontains(msg, 'mana') then
count = getCount(msg)
if count > 0 then
buy(cid,7620,count,50)
end
elseif msgcontains(msg, 'strongmana') then
count = getCount(msg)
if count > 0 then
buy(cid,7589,count,80)
end
elseif msgcontains(msg, 'stronghealth') then
count = getCount(msg)
if count > 0 then
buy(cid,7588,count,100)
end
elseif msgcontains(msg, 'greatmana') then
count = getCount(msg)
if count > 0 then
buy(cid,7590,count,120)
end
elseif msgcontains(msg, 'greathealth') then
count = getCount(msg)
if count > 0 then
buy(cid,7591,count,190)
end
-- fim da venda de potions
elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end
Salve e feche.
Agora crie um arquivo em data/npc chamado Murok.xml contendo:
<?xml version="1.0"?>
<npc name="Murok" script="data/npc/scripts/runesbyyunie.lua" access="3" lookdir="1">
<health now="1000" max="1000"/>
<look type="128" head="78" body="71" legs="82" feet="114"/>
</npc>
E pronto, seu NPC de runas igual ao global está pronto!
Divirtam-se
//Yunie~~