XML:
<?xml version="1.0" encoding="UTF-8"?> <npc name="Promotion VIP" script="data/npc/scripts/promotions.lua" walkinterval="2000" floorchange="0"> <mana now="800" max="800"/> <health now="200" max="200"/> <look type="133" head="114" body="119" legs="132" feet="114"/> </npc>Script Lua (promotions.lua):
local config = {
promote1 = 20000, -- preço da primeira promotion
promote2 = 10000000, -- preço da segunda promotion
rookPromote1 = {13, 10000}, -- {id da vocação, preço}
rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}
local focus = 0
local talk_start = 0
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_start = 0
end
end
function findmsg(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)
msg = string.lower(msg)
local price = 0
if findmsg(msg, 'hi') and (focus == 0) and getDistanceToCreature(cid) < 4 then
selfSay('Hello ' .. creatureGetName(cid) .. '! I sell promotions.')
focus = cid
talk_start = os.clock()
elseif findmsg(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 findmsg(msg, 'promotion') or findmsg(msg, 'promote') then
if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
talk_state = 2
elseif getPlayerVocation(cid) > 8 and getPlayerVocation(cid) < config.rookPromote1[1] then
selfSay('Sorry, you are already promoted.')
talk_state = 0
elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
selfSay('Sorry, you must be premium to buy promotion.')
talk_state = 0
else
if getPlayerVocation(cid) > 8 then
price = config.promote2
else
price = config.promote1
end
selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
talk_state = 1
end
elseif talk_state == 1 then
if findmsg(msg, 'yes') then
if doPlayerRemoveMoney(cid, price) then
doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
selfSay('You are now promoted!')
else
selfSay('Sorry, you do not have enough money.')
end
end
talk_state = 0
elseif talk_state == 2 then
if getPlayerVocation(cid) == 0 then
if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
doPlayerSetVocation(cid, config.rookPromote1[1])
selfSay('You are now promoted!')
else
selfSay('Sorry, you do not have enough money.')
end
elseif getPlayerVocation(cid) == config.rookPromote1[1] then
if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
doPlayerSetVocation(cid, config.rookPromote2[1])
selfSay('You are now promoted!')
else
selfSay('Sorry, you do not have enough money.')
end
end
talk_state = 0
elseif findmsg(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onThink()
doNpcSetCreatureFocus(focus)
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






info
Grupo: Campones
Registrado: 14/04/13
Posts: 89
Reputação: 0
Char no Tibia: GM Strikker
Eu queria um NPC de promotion assim:
Não sei fazer, to com medo de fazer merda e bugar as vocações de novo ai vou ferrar minha DB então peço a alguem q saiba
Uso rev 3777, 0.4!!! 8.6!