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

Promotion item

kamilcioo

Veteran OT User
Joined
Jul 25, 2008
Messages
979
Solutions
1
Reaction score
291
Hey, I just made a promotion item script. Everything works great but when I log out promotion dissapears.
Can anyone rewrite it to make promotion lasts forever?

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerPromotionLevel(cid) < 1 and getPlayerVocation(cid) == 1 and getPlayerLevel(cid) > 29 then
        doPlayerSetVocation(cid, 5)
        doCreatureSay(cid, "You have been promoted to xxx", TALKTYPE_ORANGE_1)
        doRemoveItem(item.uid, 1)
    elseif    getPlayerLevel(cid) < 29 and getPlayerVocation(cid) == 1 then
            doCreatureSay(cid, "You need to be 30 lvl.", TALKTYPE_ORANGE_1)
    elseif    getPlayerVocation(cid) ~= 1 then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You need to be a mage to use this item.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are already promoted.")
    end
    return true
end

When I use
Code:
doPlayerSetPromotionLevel(cid, 3)
instead
Code:
doPlayerSetVocation(cid, 5)
it works but it doesn't give me the promotion I want. Btw I have 3 main vocations and 2 promotions for each of them.
 
It doesn't give me promotion I want:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<vocations>
    <vocation id="0" name="Begginer" description="a no begginer" needpremium="0" gaincap="10" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="20" gainmanaticks="6" gainmanaamount="20" manamultiplier="4.0" attackspeed="700" soulmax="100" gainsoulticks="60" fromvoc="0" attackable="no">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="1" name="Mage" description="a Mage" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="7" gainhpamount="35" gainmanaticks="7" gainmanaamount="145" manamultiplier="1.1" attackspeed="700" soulmax="100" gainsoulticks="60" fromvoc="1">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="2" name="Paladin" description="a paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="7" gainhpamount="135" gainmanaticks="7" gainmanaamount="145" manamultiplier="1.4" attackspeed="700" soulmax="100" gainsoulticks="60" fromvoc="2">
        <formula meleeDamage="1.0" distDamage="1.3" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="3" name="Knight" description="a knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="5" gainhpamount="135" gainmanaticks="11" gainmanaamount="45" manamultiplier="3.0" attackspeed="700" soulmax="100" gainsoulticks="60" fromvoc="3">
        <formula meleeDamage="1.2" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="4" name="a Fire and Poison Mage" description="a Fire and Poison Mage" needpremium="0" gaincap="15" gainhp="6" gainmana="34" gainhpticks="9" gainhpamount="6" gainmanaticks="3" gainmanaamount="7" manamultiplier="1.1" attackspeed="1500" soulmax="200" gainsoulticks="15" fromvoc="1" lessloss="30">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="5" name="an Ice and Lightning Mage" description="an Ice and Lightning Mage" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="5" gainhpamount="55" gainmanaticks="5" gainmanaamount="175" manamultiplier="1.1" attackspeed="700" soulmax="200" gainsoulticks="15" fromvoc="1" lessloss="30">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="6" name="Bow Master" description="a bow master" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="5" gainhpamount="155" gainmanaticks="5" gainmanaamount="175" manamultiplier="1.4" attackspeed="1800" soulmax="200" gainsoulticks="15" fromvoc="3" lessloss="30">
        <formula meleeDamage="1.0" distDamage="1.3" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="7" name="Berserker" description="a berserker" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="4" gainhpamount="155" gainmanaticks="7" gainmanaamount="75" manamultiplier="3.0" attackspeed="700" soulmax="200" gainsoulticks="15" fromvoc="4" lessloss="30">
        <formula meleeDamage="1.2" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="8" name="Marksman" description="a marksman" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="5" gainhpamount="155" gainmanaticks="5" gainmanaamount="175" manamultiplier="1.4" attackspeed="700" soulmax="200" gainsoulticks="15" fromvoc="3" lessloss="30">
        <formula meleeDamage="1.0" distDamage="1.3" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
        <vocation id="9" name="Templar" description="a templar" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="4" gainhpamount="155" gainmanaticks="7" gainmanaamount="75" manamultiplier="3.0" attackspeed="700" soulmax="200" gainsoulticks="15" fromvoc="4" lessloss="30">
        <formula meleeDamage="1.2" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
    </vocation>
    <vocation id="10" name="Priest" description="a priest" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="5" gainhpamount="55" gainmanaticks="5" gainmanaamount="175" manamultiplier="1.1" attackspeed="700" soulmax="200" gainsoulticks="15" fromvoc="1" lessloss="30">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
    </vocation>
</vocations>

And voc in lib:
Code:
function isMage(cid)
    return isInArray({1, 4, 5, 10}, getPlayerVocation(cid))
end

function isPaladin(cid)
    return isInArray({2, 6, 8}, getPlayerVocation(cid))
end

function isKnight(cid)
    return isInArray({3, 7, 9}, getPlayerVocation(cid))
end

function isRookie(cid)
    return isInArray({0}, getPlayerVocation(cid))
end
 
Just set everyone to their promotion level.

doPlayerSetPromotionLevel(cid, 1)

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerPromotionLevel(cid) < 1) then
        if(getPlayerVocation(cid) == 1) then
            if(getPlayerLevel(cid) >= 30) then
                doPlayerSetPromotionLevel(cid, 1)
                doCreatureSay(cid, "You have been promoted to a ".. getPlayerVocationName(cid) .."!")
                doRemoveItem(item.uid, 1)
            else
                doCreatureSay(cid, "You must be level 30 to use this item!")
            end
        else
            doCreatureSay(cid, "You must be a mage to use this item.")
        end
    else
        doPlayerSendCancel(cid, "You are already promoted!")
    end
    return true
end
 
Last edited:
Just set everyone to their promotion level.

doPlayerSetPromotionLevel(cid, 1)

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerPromotionLevel(cid) < 1) then
        if(getPlayerVocation(cid) == 1) then
            if(getPlayerLevel(cid) >= 30) then
                doPlayerSetPromotionLevel(cid, 1)
                doCreatureSay(cid, "You have been promoted to a ".. getPlayerVocationName(cid) .."!")
                doRemoveItem(item.uid, 1)
            else
                doCreatureSay(cid, "You must be level 30 to use this item!")
            end
        else
            doCreatureSay(cid, "You must be a mage to use this item.")
        end
    else
        doPlayerSendCancel(cid, "You are already promoted!")
    end
    return true
end

Still not working, Used on mage and got berserker promotion when I put doPlayerSetPromotionLevel(cid, 2)
 
try this:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerVocation(cid) == 1 and getPlayerLevel(cid) > 29 then
        doPlayerSetVocation(cid, 4)
        doCreatureSay(cid, "You have been promoted to Fire and Poison Mage.", TALKTYPE_ORANGE_1)
        doRemoveItem(item.uid, 1)
    elseif getPlayerLevel(cid) =< 29 and getPlayerVocation(cid) == 1 then
            doCreatureSay(cid, "You need to be level 30.", TALKTYPE_ORANGE_1)
    elseif getPlayerVocation(cid) ~= 1 then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You need to be a Mage to use this item.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are already promoted.")
    end
    return true
end
 
@up. =< doesnt work. Anyway changed it to make it work but anyway it says that I'm already promoted. And as I mentioned above, set vocation works but only till logout.
 
Code:
config {
storagePromo = 56310
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerVocation(cid) == 1 and getPlayerLevel(cid) > 29 then
        doPlayerSetVocation(cid, 4)
        doCreatureSay(cid, "You have been promoted to Fire and Poison Mage.", TALKTYPE_ORANGE_1)
        setPlayerStorageValue(cid, storagePromo, 1)
        doRemoveItem(item.uid, 1)
    elseif getPlayerLevel(cid) <= 29 and getPlayerVocation(cid) == 1 then
            doCreatureSay(cid, "You need to be level 30.", TALKTYPE_ORANGE_1)
    elseif getPlayerVocation(cid) ~= 1 then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You need to be a Mage to use this item.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are already promoted.")
    end
    return true
end

and in creature:
Code:
function onLogin(cid)
if getPlayerStorageValue(storagePromo) == 1 then
doPlayerSetVocation(cid, 4)
else
return true
end
 
Omg, guys! His script is working very well. What are you doing?
Look at this line:
Code:
<vocation id="7" name="Berserker" ...... fromvoc="4" .....
If you are using own-made profession/promotion system you have to change your fromvoc value to the same as vocation value.
So, it should be like this:
Code:
<vocation id="7" name="Berserker" ...... fromvoc="7" .....

Simple and easy.
 
Omg, guys! His script is working very well. What are you doing?
Look at this line:
Code:
<vocation id="7" name="Berserker" ...... fromvoc="4" .....
If you are using own-made profession/promotion system you have to change your fromvoc value to the same as vocation value.
So, it should be like this:
Code:
<vocation id="7" name="Berserker" ...... fromvoc="7" .....

Simple and easy.

Thanks really!!!. Didn't think about this :P. Btw how to give repp? Send me a message.
 
Back
Top