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

Request : potion that adds magic / skill lvl, only useable 5 x !

RaawrZ

New Member
Joined
Nov 1, 2019
Messages
3
Reaction score
0
Soo, me and a friend have been sitting here trying to figure out how to make a potion give you 1 mag lvl / 1 skill on use !
But it can only be used a maximum of 5 times !
We can't seem to find Any script just laying around waiting for us to grab it.
So i'd really much appreciate if someone was either sitting on one, or could make me one ?

been looking at guides on how to solve it myself for the past 2 hours now, stil can't figure it out ! :(
 
Lua:
local potions = {
    [potionid] = {skill = <skillid>, storage = <storageid>, flask = <flaskid>},
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    if not target:isPlayer() then
        return false
    end

    local targetPlayer = Player(target)
    local potion = potions[item:getId()]

    if not potion then
        return false
    end

    if targetPlayer:getStorageValue(potion.storage) >= 5 then
        return false
    end

    if potion.skill == 7 then
        targetPlayer:addManaSpent(targetPlayer:getVocation():getRequiredManaSpent(targetPlayer:getBaseMagicLevel() + 1) - targetPlayer:getManaSpent())
    else
        targetPlayer:addSkillTries(potion.skill, targetPlayer:getVocation():getRequiredSkillTries(potion.skill, targetPlayer:getSkillLevel(potion.skill) + 1) - targetPlayer:getSkillTries(potion.skill))
    end

    targetPlayer:setStorageValue(potion.storage, targetPlayer:getStorageValue(potion.storage) + 1)
    if potion.flask then
        targetPlayer:addItem(potion.flask, 1)
    end
    item:remove(1)

end

What you have to do is:
register potions in actions.xml,
add potions to table in this file (and configure them, storage - id of storage storing count of used potions of this type, skill - skill to be added, flask - you don't have to specify this, only if you want to drop flask)
add storage values to each potion

Code:
SKILL_FIST = 0,
SKILL_CLUB = 1,
SKILL_SWORD = 2,
SKILL_AXE = 3,
SKILL_DISTANCE = 4,
SKILL_SHIELD = 5,
SKILL_FISHING = 6,

SKILL_MAGLEVEL = 7,

Not tested
 
Last edited:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    
if getPlayerStorageValue(cid,6319) >= 5 then
            doCreatureSay(cid, "You can only drink this potion once!", TALKTYPE_ORANGE_1)

    elseif getPlayerLevel(cid) >= 250 then
            doCreatureSay(cid, "You have gained some Magic Level Points!", TALKTYPE_ORANGE_1)
            doPlayerAddMagLevel(cid, 1)
            doRemoveItem(item.uid, 1)
            setPlayerStorageValue(cid,6319,5)
            return TRUE
        else
                    doCreatureSay(cid, "You must be over level 250 to drink this potion.", TALKTYPE_ORANGE_1)
        end
end
end

it's TFS 1.3
Is this useful in any way ?
what needs to be changed ?
If it can even be used..
Line 8 gives error msg
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
if getPlayerStorageValue(cid,6319) >= 5 then
            doCreatureSay(cid, "You can only drink this potion once!", TALKTYPE_ORANGE_1)

    elseif getPlayerLevel(cid) >= 250 then
            doCreatureSay(cid, "You have gained some Magic Level Points!", TALKTYPE_ORANGE_1)
            doPlayerAddMagLevel(cid, 1)
            doRemoveItem(item.uid, 1)
            setPlayerStorageValue(cid,6319,5)
            return TRUE
        else
                    doCreatureSay(cid, "You must be over level 250 to drink this potion.", TALKTYPE_ORANGE_1)
        end
end
end

it's TFS 1.3
Is this useful in any way ?
what needs to be changed ?
If it can even be used..
Line 8 gives error msg
It can be adapted but i suggest you to try out script which i posted earlier first because it is specifically written for your needs.
 
First of all you have to save this script inside your data/actions/scripts/others folder, then inside your actions.xml located in data/actions register this script by adding
XML:
<action itemid="your potion id" script="others/scriptname.lua"/>
For each potion you want.

Then inside your script file add inside potions array every potion you registered in actions.xml using example already present in array. Add missing storage values and your are ready to go.
 
Back
Top