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

Potion that adds magic points

Ernstjan

Active Member
Joined
May 17, 2008
Messages
747
Reaction score
34
Location
Vriezenveen,The Netherlands
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:addManaSpent(1000000)
    return true
end

I have this script wich works perfect, but I tried to make it so you can use it up to 5 times and dissapears on use,
but I keep getting errors in console.
I'm using TFS 1.3, Hopefully somebody can help me create this so it can be used 5 times and 1 potion dissapears when using it,
Thanks in advance!
 
Just a thought, I'm most likely wrong. I am still learning a lot but if I was in your position I would perhaps head into items.xml and set
XML:
<attribute key="charges" value="" />
this attribute under the specific item you're trying to edit?

And see if that works or is any use at all.
 
something like this:

Lua:
        local charges_n = item:getAttribute(ITEM_ATTRIBUTE_CHARGES)
        if charges_n >= 1 then
            item:setAttribute(ITEM_ATTRIBUTE_CHARGES, (charges_n-1))
        end
        player:addManaSpent(1000000)
        if charges_n == 1 then
            item:remove(1)
            return true
        end
 
something like this:

Lua:
        local charges_n = item:getAttribute(ITEM_ATTRIBUTE_CHARGES)
        if charges_n >= 1 then
            item:setAttribute(ITEM_ATTRIBUTE_CHARGES, (charges_n-1))
        end
        player:addManaSpent(1000000)
        if charges_n == 1 then
            item:remove(1)
            return true
        end
This script doesnt do anything when i replace it with my script. So hopefully you can fix it :p


Also I'll be more specific as to what i was trying:


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

    else if getPlayerLevel(cid) >= 250 then
        doCreatureSay(cid, "You have gained some Magic Level Points!", TALKTYPE_ORANGE_1)
            doPlayer:addManaSpent(1000000)
            doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
            doRemoveItem(item.uid)
            setPlayerStorageValue(cid,6319,2)
            return TRUE
        else
                    doCreatureSay(cid, "You must be over level 250 to drink this potion.", TALKTYPE_ORANGE_1)
        end
end
end


I want this script to add magic level progression and if possible to only be used by sorcs and druids and can be used 5 times.

first line likely has to be something like this:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)

But im not sure
 
Last edited:
A friend of mine has fixed it just as how i wanted: All credits goto grekftw!


Code:
local potions = {
    [26201] = {skill = 7, storage = 30018, flask = 7636},
}
 
function onUse(cid, item)
 
    if not cid:isPlayer() then
        return false
    end
 
    local player = Player(cid)
    local potion = potions[item:getId()]
    if not potion then
        return false
    end
 
    if player:getStorageValue(potion.storage) >= 4 then
        doCreatureSay(cid, "You already drank all five potions.", TALKTYPE_ORANGE_1)
        return false
    end
 
    if potion.skill == 7 then
        player:addManaSpent(1000000)
        doCreatureSay(cid, "You have gained some Magic Level Points!", TALKTYPE_ORANGE_1)
    else
        player:addSkillTries(potion.skill, player:getVocation():getRequiredSkillTries(potion.skill, player:getSkillLevel(potion.skill) + 1) - player:getSkillTries(potion.skill))
    end
 
    player:setStorageValue(potion.storage, player:getStorageValue(potion.storage) + 1)
    if potion.flask then
        player:addItem(potion.flask, 1)
    end
    item:remove(1)
 
end
 
Back
Top