• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Second/Third Promo NPC "You are already promoted".

Taurus

Texass
Joined
Jan 11, 2009
Messages
616
Solutions
2
Reaction score
30
Location
United States
I have made every attempt to search this issue, I have also used the search feature on Notepad++ to check all scripts for anything that could apply. I may have isolated the issue, but I am unable to fix it myself.

The issue is that the NPC will only promote players ONCE. After that it says "you are already promoted".

I'm using OTXserver3, which is based on TFS 1.3(?) (all 1.3 scripts I tried have worked so far)

Code:
 local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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


     
local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, text = 'Congratulations! You are now promoted.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
   
local node2 = keywordHandler:addKeyword({'acolyte'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 50000 gold coins. Do you want me to promote you?'})
    node2:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 50000, level =130, text = 'Congratulations! You are now an acolyte.'})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
   
local node3 = keywordHandler:addKeyword({'adept'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 100000 gold coins. Do you want me to promote you?'})
    node3:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 100000, level =170, text = 'Congratulations! You are now an adept of your craft.'})
    node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
   
local node4 = keywordHandler:addKeyword({'master'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 200000 gold coins. Do you want me to promote you?'})
    node4:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 200000, level =200, text = 'Congratulations! You have mastered your craft.'})
    node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
-- The New Frontier
-- Incorrect
local bribeKeyword = keywordHandler:addKeyword({'farmine'}, StdModule.say, {npcHandler = npcHandler, text = 'Ah, I vaguely remember that our little allies were eager to build some base. So speak up, what do you want?'}, function(player) return player:getStorageValue(Storage.TheNewFrontier.Questline) <= 15 end)
    bribeKeyword:addChildKeyword({'flatter'}, StdModule.say, {npcHandler = npcHandler, text = 'Indeed, indeed. Without the help of Thais, our allies stand no chance! Well, I\'ll send some money to support their cause.', reset = true},
        function(player) return player:getStorageValue(Storage.TheNewFrontier.BribeKing) ~= 1 end,
        function(player) player:setStorageValue(Storage.TheNewFrontier.BribeKing, 1) player:setStorageValue(Storage.TheNewFrontier.Mission05, player:getStorageValue(Storage.TheNewFrontier.Mission05) + 1) end
    )

-- Basic
keywordHandler:addKeyword({'eremo'}, StdModule.say, {npcHandler = npcHandler, text = 'It is said that he lives on a small island near Edron. Maybe the people there know more about him.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I am your sovereign, King Tibianus III, and it\'s my duty to uphold {justice} and provide guidance for my subjects.'})
keywordHandler:addKeyword({'justice'}, StdModule.say, {npcHandler = npcHandler, text = 'I try my best to be just and fair to our citizens. The army and the {TBI} are a great help in fulfilling this duty.'})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'Preposterous! You must know the name of your own King!'})
keywordHandler:addKeyword({'news'}, StdModule.say, {npcHandler = npcHandler, text = 'The latest news is usually brought to our magnificent town by brave adventurers. They recount tales of their journeys at Frodo\'s tavern.'})
keywordHandler:addKeyword({'how', 'are', 'you'}, StdModule.say, {npcHandler = npcHandler, text = 'Thank you, I\'m fine.'})
keywordHandler:addKeyword({'castle'}, StdModule.say, {npcHandler = npcHandler, text = 'Rain Castle is my home.'})
keywordHandler:addKeyword({'sell'}, StdModule.say, {npcHandler = npcHandler, text = 'Sell? Sell what? My kingdom isn\'t for sale!'})
keywordHandler:addKeyword({'god'}, StdModule.say, {npcHandler = npcHandler, text = 'Honour the Gods and above all pay your {taxes}.'})
keywordHandler:addKeyword({'zathroth'}, StdModule.say, {npcHandler = npcHandler, text = 'Please ask a priest about the gods.'})
keywordHandler:addKeyword({'citizen'}, StdModule.say, {npcHandler = npcHandler, text = 'The citizens of Tibia are my subjects. Ask the old monk Quentin if you want to learn more about them.'})
keywordHandler:addKeyword({'sam'}, StdModule.say, {npcHandler = npcHandler, text = 'He is a skilled blacksmith and a loyal subject.'})
keywordHandler:addKeyword({'frodo'}, StdModule.say, {npcHandler = npcHandler, text = 'He is the owner of Frodo\'s Hut and a faithful tax-payer.'})
keywordHandler:addKeyword({'gorn'}, StdModule.say, {npcHandler = npcHandler, text = 'He was once one of Tibia\'s greatest fighters. Now he sells equipment.'})
keywordHandler:addKeyword({'benjamin'}, StdModule.say, {npcHandler = npcHandler, text = 'He was once my greatest general. Now he is very old and senile so we assigned him to work for the Royal Tibia Mail.'})
keywordHandler:addKeyword({'noodles'}, StdModule.say, {npcHandler = npcHandler, text = 'The royal poodle Noodles is my greatest {treasure}!'})
keywordHandler:addKeyword({'ferumbras'}, StdModule.say, {npcHandler = npcHandler, text = 'He is a follower of the evil God Zathroth and responsible for many attacks on us. Kill him on sight!'})
keywordHandler:addKeyword({'bozo'}, StdModule.say, {npcHandler = npcHandler, text = 'He is my royal jester and cheers me up now and then.'})
keywordHandler:addKeyword({'treasure'}, StdModule.say, {npcHandler = npcHandler, text = 'The royal poodle Noodles is my greatest treasure!'})
keywordHandler:addKeyword({'monster'}, StdModule.say, {npcHandler = npcHandler, text = 'Go and hunt them! For king and country!'})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, text = 'Visit Quentin the monk for help.'})
keywordHandler:addKeyword({'sewer'}, StdModule.say, {npcHandler = npcHandler, text = 'What a disgusting topic!'})
keywordHandler:addKeyword({'dungeon'}, StdModule.say, {npcHandler = npcHandler, text = 'Dungeons are no places for kings.'})
keywordHandler:addKeyword({'equipment'}, StdModule.say, {npcHandler = npcHandler, text = 'Feel free to buy it in our town\'s fine shops.'})
keywordHandler:addKeyword({'food'}, StdModule.say, {npcHandler = npcHandler, text = 'Ask the royal cook for some food.'})
keywordHandler:addKeyword({'tax collector'}, StdModule.say, {npcHandler = npcHandler, text = 'That tax collector is the bane of my life. He is so lazy. I bet you haven\'t payed any taxes at all.'})
keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, text = 'I am the king, so watch what you say!'})
keywordHandler:addKeyword({'army'}, StdModule.say, {npcHandler = npcHandler, text = 'Ask the soldiers about that.'})
keywordHandler:addKeyword({'shop'}, StdModule.say, {npcHandler = npcHandler, text = 'Visit the shops of our merchants and craftsmen.'})
keywordHandler:addKeyword({'guild'}, StdModule.say, {npcHandler = npcHandler, text = 'The four major guilds are the knights, the paladins, the druids, and the sorcerers.'})
keywordHandler:addKeyword({'minotaur'}, StdModule.say, {npcHandler = npcHandler, text = 'Vile monsters, but I must admit they are strong and sometimes even cunning ... in their own bestial way.'})
keywordHandler:addKeyword({'good'}, StdModule.say, {npcHandler = npcHandler, text = 'The forces of good are hard pressed in these dark times.'})
keywordHandler:addKeyword({'evil'}, StdModule.say, {npcHandler = npcHandler, text = 'We need all strength we can muster to smite evil!'})
keywordHandler:addKeyword({'order'}, StdModule.say, {npcHandler = npcHandler, text = 'We need order to survive!'})
keywordHandler:addKeyword({'chaos'}, StdModule.say, {npcHandler = npcHandler, text = 'Chaos arises from selfishness.'})
keywordHandler:addKeyword({'excalibug'}, StdModule.say, {npcHandler = npcHandler, text = 'It\'s the sword of the Kings. If you return this weapon to me I will {reward} you beyond your wildest dreams.'})
keywordHandler:addKeyword({'reward'}, StdModule.say, {npcHandler = npcHandler, text = 'Well, if you want a reward, go on a quest to bring me Excalibug!'})
keywordHandler:addKeyword({'chester'}, StdModule.say, {npcHandler = npcHandler, text = 'A very competent person. A little nervous but very competent.'})
keywordHandler:addKeyword({'tbi'}, StdModule.say, {npcHandler = npcHandler, text = 'This organisation is an essential tool for holding our enemies in check. Its headquarter is located in the bastion in the northwall.'})
keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, text = 'Soon the whole land will be ruled by me once again!'})
keywordHandler:addAliasKeyword({'land'})
keywordHandler:addKeyword({'harkath'}, StdModule.say, {npcHandler = npcHandler, text = 'Harkath Bloodblade is the general of our glorious {army}.'})
keywordHandler:addAliasKeyword({'bloodblade'})
keywordHandler:addAliasKeyword({'general'})
keywordHandler:addKeyword({'quest'}, StdModule.say, {npcHandler = npcHandler, text = 'I will call for heroes as soon as the need arises again and then reward them appropriately.'})
keywordHandler:addAliasKeyword({'mission'})
keywordHandler:addKeyword({'gold'}, StdModule.say, {npcHandler = npcHandler, text = 'To pay your taxes, visit the royal tax collector.'})
keywordHandler:addAliasKeyword({'money'})
keywordHandler:addAliasKeyword({'tax'})
keywordHandler:addAliasKeyword({'collector'})
keywordHandler:addKeyword({'time'}, StdModule.say, {npcHandler = npcHandler, text = 'It\'s a time for heroes!'})
keywordHandler:addAliasKeyword({'hero'})
keywordHandler:addAliasKeyword({'adventurer'})
keywordHandler:addKeyword({'enemy'}, StdModule.say, {npcHandler = npcHandler, text = 'Our enemies are numerous. The evil minotaurs, Ferumbras, and the renegade city of Carlin to the north are just some of them.'})
keywordHandler:addAliasKeyword({'enemies'})
keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, text = 'They dare to reject my reign over the whole continent!'})
keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, text = 'Our beloved city has some fine shops, guildhouses and a modern sewerage system.'})
keywordHandler:addAliasKeyword({'city'})
keywordHandler:addKeyword({'merchant'}, StdModule.say, {npcHandler = npcHandler, text = 'Ask around about them.'})
keywordHandler:addAliasKeyword({'craftsmen'})
keywordHandler:addKeyword({'paladin'}, StdModule.say, {npcHandler = npcHandler, text = 'The paladins are great protectors for Thais.'})
keywordHandler:addAliasKeyword({'elane'})
keywordHandler:addKeyword({'knight'}, StdModule.say, {npcHandler = npcHandler, text = 'The brave knights are necessary for human survival in Thais.'})
keywordHandler:addAliasKeyword({'gregor'})
keywordHandler:addKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, text = 'The magic of the sorcerers is a powerful tool to smite our enemies.'})
keywordHandler:addAliasKeyword({'muriel'})
keywordHandler:addKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, text = 'We need the druidic healing powers to fight evil.'})
keywordHandler:addAliasKeyword({'marvik'})

npcHandler:setMessage(MESSAGE_GREET, 'I greet thee, my loyal subject |PLAYERNAME|. I offer four {promotions}... ask for {Acolyte} at level 130, {Adept} at 170 and {Master} at 200. ')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye, |PLAYERNAME|!')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'How rude!')

local focusModule = FocusModule:new()
focusModule:addGreetMessage('hail king')
focusModule:addGreetMessage('salutations king')
npcHandler:addModule(focusModule)

And in the NPC lib:

Code:
    --Usage:
        -- local node1 = keywordHandler:addKeyword({"promot"}, StdModule.say, {npcHandler = npcHandler, text = "I can promote you for 20000 gold coins. Do you want me to promote you?"})
        --         node1:addChildKeyword({"yes"}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20}, text = "Congratulations! You are now promoted.")
        --         node1:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, text = "Allright then. Come back when you are ready."}, reset = true)
    function StdModule.promotePlayer(cid, message, keywords, parameters, node)
        local npcHandler = parameters.npcHandler
        if npcHandler == nil then
            error("StdModule.promotePlayer called without any npcHandler instance.")
        end
        if not npcHandler:isFocused(cid) then
            return false
        end

        local player = Player(cid)
        if player:isPremium() then
            if player:getStorageValue(Storage.Promotion) == 1 then
                npcHandler:say("You are already promoted!", cid)
            elseif player:getLevel() < parameters.level then
                npcHandler:say("I am sorry, but I can only promote you once you have reached level " .. parameters.level .. ".", cid)
            elseif not player:removeMoneyNpc(parameters.cost) then
                npcHandler:say("You do not have enough money!", cid)
            else
                player:setStorageValue(Storage.Promotion, 1)
                player:setVocation(player:getVocation():getPromotion())
                player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
                npcHandler:say(parameters.text or "Congratulations! You are now promoted.", cid)
            end
        else
            npcHandler:say("You need a premium account in order to get promoted.", cid)
        end
        npcHandler:resetNpc(cid)
        return true
    end

It seems quite different from what I remember which was simply a script that sets the players voc to the desired vocation.

I'm pretty sure the issue is with:
Code:
            if player:getStorageValue(Storage.Promotion) == 1 then
in the NPC lib, but I am uncertain how to change this. Everything I have changed has caused it to stop working altogether. Thanks again to anyone who can help.
 
You are on the right track, you will have to modify that code since the promotion code is written in the libs (probbly to avoid having the same code in 10 scripts)
So add a new storage, check if that storage is 1 before the normal one, then look in the NPC file, at node1 and create another node for your second promotion.
 
You are on the right track, you will have to modify that code since the promotion code is written in the libs (probbly to avoid having the same code in 10 scripts)
So add a new storage, check if that storage is 1 before the normal one, then look in the NPC file, at node1 and create another node for your second promotion.

Thank you! I really appreciate the help, it's just that I've pretty much exhausted everything I know to do. If there is any way you could help out I'd really appreciate it.

I tried to edit it to be

Code:
if player:getStorageValue(Storage.Promotion) >= 4 then

But then it doesn't work. I don't think I'm doing it right. I have never seen this before on any OT I have worked on, anyone's help is appreciated. (Even if it was an old fashioned script that just sets the vocation id #) Thanks everyone.
 
Damn I was really optimistic about this.
Well this is a blast from the past. xD
https://otland.net/threads/promotion-npc.223312/

I'll always suggest to code it in lua, instead of using the built-in functions.
You can customize your npc's a lot more that way.

But then again, I'm only a mediocre scripter. :cool:

I used the scripts from the post you linked me to, I even made the changes suggested by the person who helped you out, however when I say second promotion, he asked if I want it I say yes and nothing happens. I think it's because we're using two TOTALLY different versions of TFS.

That's the issue I've had when trying to use the search feature. I can't find anything for tfs 1.3 on second promos. Thanks very much. I guess I still need a hand with this.
 
Yeah, I only use 0.3.7, otherwise I'd be more help.
Try searching for TFS 1.1 or 1.2, they are basically the same as tfs 1.3, afaik

Yes, I have tested probably over a dozen configurations on this. I REALLY have no clue... This is driving me insane.

I know the issue is here
Code:
            if player:getStorageValue(Storage.Promotion) == 1 then
                npcHandler:say("You are already promoted!", cid)

I have tried every way I know to re-write this part, what I've done in the meantime is just remove it. Now he will promote them, but they can say "acolyte - yes" over and over and get promoted all the way to top voc at any level.

Damn, I really have racked my brain to fix this.

My OT has no donation page, I don't intend to add one. I delete botters... this server is for people who wanna do quests and chill, it's a great little community, this is the #1 problem we are having, THANK YOU to anyone who can shed some light on this
 
Last edited:
Instead of using NPC for third promotion, I use an item to do that on-use. Then make that item buyable via NPC.

Actions.XML:
Code:
<action itemid="5952" script="promotion.lua" />

promotion.lua:
Code:
local vocations = {
    [5] = 9,
    [6] = 10,
    [7] = 11,
    [8] = 12,
}

function onUse(cid, item, fromPosition, itemEX, toPosition)
local player = Player(cid)
local vocation = player:getVocation()
local vocID = vocation:getId()
local vocationName = vocation:getName()
        if vocations[vocID] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You have succesfully upgraded from a '..vocationName..' to a '..Vocation(vocations[vocID]):getName()..'. ')
            player:setVocation(Vocation(vocations[vocID]))
            Item(item.uid):remove()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You cannot upgrade vocation.')
        end
   return true
end

Then just make a NPC who sells that 3rd promotion item, for however amount you want.
 
Instead of using NPC for third promotion, I use an item to do that on-use. Then make that item buyable via NPC.

Actions.XML:
Code:
<action itemid="5952" script="promotion.lua" />

promotion.lua:
Code:
local vocations = {
    [5] = 9,
    [6] = 10,
    [7] = 11,
    [8] = 12,
}

function onUse(cid, item, fromPosition, itemEX, toPosition)
local player = Player(cid)
local vocation = player:getVocation()
local vocID = vocation:getId()
local vocationName = vocation:getName()
        if vocations[vocID] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You have succesfully upgraded from a '..vocationName..' to a '..Vocation(vocations[vocID]):getName()..'. ')
            player:setVocation(Vocation(vocations[vocID]))
            Item(item.uid):remove()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You cannot upgrade vocation.')
        end
   return true
end

Then just make a NPC who sells that 3rd promotion item, for however amount you want.

This is perfect. The one problem I have is I can't find an otb editor for my items.otb. What editor do you use with OTXserver3 (or tfs1.x) I use version 10.99 if that matters
 
Instead of using NPC for third promotion, I use an item to do that on-use. Then make that item buyable via NPC.

Actions.XML:
Code:
<action itemid="5952" script="promotion.lua" />

promotion.lua:
Code:
local vocations = {
    [5] = 9,
    [6] = 10,
    [7] = 11,
    [8] = 12,
}

function onUse(cid, item, fromPosition, itemEX, toPosition)
local player = Player(cid)
local vocation = player:getVocation()
local vocID = vocation:getId()
local vocationName = vocation:getName()
        if vocations[vocID] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You have succesfully upgraded from a '..vocationName..' to a '..Vocation(vocations[vocID]):getName()..'. ')
            player:setVocation(Vocation(vocations[vocID]))
            Item(item.uid):remove()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You cannot upgrade vocation.')
        end
   return true
end

Then just make a NPC who sells that 3rd promotion item, for however amount you want.

How do I make this script check for the players level in tfs1.3?
 
Any one of these things would solve my little problem.

1. some help with the original NPC lib file where it sets the storage.
2. an item.otb editor for 10.99 (or whatever works for tfs 1.3)
3. an npc that checks level before selling items.
4. making Fablow's script check for level.

I'm really down FOR ANY WAY the players can promote themselves. I have worked on this nonstop for two days. I don't get it. Can anyone please help?
 
1) What's wrong with your original NPC lib file? What do you need changed/added? Show us your lib file - You don't need storage for the vocations with the script (fyi).
2) Gave you a link in PM for an 10.94 item editor.
3) I don't think you can do that with trade (don't take my word for it), but you probably could take xodet.lua, rescript it to sell promotion item by saying promotion item. I believe the function is 'if player:isLevel(level here) then'. So, something like this:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local player = Player(cid)
    local items = {[1] = 5952}
    local itemId = items[player:getLevel():getBase():getId()]
    if msgcontains(msg, 'promo scroll') or msgcontains(msg, 'second promotion') then
        if player:isLevel(100) then
                npcHandler:say('Would you like to buy a promotion scroll for 10,000gp?', cid)
                npcHandler.topic[cid] = 1
                else
                npcHandler:say('Sorry, you need to be level 100 to buy this item!', cid)
                end
    elseif msgcontains(msg, 'yes') then
        if npcHandler.topic[cid] == 1 then
            player:addItem(itemId, 1)
            player:removeItem(2160, 1)
            npcHandler:say('Here you are young adept, take care yourself.', cid)
        end
        npcHandler.topic[cid] = 0
    elseif msgcontains(msg, 'no') and npcHandler.topic[cid] == 1 then
        npcHandler:say('Ok then.', cid)
        npcHandler.topic[cid] = 0
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

4)
Code:
local vocations = {
    [5] = 9,
    [6] = 10,
    [7] = 11,
    [8] = 12,
}

function onUse(cid, item, fromPosition, itemEX, toPosition)
local player = Player(cid)
local vocation = player:getVocation()
local level = player:getLevel(50)
local vocID = vocation:getId()
local vocationName = vocation:getName()
        if vocations[vocID] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You have succesfully upgraded from a '..vocationName..' to a '..Vocation(vocations[vocID]):getName()..'. ')
            player:setVocation(Vocation(vocations[vocID]))
            Item(item.uid):remove()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You cannot upgrade vocation.')
        end
   return true
end

Note: Both not tested, seems like it would work.
 
Note: Both not tested, seems like it would work.

YOU'RE A HERO! You showed me exactly what I was forgetting.

Code:
local level = player:getLevel(50)

Changed to:

Code:
local level = player:getLevel(cid)

and added

Code:
 if vocations[vocID] and level >= 50 then

And now the script checks for level before promoting! You are totally awesome dude. Our little community thanks you.

I would also add thanks for the link to item editor. That's pretty much all I needed.
 
Back
Top