• 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!

Super Promotion Scroll TFS 1.2

Asheex

New Member
Joined
Nov 4, 2016
Messages
31
Reaction score
0
Hey,

I need a script that after clicking on a given item will change the character's profession to a better one

For example: knight> super knight> ultra knight

Knight have ID 4 on Vocation.xml
Super Knight have ID 8 on Vocation.xml
Ultra Knight have ID 12 on Vocation.xml

So generally there will be 2 promotional items for each profession

TFS 1.2

Thank you in advance for your help
 
Solution
data/actions/actions.xml
XML:
<action itemid="ID_SCROLL1" script="howimeetyourmother.lua" />
<action itemid="ID_SCROLL2" script="howimeetyourmother.lua" />

data/actions/scripts/howimeetyourmother.lua
Lua:
local cfg = {
    [ID_SCROLL1] = {fromVoc = 4, toVoc = 8, namefrom = 'knight', nameto = 'super knight'},
    [ID_SCROLL2] = {fromVoc = 8, toVoc = 12, namefrom = 'super knight', nameto = 'ultra knight'}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local scroll = cfg[item.itemid]
    if not scroll then
        return true
    end

    if ((item.itemid == scroll) and (player:getVocation() == scroll.fromVoc)) then
            player:setVocation(scroll.toVoc)...
data/actions/actions.xml
XML:
<action itemid="ID_SCROLL1" script="howimeetyourmother.lua" />
<action itemid="ID_SCROLL2" script="howimeetyourmother.lua" />

data/actions/scripts/howimeetyourmother.lua
Lua:
local cfg = {
    [ID_SCROLL1] = {fromVoc = 4, toVoc = 8, namefrom = 'knight', nameto = 'super knight'},
    [ID_SCROLL2] = {fromVoc = 8, toVoc = 12, namefrom = 'super knight', nameto = 'ultra knight'}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local scroll = cfg[item.itemid]
    if not scroll then
        return true
    end

    if ((item.itemid == scroll) and (player:getVocation() == scroll.fromVoc)) then
            player:setVocation(scroll.toVoc)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You promoted your dick from '.. scroll.namefrom ..' to '.. scroll.nameto ..'. Dick size++')
            item:remove()
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'This scroll is not for your vocation you stupid prick!')
     end

    return true
end

Don't forget to change variables and other things.
If works i hope you will have a great day and huge biceps!
 
Last edited:
Solution
Got an issue with this.

XML:
<action itemid="5808" script="dicerrank.lua"/>

Lua:
local cfg = {
    [5808] = {fromVoc = 8, toVoc = 12, namefrom = 'elite knight', nameto = 'dicer'},
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local scroll = cfg[item.itemid]
    if not scroll then
        return true
    end

    if ((item.itemid == scroll) and (player:getVocation() == scroll.fromVoc)) then
            player:setVocation(scroll.toVoc)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been promoted from '.. scroll.namefrom ..' to '.. scroll.nameto ..'. Congratulations!')
            item:remove()
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'This scroll cannot be used by your vocation!')
     end

    return true
end

Character vocation is = 8 (Elite Knight) but when trying to use the item I get the message that my vocation can't use this item.

Ideas?
 
Right...completely misunderstood it. Thanks 🤦‍♀️

Edit:

Say I wanted for it to work for all vocations?

e.g.

8 > 12
7 > 11
6 > 10
5 > 9

How would I apply that to the script?

@Stigma
 
Last edited:
Bump

Anyone able to explain to me how I would add multiple vocations to the script?

Like explained above.

I want the item to work for all vocations which are

8 to 12
7 to 11
6 to 10
5 to 9

I'm not entirely sure how to add that into the cfg part :/
 
Bump, still wondering how to add multiple vocations to script 🤔

Code:
local cfg = {
    [ID_SCROLL1] = {fromVoc = 4, toVoc = 8, namefrom = 'knight', nameto = 'super knight'},
    [ID_SCROLL2] = {fromVoc = 8, toVoc = 12, namefrom = 'super knight', nameto = 'ultra knight'},
    [ID_SCROLL3] = {fromVoc = 3, toVoc = 7, namefrom = 'paladin', nameto = 'royal paladin'},
    [ID_SCROLL4] = {fromVoc = 7, toVoc = 11, namefrom = 'royal paladin', nameto = 'master paladin'}
}
 
Bump

Anyone able to explain to me how I would add multiple vocations to the script?

Like explained above.

I want the item to work for all vocations which are

8 to 12
7 to 11
6 to 10
5 to 9

I'm not entirely sure how to add that into the cfg part :/
Bump, still wondering how to add multiple vocations to script 🤔
12 - 8 = 4
11 - 7 = 4
10 - 6 = 4
9- 5 = 4

So just add 4 to the person's vocation, and they will get the correct promotion.
and just checkto make sure they aren't the 'maximum' promotion already.

0 - no vocation
1,2,3,4 = vocation
5,6,7,8 = first promotion
9,10,11,12 = second promotion
so
if vocation < 9 then
-- let them promote.
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local vocation = player:getVocation():getId()
    if vocation < 9 then
        vocation = vocation + 4
        player:setVocation(vocation)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You've been promoted! Congratulations!")
        item:remove()
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You're already at the maximum promotion level. Unable to utilize this item.")
    end
    return true
end
 
12 - 8 = 4
11 - 7 = 4
10 - 6 = 4
9- 5 = 4

So just add 4 to the person's vocation, and they will get the correct promotion.
and just checkto make sure they aren't the 'maximum' promotion already.

0 - no vocation
1,2,3,4 = vocation
5,6,7,8 = first promotion
9,10,11,12 = second promotion
so
if vocation < 9 then
-- let them promote.
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local vocation = player:getVocation():getId()
    if vocation < 9 then
        vocation = vocation + 4
        player:setVocation(vocation)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You've been promoted! Congratulations!")
        item:remove()
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You're already at the maximum promotion level. Unable to utilize this item.")
    end
    return true
end

That's perfect, much appreciation. Say I only want vocations 5-9 to be allowed to use the scroll?
 
That's perfect, much appreciation. Say I only want vocations 5-9 to be allowed to use the scroll?
if vocation > 4 and vocation < 9 then
above would let 5,6,7,8 use the scroll.

Can make it easier to read though.

if vocation >= 5 and vocation <= 8 then
 
if vocation > 4 and vocation < 9 then
above would let 5,6,7,8 use the scroll.

Can make it easier to read though.

if vocation >= 5 and vocation <= 8 then

if vocation > 4 and vocation < 9 then wasn't working but if vocation >= 5 and vocation <= 8 then did D:

thanks a lot, ill remember this for the future
 
Back
Top