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

Lua Solved

Lbtg

Advanced OT User
Joined
Nov 22, 2008
Messages
2,398
Reaction score
165
Hello i got this scrip custom pot
it works good , but i want to put exaust like real potion and
Vocations i want that only
1,2,3 voc LEts say can use it
script
PHP:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 20000))

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local level = 550
    local mana_add = math.random(4600,5600)
    if getPlayerLevel(cid) >= level then
        doCreatureAddHealth(cid, mana_add)
        for i = 1,3 do
        doSendMagicEffect(getThingPos(itemEx.uid), math.random(8,8)+i)
        end
        doCreatureSay(itemEx.uid, "Yeah!!", TALKTYPE_ORANGE_1)
    else
        doPlayerSendCancel(cid, "You Need More Levels To Use This.")
    end
    return true
end

thanks in advance

Aswell can i ask for same script but it should heal health and mana on use
 
Last edited:
add it in the potions script like any other potions and change numbers
Code:
local POTIONS = {
    [8704] = {empty = 7636, splash = 42, health = {50, 100}}, -- small health potion
    [7618] = {empty = 7636, splash = 42, health = {100, 200}}, -- health potion
    [7588] = {empty = 7634, splash = 42, health = {200, 400}, level = 50, vocations = {3, 4, 7, 8}, vocStr = "knights and paladins"}, -- strong health potion
    [7591] = {empty = 7635, splash = 42, health = {500, 700}, level = 80, vocations = {4, 8}, vocStr = "knights"}, -- great health potion
    [8473] = {empty = 7635, splash = 42, health = {800, 1000}, level = 130, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion

    [7620] = {empty = 7636, splash = 47, mana = {70, 130}}, -- mana potion
    [7589] = {empty = 7634, splash = 47, mana = {110, 190}, level = 50, vocations = {1, 2, 3, 5, 6, 7}, vocStr = "sorcerers, druids and paladins"}, -- strong mana potion
    [7590] = {empty = 7635, splash = 47, mana = {200, 300}, level = 80, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- great mana potion

    [8472] = {empty = 7635, splash = 43, health = {200, 400}, mana = {110, 190}, level = 80, vocations = {3, 7}, vocStr = "paladins"} -- great spirit potion
}
just add another one there with the right data and it should work
 
can't do like this i need on use script since the pots cant be used on something else just clicked.
so i need to fix the script :)
 
+ i get error on use potion(my script)
HTML:
[13:42:49.744] [Error - Action Interface]
[13:42:49.744] data/actions/scripts/liquids/healthpot.lua:onUse
[13:42:49.744] Description:
[13:42:49.744] (luaDoCreatureSay) Creature not found
 
Code:
exhaustion =
{
    check = function (cid, storage)
        if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        return getPlayerStorageValue(cid, storage) >= os.time()
    end,

    get = function (cid, storage)
        if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        local exhaust = getPlayerStorageValue(cid, storage)
        if(exhaust > 0) then
            local left = exhaust - os.time()
            if(left >= 0) then
                return left
            end
        end

        return false
    end,

    set = function (cid, storage, time)
        setPlayerStorageValue(cid, storage, os.time() + time)
    end,

    make = function (cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if(not exhaust) then
            exhaustion.set(cid, storage, time)
            return true
        end

        return false
    end
}
set special exhaust via these functions (cred to @Printer .. i think)

however if you do set exhaust via this you also have to add this to the regular potion script so you cant double pot
 
+ i get error on use potion(my script)
HTML:
[13:42:49.744] [Error - Action Interface]
[13:42:49.744] data/actions/scripts/liquids/healthpot.lua:onUse
[13:42:49.744] Description:
[13:42:49.744] (luaDoCreatureSay) Creature not found
ofc you get that error, you have
Code:
doCreatureSay(itemEx.uid, "Yeah!!", TALKTYPE_ORANGE_1)
doCreatureSay(cid, txt, TALKTYPE)
is itemEx.uid a creature id? no, then change itemEx.uid to cid

edit: a "solution" you can use it to re-use potions, like the lowest lvl hp pot gives like 100-200 hp in default script, but you can add to it lvl2Health = {x,y} and lvl2 = 500 for example
and in the script if playerLevel >= lvl2 give lvl2Health else give health
its a little bit wonky but it should work
 
ofc you get that error, you have
Code:
doCreatureSay(itemEx.uid, "Yeah!!", TALKTYPE_ORANGE_1)
doCreatureSay(cid, txt, TALKTYPE)
is itemEx.uid a creature id? no, then change itemEx.uid to cid

edit: a "solution" you can use it to re-use potions, like the lowest lvl hp pot gives like 100-200 hp in default script, but you can add to it lvl2Health = {x,y} and lvl2 = 500 for example
and in the script if playerLevel >= lvl2 give lvl2Health else give health
its a little bit wonky but it should work

error gone ^^
can you please so 1,2,3 only vocs can use and exaust so it cant be spammed ? :) becouse now i can spam it and i want to use same time as normal potion
 
actually after looking at potions.lua itemEx.uid should work (my bad i dont really use 0.4 or bother with potions :( ) but meh
 
using like this
Code:
[8704] = {empty = 7636, splash = 42, health = {50, 100}, health2 = {500, 1000}, level2 = 8}
in potions config and then

Code:
    local health = {}
    if getPlayerLevel(itemEx.uid) < potion.level2 then
        health = potion.health
    else
        health = potion.health2
    end
at line ~~80 will allow you to re-use potions any amount of times you wish for high lvls (if they can cope with using a nooby looking potion :))
 
using like this
Code:
[8704] = {empty = 7636, splash = 42, health = {50, 100}, health2 = {500, 1000}, level2 = 8}
in potions config and then

Code:
    local health = {}
    if getPlayerLevel(itemEx.uid) < potion.level2 then
        health = potion.health
    else
        health = potion.health2
    end
at line ~~80 will allow you to re-use potions any amount of times you wish for high lvls (if they can cope with using a nooby looking potion :))
wooot ? :D didint get what you mean
can you please add in my script so i can have exaust time to use it aswell as only 1,2,3 voc can use it ? :)
 
this potion can't be used on someone else . it heals on click item(onuse)
then theres not really a problem with it :)

that example was for re-using a potion. ex Small health potion normally gives 50-100 hp, but if you're above the configured lvl (8 in my example) it will heal 500-100 instead.
but if you want to use a custom item onuse you'd have to add the exhaust. set/get functions i pasted above, in both this script and the regular potion script to avoid double potion conflicts
 
actually just change
Code:
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 20000))
to
Code:
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
and the exhaust should work
the getConfigInfo("~~") returns 1000, so by doing -20k you give -19k MS exhaust

edit:
for vocation thing add to ur script
Code:
local vocations = {1,2,3...}
and change
Code:
if getPlayerLevel(cid) >= level then
to
Code:
if getPlayerLevel(cid) >= level and isInArray(vocations, getPlayerVocation(cid)) then
 
actually just change
Code:
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 20000))
to
Code:
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
and the exhaust should work
the getConfigInfo("~~") returns 1000, so by doing -20k you give -19k MS exhaust

edit:
for vocation thing add to ur script
Code:
local vocations = {1,2,3}
and change
Code:
if getPlayerLevel(cid) >= level then
to
Code:
if getPlayerLevel(cid) >= level and isInArray(vocations, getPlayerVocation(cid)) then
i did -100 before but i can spam it anyway

like this ?
PHP:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local level = 550
    local vocations = {1,2,3}
    local mana_add = math.random(4600,5600)
    if getPlayerLevel(cid) >= level and isInArray(vocations, getPlayerVocation(cid)) then
        doCreatureAddHealth(cid, mana_add)
        for i = 1,3 do
        doSendMagicEffect(getThingPos(itemEx.uid), math.random(8,8)+i)
        end
        doCreatureSay(cid, "Yeah!!", TALKTYPE_ORANGE_1)
    else
        doPlayerSendCancel(cid, "You Need More Levels To Use This.")
    end
    return true
end
 
well yeah you can spam it cause you dont have
Code:
doAddCondition(cid, exhaust)
anywhere in your script, so it doesnt add that condition..
add it after doCreatureSay~~ before else on a new line
 
Code:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end
    local level = 8
    local mana_add = math.random(4600,5600)
    if getPlayerLevel(cid) >= level then
        doCreatureAddHealth(cid, mana_add)
        for i = 1,3 do
            doSendMagicEffect(getCreaturePosition(cid), math.random(8,8)+i)
        end
        doCreatureSay(cid, mana_add, TALKTYPE_ORANGE_1)
        doAddCondition(cid, exhaust)
    else
        doPlayerSendCancel(cid, "You Need More Levels To Use This.")
    end
    return true
end
works on my 0.3.6
 
it works so to set vocations i do like this ?
PHP:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end
    local level = 550
    local vocations = {1,2,3}
    local mana_add = math.random(4600,5600)
    if getPlayerLevel(cid) >= level and isInArray(vocations, getPlayerVocation(cid)) then
    doCreatureAddHealth(cid, mana_add)
        for i = 1,3 do
            doSendMagicEffect(getCreaturePosition(cid), math.random(8,8)+i)
        end
        doCreatureSay(cid, mana_add, TALKTYPE_ORANGE_1)
        doAddCondition(cid, exhaust)
    else
        doPlayerSendCancel(cid, "You Need More Levels To Use This.")
    end
    return true
end
 
Back
Top