hello Everyone
Have a problem, when player back after dead can`t use potions and tell have freeze
i need code add in Createscript/ login to fix that
Have a problem, when player back after dead can`t use potions and tell have freeze
i need code add in Createscript/ login to fix that
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 = {1,3}, level = 1, vocations = {4, 8, 12}, vocStr = "knights"}, -- Ultimate health potion
[7620] = {empty = 7636, splash = 7, mana = {0,1}}, -- Mana potion
[7589] = {empty = 7634, splash = 7, mana = {0,1}, 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 = {0,1}, level = 1, vocations = {1, 2, 5, 6, 9, 10}, vocStr = "sorcerers and druids"}, -- Great mana potion
[8472] = {empty = 7635, splash = 7, health = {0,1}, mana = {0, 1}, 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
Code:
local config = {
freezetime = 5,
cooldown = 25,
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
Last edited: