Promotion NPC

Como vão galera? Hoje trouxe para vocês um NPC parecido com o do Mu Online, aquele que te promove em troca de items+coins.
Instalação

Vá em data/npc/, copie algum arquivo da pasta e cole, renomeie para Priest Sevina, agora abra com o bloco de notas e cole dentro:
<?xml version="1.0" encoding="UTF-8"?> <npc name="Priest Sevina" script="promotion.lua" walkinterval="2000" floorchange="0"> <health now="150" max="150"/> <look type="132" head="25" body="100" legs="50" feet="99" corpse="2212"/> <parameters> <parameter key="message_greet" value="Hello |PLAYERNAME|. If you want promote, say {promote}."/> </parameters> </npc>
Agora em data/npc/scripts, copie algum arquivo desta pasta e cole, renomeie para promotion, se já existir um arquivo com esse nome, substitua oque tem dentro dele por:
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 promos = { [1] = {level = 150, item = 2494, quant = 1, coins = 20000, name = "Master Sorcerer"}, [2] = {level = 150, item = 2495, quant = 1, coins = 30000, name = "Elder Druid"}, [3] = {level = 100, item = 2493, quant = 1, coins = 15000, name = "Royal Paladin"}, [4] = {level = 200, item = 2492, quant = 1, coins = 50000, name = "Elite Knight"}, } local promo = promos[getPlayerVocation(cid)] if msgcontains(msg, 'promote') or msgcontains(msg, 'promotion') then if getPlayerVocation(cid) < 1 or getPlayerVocation(cid) > 4 then selfSay('Have you been promoted, go away.', cid) talkState[talkUser] = 0 return false end if getPlayerLevel(cid) < promo.level then selfSay('Go fight my young warrior, you do not have the required level. Level need: ['..promo.level..'].', cid) talkState[talkUser] = 0 return false end selfSay('Hello my friend, Im a Time Lord and I can promote to the second class, just need a few favors, (say {yes}.).', cid) talkState[talkUser] = 2 if msgcontains(msg, 'yes') then selfSay('You want to be promoted to '..promo.name..', will I need to bring me a '..getItemNameById(promo.item)..' and '..promo.coins..' coins.', cid) talkState[talkUser] = 3 end return true end if doPlayerRemoveItem(cid, promo.item, promo.quant) and doPlayerRemoveMoney(cid, promo.coins) then doSendMagicEffect(getCreaturePosition(cid), 14) setPlayerPromotionLevel(cid, getPlayerPromotionLevel(cid)+1) selfSay('Now you are a '..promo.name..', enter the account again to take effect', cid) else selfSay('You do not have enough money ('..promo.coins..' gold coins) or do not have the required item ('..getItemNameById(promo.item)..').', cid) end talkState[talkUser] = 0 return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Configuração

Nesta parte:
local promos = { [1] = {level = 150, item = 2494, quant = 1, coins = 20000, name = "Master Sorcerer"}, [2] = {level = 150, item = 2495, quant = 1, coins = 30000, name = "Elder Druid"}, [3] = {level = 100, item = 2493, quant = 1, coins = 15000, name = "Royal Paladin"}, [4] = {level = 200, item = 2492, quant = 1, coins = 50000, name = "Elite Knight"}, }
Entre [ e ], no caso 1, 2, 3 e 4 são os Ids das vocations, em "level" você coloca o level necessário para esta vocation ser promovida, "item" você coloca o Item ID necessário para ser promovido e quant coloque a quantidade.
Já em "coins" você coloca a quantidade de gold coins que devem ser removidas do player e em "name" coloque entre aspas e por escrito, o nome da Promotion.
Demonstração

