• 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)...
I added a check for exhaustion for storage 19002, just like the other script does...

If that doesn't work, then i dont know why, because it should work... good luck!

p.s upgrade to 1.4....
 
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)
setConditionParam(config.exhaustt, CONDITION_PARAM_TICKS, config.cooldown * 1000)
setCombatCondition(config.combat, config.exhaust)
setCombatCondition(config.combat, config.exhaustt)

local function removeConditions(cid)
    doCreatureSetNoMove(cid, false)
    doRemoveCondition(cid, CONDITION_EXHAUST, 1)
    doRemoveCondition(cid, CONDITION_EXHAUST, 2)
end

local 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
    return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not isPlayer(cid) or not itemEx or not isPlayer(itemEx.uid) then
        return false
    end

    local lastUse = getPlayerStorageValue(cid, config.storage)
    if lastUse and (lastUse - os.time()) > 0 then
        local remainingTime = lastUse - os.time()
        return doPlayerSendCancel(cid, "You must wait " .. remainingTime .. " seconds before using this ability again.")
    end

    if getTilePzInfo(toPosition) then
        return doPlayerSendCancel(cid, "You cannot use this in a protection zone.")
    end

    if cid == itemEx.uid then
        return doPlayerSendCancel(cid, "You cannot use this on yourself.")
    end

    doSendMagicEffect(getCreaturePosition(itemEx.uid), 110)
    doSendAnimatedText(getCreaturePosition(itemEx.uid), "Frozen!", TEXTCOLOR_BLUE)
    doPlayerSetStorageValue(itemEx.uid, 10569, 1)

    local function back()
        if isPlayer(itemEx.uid) then
            doPlayerSetStorageValue(itemEx.uid, 10569, -1)
        end
    end
    addEvent(back, config.freezetime * 1000)

    exhaustion.set(cid, config.storage, config.cooldown)

    local playerPosition = getCreaturePosition(cid)
    local targetPosition = getCreaturePosition(itemEx.uid)
    if getDistanceBetween(playerPosition, targetPosition) <= 1 then
        doCreatureSetNoMove(itemEx.uid, true)
        countDown(config.freezetime, targetPosition, 0, "melted", "melted")
        addEvent(removeConditions, config.freezetime * 1000, itemEx.uid)
        return true
    else
        doCreatureSetNoMove(itemEx.uid, true)
        addEvent(countDown, 500, config.freezetime, targetPosition, 0, "melted", "melted")
        addEvent(removeConditions, config.freezetime * 1000, itemEx.uid)
        return true
    end
end

data/actions/potions.lua.
Lua:
local config = {
    removeOnUse = false,
    usableOnTarget = false, -- Can be used on target? (e.g., healing a friend)
    splashable = false,
    realAnimation = false, -- 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)
    if getPlayerStorageValue(cid, 10569) == 1 then
        doSendAnimatedText(getCreaturePosition(cid), "Frozen!", TEXTCOLOR_BLUE)
        doSendMagicEffect(getCreaturePosition(cid), 110)
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return false
    end

    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 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 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 config.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

If you want to prevent the use of magic and other potions like Ultimate Healing Potions, Healing Potions, etc., simply add it below 'onUse,' and another spell should also be added below 'onCastSpell.' Problem solved!
Lua:
  if getPlayerStorageValue(cid, 10569) == 1 then
        doSendAnimatedText(getCreaturePosition(cid), "Frozen!", TEXTCOLOR_BLUE)
        doSendMagicEffect(getCreaturePosition(cid), 110)
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return false
    end
 
Last edited:
Solution
Back
Top