• 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 Script Freeze Rune (Bug Character)

Gaber Zen

Well-Known Member
Joined
Apr 22, 2023
Messages
224
Reaction score
51
Location
Egypt
Hello Guys
I have problem, Script Action Freze Rune After Time down Player Don`t move or logout.
Tibia 8.6 -TFS V
tfs.png
local freezetime = 5
local cooldown = 10 -- time to use again
local storage = 19002
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, exhaust)
local exhaustt = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaustt, CONDITION_PARAM_SUBID, 2)
setConditionParam(exhaustt, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, exhaustt)
function countDown(number, pos, effect, msgonend, effectonend)
local n = number
for i = 1, number do
addEvent(doSendAnimatedText,i* 1000, pos, n > 1 and n.."" or msgonend .."", n < 6 and TEXTCOLOR_RED or TEXTCOLOR_GREEN)
addEvent(doSendMagicEffect,i* 1000, pos, n > 1 and effect or effectonend )
n = n -1
end
n = number
return true
end
function removed(cid)
doCreatureSetNoMove(cid, 0)
doRemoveCondition(cid,CONDITION_EXHAUST,1)
doRemoveCondition(cid,CONDITION_EXHAUST,2)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if exhaustion.get(cid,storage) then
return doPlayerSendCancel(cid,"You can't use this yet.")
end
if getTilePzInfo(toPosition) == true then
return doPlayerSendCancel(cid, "You cant use in pz.")
end

if not isPlayer(itemEx.uid) or cid == itemEx.uid then
return doPlayerSendCancel(cid,"You can only use this on another players.")
end
doSendAnimatedText(getThingPos(itemEx.uid),"Freezed!", TEXTCOLOR_BLUE)
exhaustion.set(cid,storage,cooldown)
doCombat(cid, combat, numberToVariant(itemEx.uid))
doCreatureSetNoMove(itemEx.uid, 1)
countDown(freezetime , toPosition, 0, "melted", 5)
addEvent(removed,freezetime*1000,itemEx.uid)
return true
end
<action itemid="7289" allowfaruse="1" event="script" value="freeze.lua"/>
 
Solution
Tested and it works. When you use a rune on the target player, it silences them, preventing them from using mana potions only.

freeze.lua
Lua:
local config = {
    freezetime = 5,
    cooldown = 10,
    storage = 19002,
    combat = createCombatObject(),
    exhaust = createConditionObject(CONDITION_EXHAUST),
    exhaustt = createConditionObject(CONDITION_EXHAUST)
}

setCombatParam(config.combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
setCombatParam(config.combat, COMBAT_PARAM_AGGRESSIVE, false)

setConditionParam(config.exhaust, CONDITION_PARAM_SUBID, 1)
setConditionParam(config.exhaust, CONDITION_PARAM_TICKS, config.cooldown * 1000)
setConditionParam(config.exhaustt, CONDITION_PARAM_SUBID, 2)...
So remove it from the script, leave a comment and your problem is over, right?
Players no longer freeze!

XML:
<!--action itemid="7289" allowfaruse="1" event="script" value="freeze.lua"/-->
 
After cooldown Over player Can`t walk or logout or dropitems
Lua:
doCreatureSetNoMove(cid, 0)

I think this function is prevented from many things, so you should look for whether you are on the lua script or src and deal with what kind of action you should take, is not it better to copy the paralyze rune and set the speed to 0?
 
in the main function it should be:
Lua:
doCreatureSetNoMove(cid, true)
addEvent(removed,freezetime*1000, cid)

in the removed function it should be:
Lua:
doCreatureSetNoMove(cid, false)
 
in the main function it should be:
Lua:
doCreatureSetNoMove(cid, true)
addEvent(removed,freezetime*1000, cid)

in the removed function it should be:
Lua:
doCreatureSetNoMove(cid, false)
the code is shit,
After cooldown Over player Can`t walk or logout or dropitems

when Add doCreatureSetNoMove(cid, false) <<<< player get frezz but healing how can fix it
 
show me the current script after you applied my changes
Lua:
local freezetime = 5
local cooldown = 10 -- time to use again
local storage = 19002
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, exhaust)
local exhaustt = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaustt, CONDITION_PARAM_SUBID, 2)
setConditionParam(exhaustt, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, exhaustt)
function countDown(number, pos, effect, msgonend, effectonend)
local n = number
for i = 1, number do
addEvent(doSendAnimatedText,i* 1000, pos, n > 1 and n.."" or msgonend .."", n < 6 and TEXTCOLOR_RED or TEXTCOLOR_GREEN)
addEvent(doSendMagicEffect,i* 1000, pos, n > 1 and effect or effectonend )
n = n -1
end
n = number
return true
end
function removed(cid)
doCreatureSetNoMove(cid, false)
doRemoveCondition(cid,CONDITION_EXHAUST,1)
doRemoveCondition(cid,CONDITION_EXHAUST,2)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if exhaustion.get(cid,storage) then
return doPlayerSendCancel(cid,"You can't use this yet.")
end
if getTilePzInfo(toPosition) == true then
return doPlayerSendCancel(cid, "You cant use in pz.")
end

if not isPlayer(itemEx.uid) or cid == itemEx.uid then
return doPlayerSendCancel(cid,"You can only use this on another players.")
end
doSendAnimatedText(getThingPos(itemEx.uid),"Freezed!", TEXTCOLOR_BLUE)
exhaustion.set(cid,storage,cooldown)
doCombat(cid, combat, numberToVariant(itemEx.uid))
doCreatureSetNoMove(itemEx.uid, 1)
countDown(freezetime , toPosition, 0, "melted", 5)
addEvent(removed,freezetime*1000,itemEx.uid)
return true
end
 
Lua:
local freezetime = 5
local cooldown = 10 -- time to use again
local storage = 19002
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, exhaust)
local exhaustt = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaustt, CONDITION_PARAM_SUBID, 2)
setConditionParam(exhaustt, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, exhaustt)
function countDown(number, pos, effect, msgonend, effectonend)
local n = number
for i = 1, number do
addEvent(doSendAnimatedText,i* 1000, pos, n > 1 and n.."" or msgonend .."", n < 6 and TEXTCOLOR_RED or TEXTCOLOR_GREEN)
addEvent(doSendMagicEffect,i* 1000, pos, n > 1 and effect or effectonend )
n = n -1
end
n = number
return true
end
function removed(cid)
doCreatureSetNoMove(cid, false)
doRemoveCondition(cid,CONDITION_EXHAUST,1)
doRemoveCondition(cid,CONDITION_EXHAUST,2)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if exhaustion.get(cid,storage) then
return doPlayerSendCancel(cid,"You can't use this yet.")
end
if getTilePzInfo(toPosition) == true then
return doPlayerSendCancel(cid, "You cant use in pz.")
end

if not isPlayer(itemEx.uid) or cid == itemEx.uid then
return doPlayerSendCancel(cid,"You can only use this on another players.")
end
doSendAnimatedText(getThingPos(itemEx.uid),"Freezed!", TEXTCOLOR_BLUE)
exhaustion.set(cid,storage,cooldown)
doCombat(cid, combat, numberToVariant(itemEx.uid))
doCreatureSetNoMove(itemEx.uid, 1)
countDown(freezetime , toPosition, 0, "melted", 5)
addEvent(removed,freezetime*1000,itemEx.uid)
return true
end

In your potions script (probably something like data/actions/potions.lua), you will need to check the below storage (19002) and if the storage value is 1, return false.

I've refactored your above script so its readable...
Lua:
local freezetime = 5
local cooldown = 10
local storage = 19002
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, exhaust)

local exhaustt = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaustt, CONDITION_PARAM_SUBID, 2)
setConditionParam(exhaustt, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, exhaustt)

function countDown(number, pos, effect, msgonend, effectonend)
    local n = number
    for i = 1, number do
        addEvent(doSendAnimatedText,i* 1000, pos, n > 1 and n.."" or msgonend .."", n < 6 and TEXTCOLOR_RED or TEXTCOLOR_GREEN)
        addEvent(doSendMagicEffect,i* 1000, pos, n > 1 and effect or effectonend )
        n = n -1
    end
   
    n = number
    return true
end

local function removed(cid)
    if isPlayer(cid) then
        doCreatureSetNoMove(cid, false)
        doRemoveCondition(cid, CONDITION_EXHAUST, 1)
        doRemoveCondition(cid, CONDITION_EXHAUST, 2)
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if exhaustion.get(cid, storage) then
        return doPlayerSendCancel(cid,"You can't use this yet.")
    end
    if getTilePzInfo(toPosition) == true then
        return doPlayerSendCancel(cid, "You cant use in pz.")
    end
    if not isPlayer(itemEx.uid) or cid == itemEx.uid then
        return doPlayerSendCancel(cid, "You can only use this on another players.")
    end
   
    doSendAnimatedText(getThingPos(itemEx.uid), "Freezed!", TEXTCOLOR_BLUE)
    exhaustion.set(cid, storage, cooldown)
    doCombat(cid, combat, numberToVariant(itemEx.uid))
    doCreatureSetNoMove(itemEx.uid, true)
   
    addEvent(removed, freezetime * 1000, itemEx.uid)
    countDown(freezetime, toPosition, 0, "melted", 5)
   
    return true
end
 
Learn to read....
In your potions script (probably something like data/actions/potions.lua), you will need to check the below storage (19002) and if the storage value is 1, return false.

Paste here your data/actions/potions.lua
 
Learn to read....


Paste here your data/actions/potions.lua
Lua:
local config = {
    removeOnUse = "no",
    usableOnTarget = "no", -- can be used on target? (fe. healing friend)
    splashable = "no",
    realAnimation = "no", -- make text effect visible only for players in range 1x1
    healthMultiplier = 1.0,
    manaMultiplier = 1.0
}

config.removeOnUse = getBooleanFromString(config.removeOnUse)
config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
config.splashable = getBooleanFromString(config.splashable)
config.realAnimation = getBooleanFromString(config.realAnimation)

local POTIONS = {
    [8704] = {empty = 7636, splash = 2, health = {1,1}}, -- small health potion
    [7618] = {empty = 7636, splash = 2, health = {1,1}}, -- health potion
    [7588] = {empty = 7634, splash = 2, health = {1,1}, level = 1, vocations = {3, 4, 7, 8, 11, 12}, vocStr = "knights and paladins"}, -- strong health potion
    [7591] = {empty = 7635, splash = 2, health = {1,1}, level = 1, vocations = {4, 8, 12}, vocStr = "knights"}, -- great health potion
    [8473] = {empty = 7635, splash = 2, health = {3,5}, level = 1, vocations = {4, 8, 12}, vocStr = "knights"}, -- ultimate health potion
    [7620] = {empty = 7636, splash = 7, mana = {1,1}}, -- mana potion
    [7589] = {empty = 7634, splash = 7, mana = {1,2}, level = 1, vocations = {1, 2, 3, 5, 6, 7, 9, 10}, vocStr = "sorcerers, druids and paladins"}, -- strong mana potion
    [7590] = {empty = 7635, splash = 7, mana = {1,2}, level = 1, vocations = {1, 2, 5, 6, 9, 10}, vocStr = "sorcerers and druids"}, -- great mana potion
    [8472] = {empty = 7635, splash = 3, health = {2,2}, mana = {2, 2}, level = 1, vocations = {3, 7, 11}, vocStr = "paladins"}, -- great spirit potion
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local potion = POTIONS[item.itemid]
    if(not potion) then
        return false
    end
    if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
        if(not config.splashable) then
            return false
        end
        if(toPosition.x == CONTAINER_POSITION) then
            toPosition = getThingPos(item.uid)
        end
        doDecayItem(doCreateItem(2016, potion.splash, toPosition))
        doTransformItem(item.uid, potion.empty)
        return true
    end
    if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end
    if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
    not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
    then
        doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
        return true
    end
    if potion.health ~= nil then
        local health = math.random(potion.health[1], potion.health[2])
        doSendAnimatedText(getThingPos(itemEx.uid), "+"..health.."%", TEXTCOLOR_GREEN)
        if not doCreatureAddHealth(itemEx.uid, math.ceil(getCreatureMaxHealth(cid) * (health / 100))) then
            return false
        end
    end
    if potion.mana ~= nil then
        local mana = math.random(potion.mana[1], potion.mana[2])
        doSendAnimatedText(getThingPos(itemEx.uid), "+"..mana.."%", TEXTCOLOR_BLUE)
        if not doCreatureAddMana(itemEx.uid, math.ceil(getCreatureMaxMana(cid) * (mana / 100))) then
            return false
        end
    end
    if(not realAnimation) then
        doCreatureSay(itemEx.uid, "", TALKTYPE_ORANGE_1)
    else
        for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
            if(isPlayer(tid)) then
                doCreatureSay(itemEx.uid, "", TALKTYPE_ORANGE_1, false, tid)
            end
        end
    end
    doAddCondition(cid, exhaust)
    if(not potion.empty or config.removeOnUse) then
        doRemoveItem(item.uid, 1)
        return true
    end
    doRemoveItem(item.uid, 0)
    doPlayerAddItem(cid, potion.empty, 0)
    doPlayerRemoveItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty))
    doPlayerAddItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty))
    return true
end
 
Lua:
local config = {
    removeOnUse = "no",
    usableOnTarget = "no", -- can be used on target? (fe. healing friend)
    splashable = "no",
    realAnimation = "no", -- make text effect visible only for players in range 1x1
    healthMultiplier = 1.0,
    manaMultiplier = 1.0
}

config.removeOnUse = getBooleanFromString(config.removeOnUse)
config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
config.splashable = getBooleanFromString(config.splashable)
config.realAnimation = getBooleanFromString(config.realAnimation)

local POTIONS = {
    [8704] = {empty = 7636, splash = 2, health = {1,1}}, -- small health potion
    [7618] = {empty = 7636, splash = 2, health = {1,1}}, -- health potion
    [7588] = {empty = 7634, splash = 2, health = {1,1}, level = 1, vocations = {3, 4, 7, 8, 11, 12}, vocStr = "knights and paladins"}, -- strong health potion
    [7591] = {empty = 7635, splash = 2, health = {1,1}, level = 1, vocations = {4, 8, 12}, vocStr = "knights"}, -- great health potion
    [8473] = {empty = 7635, splash = 2, health = {3,5}, level = 1, vocations = {4, 8, 12}, vocStr = "knights"}, -- ultimate health potion
    [7620] = {empty = 7636, splash = 7, mana = {1,1}}, -- mana potion
    [7589] = {empty = 7634, splash = 7, mana = {1,2}, level = 1, vocations = {1, 2, 3, 5, 6, 7, 9, 10}, vocStr = "sorcerers, druids and paladins"}, -- strong mana potion
    [7590] = {empty = 7635, splash = 7, mana = {1,2}, level = 1, vocations = {1, 2, 5, 6, 9, 10}, vocStr = "sorcerers and druids"}, -- great mana potion
    [8472] = {empty = 7635, splash = 3, health = {2,2}, mana = {2, 2}, level = 1, vocations = {3, 7, 11}, vocStr = "paladins"}, -- great spirit potion
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local potion = POTIONS[item.itemid]
    if(not potion) then
        return false
    end
    if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
        if(not config.splashable) then
            return false
        end
        if(toPosition.x == CONTAINER_POSITION) then
            toPosition = getThingPos(item.uid)
        end
        doDecayItem(doCreateItem(2016, potion.splash, toPosition))
        doTransformItem(item.uid, potion.empty)
        return true
    end
    if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end
    if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
    not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
    then
        doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
        return true
    end
    if potion.health ~= nil then
        local health = math.random(potion.health[1], potion.health[2])
        doSendAnimatedText(getThingPos(itemEx.uid), "+"..health.."%", TEXTCOLOR_GREEN)
        if not doCreatureAddHealth(itemEx.uid, math.ceil(getCreatureMaxHealth(cid) * (health / 100))) then
            return false
        end
    end
    if potion.mana ~= nil then
        local mana = math.random(potion.mana[1], potion.mana[2])
        doSendAnimatedText(getThingPos(itemEx.uid), "+"..mana.."%", TEXTCOLOR_BLUE)
        if not doCreatureAddMana(itemEx.uid, math.ceil(getCreatureMaxMana(cid) * (mana / 100))) then
            return false
        end
    end
    if(not realAnimation) then
        doCreatureSay(itemEx.uid, "", TALKTYPE_ORANGE_1)
    else
        for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
            if(isPlayer(tid)) then
                doCreatureSay(itemEx.uid, "", TALKTYPE_ORANGE_1, false, tid)
            end
        end
    end
    doAddCondition(cid, exhaust)
    if(not potion.empty or config.removeOnUse) then
        doRemoveItem(item.uid, 1)
        return true
    end
    doRemoveItem(item.uid, 0)
    doPlayerAddItem(cid, potion.empty, 0)
    doPlayerRemoveItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty))
    doPlayerAddItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty))
    return true
end
Lua:
local config = {
    removeOnUse = "no",
    usableOnTarget = "no", -- can be used on target? (fe. healing friend)
    splashable = "no",
    realAnimation = "no", -- make text effect visible only for players in range 1x1
    healthMultiplier = 1.0,
    manaMultiplier = 1.0
}

config.removeOnUse = getBooleanFromString(config.removeOnUse)
config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
config.splashable = getBooleanFromString(config.splashable)
config.realAnimation = getBooleanFromString(config.realAnimation)

local POTIONS = {
    [8704] = {empty = 7636, splash = 2, health = {1,1}}, -- small health potion
    [7618] = {empty = 7636, splash = 2, health = {1,1}}, -- health potion
    [7588] = {empty = 7634, splash = 2, health = {1,1}, level = 1, vocations = {3, 4, 7, 8, 11, 12}, vocStr = "knights and paladins"}, -- strong health potion
    [7591] = {empty = 7635, splash = 2, health = {1,1}, level = 1, vocations = {4, 8, 12}, vocStr = "knights"}, -- great health potion
    [8473] = {empty = 7635, splash = 2, health = {3,5}, level = 1, vocations = {4, 8, 12}, vocStr = "knights"}, -- ultimate health potion
    [7620] = {empty = 7636, splash = 7, mana = {1,1}}, -- mana potion
    [7589] = {empty = 7634, splash = 7, mana = {1,2}, level = 1, vocations = {1, 2, 3, 5, 6, 7, 9, 10}, vocStr = "sorcerers, druids and paladins"}, -- strong mana potion
    [7590] = {empty = 7635, splash = 7, mana = {1,2}, level = 1, vocations = {1, 2, 5, 6, 9, 10}, vocStr = "sorcerers and druids"}, -- great mana potion
    [8472] = {empty = 7635, splash = 3, health = {2,2}, mana = {2, 2}, level = 1, vocations = {3, 7, 11}, vocStr = "paladins"}, -- great spirit potion
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local potion = POTIONS[item.itemid]
    if(not potion) then
        return false
    end
    
    if exhaustion.get(cid, 19002) then
        return doPlayerSendCancel(cid,"You can't use this yet.")
    end
    
    if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
        if(not config.splashable) then
            return false
        end
        if(toPosition.x == CONTAINER_POSITION) then
            toPosition = getThingPos(item.uid)
        end
        doDecayItem(doCreateItem(2016, potion.splash, toPosition))
        doTransformItem(item.uid, potion.empty)
        return true
    end
    if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end
    if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
    not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
    then
        doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
        return true
    end
    if potion.health ~= nil then
        local health = math.random(potion.health[1], potion.health[2])
        doSendAnimatedText(getThingPos(itemEx.uid), "+"..health.."%", TEXTCOLOR_GREEN)
        if not doCreatureAddHealth(itemEx.uid, math.ceil(getCreatureMaxHealth(cid) * (health / 100))) then
            return false
        end
    end
    if potion.mana ~= nil then
        local mana = math.random(potion.mana[1], potion.mana[2])
        doSendAnimatedText(getThingPos(itemEx.uid), "+"..mana.."%", TEXTCOLOR_BLUE)
        if not doCreatureAddMana(itemEx.uid, math.ceil(getCreatureMaxMana(cid) * (mana / 100))) then
            return false
        end
    end
    if(not realAnimation) then
        doCreatureSay(itemEx.uid, "", TALKTYPE_ORANGE_1)
    else
        for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
            if(isPlayer(tid)) then
                doCreatureSay(itemEx.uid, "", TALKTYPE_ORANGE_1, false, tid)
            end
        end
    end
    doAddCondition(cid, exhaust)
    if(not potion.empty or config.removeOnUse) then
        doRemoveItem(item.uid, 1)
        return true
    end
    doRemoveItem(item.uid, 0)
    doPlayerAddItem(cid, potion.empty, 0)
    doPlayerRemoveItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty))
    doPlayerAddItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty))
    return true
end
 
Back
Top