• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua [TFS 0.X] Mana Fluid error

potinho

Well-Known Member
Joined
Oct 11, 2009
Messages
1,190
Solutions
17
Reaction score
92
Location
Brazil
Im getting those errors when try to use mana fluid running:

2022-06-11 23:22:50 - [Error - Action Interface]
2022-06-11 23:22:50 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-11 23:22:50 - Description:
2022-06-11 23:22:50 - (luaHasItemProperty) Item not found
2022-06-11 23:22:50 -
2022-06-11 23:22:50 - [Error - Action Interface]
2022-06-11 23:22:50 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-11 23:22:50 - Description:
2022-06-11 23:22:50 - (luaDoCreateItem) Tile not found
2022-06-11 23:22:50 -
2022-06-11 23:22:50 - [Error - Action Interface]
2022-06-11 23:22:50 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-11 23:22:50 - Description:
2022-06-11 23:22:50 - (luaDoDecayItem) Item not found


Someone can help me to fix? How to make possible use mana fluid pressing hotkey in OTCv8?

potions.lua

Lua:
local ITEM_RUM_FLASK = 5553

local TYPE_EMPTY = 0
local TYPE_WATER = 1
local TYPE_BLOOD = 2
local TYPE_BEER = 3
local TYPE_SLIME = 4
local TYPE_LEMONADE = 5
local TYPE_MILK = 6
local TYPE_MANA_FLUID = 7
local TYPE_LIFE_FLUID = 10
local TYPE_OIL = 11
local TYPE_URINE = 13
local TYPE_COCONUT_MILK = 14
local TYPE_WINE = 15
local TYPE_MUD = 19
local TYPE_FRUIT_JUICE = 21
local TYPE_LAVA = 26
local TYPE_RUM = 27
local TYPE_SWAMP = 28
local TYPE_TEA = 35

local oilLamps = {[2046] = 2044}
local casks = {[1771] = TYPE_WATER, [1772] = TYPE_BEER, [1773] = TYPE_WINE}
local alcoholDrinks = {TYPE_BEER, TYPE_WINE, TYPE_RUM}
local poisonDrinks = {TYPE_SLIME, TYPE_SWAMP}

local drunk = createConditionObject(CONDITION_DRUNK)
setConditionParam(drunk, CONDITION_PARAM_TICKS, 60000)

local poison = createConditionObject(CONDITION_POISON)
setConditionParam(poison, CONDITION_PARAM_DELAYED, true) -- Condition will delay the first damage from when it's added
setConditionParam(poison, CONDITION_PARAM_MINVALUE, -50) -- Minimum damage the condition can do at total
setConditionParam(poison, CONDITION_PARAM_MAXVALUE, -120) -- Maximum damage
setConditionParam(poison, CONDITION_PARAM_STARTVALUE, -5) -- The damage the condition will do on the first hit
setConditionParam(poison, CONDITION_PARAM_TICKINTERVAL, 4000) -- Delay between damages
setConditionParam(poison, CONDITION_PARAM_FORCEUPDATE, true) -- Re-update condition when adding it(ie. min/max value)

local burn = createConditionObject(CONDITION_FIRE)
setConditionParam(burn, CONDITION_PARAM_DELAYED, true) -- Condition will delay the first damage from when it's added
setConditionParam(burn, CONDITION_PARAM_MINVALUE, -70) -- Minimum damage the condition can do at total
setConditionParam(burn, CONDITION_PARAM_MAXVALUE, -150) -- Maximum damage
setConditionParam(burn, CONDITION_PARAM_STARTVALUE, -10) -- The damage the condition will do on the first hit
setConditionParam(burn, CONDITION_PARAM_TICKINTERVAL, 10000) -- Delay between damages
setConditionParam(burn, CONDITION_PARAM_FORCEUPDATE, true) -- Re-update condition when adding it(ie. min/max value)

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(doComparePositions(getCreaturePosition(cid), toPosition))then
itemEx.uid = cid
end
    
    if(itemEx.uid == cid) then
    if(item.type == TYPE_EMPTY) then
        doPlayerSendCancel(cid, "It is empty.")
        return true
    end

    if(item.type == TYPE_MANA_FLUID) then
        if(not doPlayerAddMana(itemEx.uid, math.random(40, 80))) then
            return false
        end

        doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_MONSTER_SAY)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
    elseif(item.type == TYPE_LIFE_FLUID) then
        if(not doCreatureAddHealth(itemEx.uid, math.random(40, 80))) then
            return false
        end

        doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_MONSTER_SAY)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
    elseif(isInArray(alcoholDrinks, item.type)) then
        if(not doTargetCombatCondition(0, cid, drunk, CONST_ME_NONE)) then
            return false
        end

        doCreatureSay(cid, "Aaah...", TALKTYPE_MONSTER_SAY)
    elseif(isInArray(poisonDrinks, item.type)) then
        if(not doTargetCombatCondition(0, cid, poison, CONST_ME_NONE)) then
            return false
        end

        doCreatureSay(cid, "Urgh!", TALKTYPE_MONSTER_SAY)
    elseif(item.type == TYPE_LAVA) then
        if(not doTargetCombatCondition(0, cid, burn, CONST_ME_NONE)) then
            return false
        end

        doCreatureSay(cid, "Urgh!", TALKTYPE_MONSTER_SAY)
    else
        doCreatureSay(cid, "Gulp.", TALKTYPE_MONSTER_SAY)
    end

    doRemoveItem(item.uid)
    return true
end

if(not isCreature(itemEx.uid)) then
    if(item.type == TYPE_EMPTY) then
        if(isItemFluidContainer(itemEx.itemid) and itemEx.type ~= TYPE_EMPTY) then
            doChangeTypeItem(item.uid, itemEx.type)
            doChangeTypeItem(itemEx.uid, TYPE_EMPTY)
            return true
        end

        local tmp = casks[itemEx.itemid]
        if(tmp == nil) then
            tmp = getFluidSourceType(itemEx.itemid)
        end

        if(tmp) then
            doChangeTypeItem(item.uid, tmp)
            return true
        end

        doPlayerSendCancel(cid, "It is empty.")
        return true
    end

    local tmp = oilLamps[itemEx.itemid]
    if(item.type == TYPE_OIL and tmp ~= nil) then
        doTransformItem(itemEx.uid, tmp)
        doRemoveItem(item.uid)
        return true
    end

    if(isItemFluidContainer(itemEx.itemid) and itemEx.type == TYPE_EMPTY) then
        doChangeTypeItem(itemEx.uid, itemEx.type)
        doRemoveItem(item.uid)
        return true
    end

    if(hasProperty(itemEx.uid, CONST_PROP_BLOCKSOLID)) then
        return false
    end
end

if(item.type == TYPE_EMPTY) then
    doPlayerSendCancel(cid, "It is empty.")
    return true
end

doDecayItem(doCreateItem(2016, item.type, toPosition))
doRemoveItem(item.uid)
return true
end
 
OP
OP
potinho

potinho

Well-Known Member
Joined
Oct 11, 2009
Messages
1,190
Solutions
17
Reaction score
92
Location
Brazil
So the splash effect is not being spawned for whatever reason...
I'd try confirming that it was created successfully before trying to decay the item.

change
Lua:
doDecayItem(doCreateItem(2016, item.type, toPosition))
to
Lua:
local splash = doCreateItem(2016, item.type, toPosition)
if splash.uid > 0 then
    doDecayItem(splash) -- might need to be splash.uid.. can't remember 0.x stuff anymore
end
with splash or splash.uid got error:

2022-06-30 07:59:24 - [Error - Action Interface]
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 07:59:24 - Description:
2022-06-30 07:59:24 - (luaHasItemProperty) Item not found
2022-06-30 07:59:24 -
2022-06-30 07:59:24 - [Error - Action Interface]
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 07:59:24 - Description:
2022-06-30 07:59:24 - (luaDoCreateItem) Tile not found
2022-06-30 07:59:24 -
2022-06-30 07:59:24 - [Error - Action Interface]
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 07:59:24 - Description:
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:144: attempt to index local 'splash' (a boolean value)
2022-06-30 07:59:24 - stack traceback:
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:144: in function <data/actions/scripts/liquids/potions.lua:47>
 

underewar

Active Member
Joined
Feb 9, 2013
Messages
41
Reaction score
42
Location
Brazil
GitHub
Underewarrr
with splash or splash.uid got error:

2022-06-30 07:59:24 - [Error - Action Interface]
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 07:59:24 - Description:
2022-06-30 07:59:24 - (luaHasItemProperty) Item not found
2022-06-30 07:59:24 -
2022-06-30 07:59:24 - [Error - Action Interface]
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 07:59:24 - Description:
2022-06-30 07:59:24 - (luaDoCreateItem) Tile not found
2022-06-30 07:59:24 -
2022-06-30 07:59:24 - [Error - Action Interface]
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 07:59:24 - Description:
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:144: attempt to index local 'splash' (a boolean value)
2022-06-30 07:59:24 - stack traceback:
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:144: in function <data/actions/scripts/liquids/potions.lua:47>
Looks like you take a datapack and trow in a random src.
 
OP
OP
potinho

potinho

Well-Known Member
Joined
Oct 11, 2009
Messages
1,190
Solutions
17
Reaction score
92
Location
Brazil
Looks like you take a datapack and trow in a random src.
Maybe, but happens with this data pack too:

 

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,245
Solutions
545
Reaction score
4,487
with splash or splash.uid got error:

2022-06-30 07:59:24 - [Error - Action Interface]
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 07:59:24 - Description:
2022-06-30 07:59:24 - (luaHasItemProperty) Item not found
2022-06-30 07:59:24 -
2022-06-30 07:59:24 - [Error - Action Interface]
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 07:59:24 - Description:
2022-06-30 07:59:24 - (luaDoCreateItem) Tile not found
2022-06-30 07:59:24 -
2022-06-30 07:59:24 - [Error - Action Interface]
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 07:59:24 - Description:
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:144: attempt to index local 'splash' (a boolean value)
2022-06-30 07:59:24 - stack traceback:
2022-06-30 07:59:24 - data/actions/scripts/liquids/potions.lua:144: in function <data/actions/scripts/liquids/potions.lua:47>
Something is going wrong with toPosition...

Let's print that.
Lua:
print("--------")
print(toPosition.x, toPosition.y, toPosition.z)
local splash = doCreateItem(2016, item.type, toPosition)
if splash.uid > 0 then
    doDecayItem(splash) -- might need to be splash.uid.. can't remember 0.x stuff anymore
end
 
OP
OP
potinho

potinho

Well-Known Member
Joined
Oct 11, 2009
Messages
1,190
Solutions
17
Reaction score
92
Location
Brazil
Something is going wrong with toPosition...

Let's print that.
Lua:
print("--------")
print(toPosition.x, toPosition.y, toPosition.z)
local splash = doCreateItem(2016, item.type, toPosition)
if splash.uid > 0 then
    doDecayItem(splash) -- might need to be splash.uid.. can't remember 0.x stuff anymore
end
2022-06-30 18:36:54 - [Error - Action Interface]
2022-06-30 18:36:54 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 18:36:54 - Description:
2022-06-30 18:36:54 - (luaHasItemProperty) Item not found
2022-06-30 18:36:54 - --------
2022-06-30 18:36:54 - 0
2022-06-30 18:36:54 - 0
2022-06-30 18:36:54 - 0
2022-06-30 18:36:54 -
2022-06-30 18:36:54 - [Error - Action Interface]
2022-06-30 18:36:54 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 18:36:54 - Description:
2022-06-30 18:36:54 - (luaDoCreateItem) Tile not found
2022-06-30 18:36:54 -
2022-06-30 18:36:54 - [Error - Action Interface]
2022-06-30 18:36:54 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 18:36:54 - Description:
2022-06-30 18:36:54 - data/actions/scripts/liquids/potions.lua:151: attempt to index local 'splash' (a boolean value)
2022-06-30 18:36:54 - stack traceback:
2022-06-30 18:36:54 - data/actions/scripts/liquids/potions.lua:151: in function <data/actions/scripts/liquids/potions.lua:47>


Lua:
local ITEM_RUM_FLASK = 5553

local TYPE_EMPTY = 0
local TYPE_WATER = 1
local TYPE_BLOOD = 2
local TYPE_BEER = 3
local TYPE_SLIME = 4
local TYPE_LEMONADE = 5
local TYPE_MILK = 6
local TYPE_MANA_FLUID = 7
local TYPE_LIFE_FLUID = 10
local TYPE_OIL = 11
local TYPE_URINE = 13
local TYPE_COCONUT_MILK = 14
local TYPE_WINE = 15
local TYPE_MUD = 19
local TYPE_FRUIT_JUICE = 21
local TYPE_LAVA = 26
local TYPE_RUM = 27
local TYPE_SWAMP = 28
local TYPE_TEA = 35

local oilLamps = {[2046] = 2044}
local casks = {[1771] = TYPE_WATER, [1772] = TYPE_BEER, [1773] = TYPE_WINE}
local alcoholDrinks = {TYPE_BEER, TYPE_WINE, TYPE_RUM}
local poisonDrinks = {TYPE_SLIME, TYPE_SWAMP}

local drunk = createConditionObject(CONDITION_DRUNK)
setConditionParam(drunk, CONDITION_PARAM_TICKS, 60000)

local poison = createConditionObject(CONDITION_POISON)
setConditionParam(poison, CONDITION_PARAM_DELAYED, true) -- Condition will delay the first damage from when it's added
setConditionParam(poison, CONDITION_PARAM_MINVALUE, -50) -- Minimum damage the condition can do at total
setConditionParam(poison, CONDITION_PARAM_MAXVALUE, -120) -- Maximum damage
setConditionParam(poison, CONDITION_PARAM_STARTVALUE, -5) -- The damage the condition will do on the first hit
setConditionParam(poison, CONDITION_PARAM_TICKINTERVAL, 4000) -- Delay between damages
setConditionParam(poison, CONDITION_PARAM_FORCEUPDATE, true) -- Re-update condition when adding it(ie. min/max value)

local burn = createConditionObject(CONDITION_FIRE)
setConditionParam(burn, CONDITION_PARAM_DELAYED, true) -- Condition will delay the first damage from when it's added
setConditionParam(burn, CONDITION_PARAM_MINVALUE, -70) -- Minimum damage the condition can do at total
setConditionParam(burn, CONDITION_PARAM_MAXVALUE, -150) -- Maximum damage
setConditionParam(burn, CONDITION_PARAM_STARTVALUE, -10) -- The damage the condition will do on the first hit
setConditionParam(burn, CONDITION_PARAM_TICKINTERVAL, 10000) -- Delay between damages
setConditionParam(burn, CONDITION_PARAM_FORCEUPDATE, true) -- Re-update condition when adding it(ie. min/max value)

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(doComparePositions(getCreaturePosition(cid), toPosition))then
itemEx.uid = cid
end
   
    if(itemEx.uid == cid) then
    if(item.type == TYPE_EMPTY) then
        doPlayerSendCancel(cid, "It is empty.")
        print(1)
        return true
    end

    if(item.type == TYPE_MANA_FLUID) then
        if(not doPlayerAddMana(itemEx.uid, math.random(40, 80))) then
        print(2)
            return false
        end

        doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_MONSTER_SAY)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
        print(3)
    elseif(item.type == TYPE_LIFE_FLUID) then
        if(not doCreatureAddHealth(itemEx.uid, math.random(40, 80))) then
            return false
        end

        doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_MONSTER_SAY)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
    elseif(isInArray(alcoholDrinks, item.type)) then
        if(not doTargetCombatCondition(0, cid, drunk, CONST_ME_NONE)) then
            return false
        end

        doCreatureSay(cid, "Aaah...", TALKTYPE_MONSTER_SAY)
    elseif(isInArray(poisonDrinks, item.type)) then
        if(not doTargetCombatCondition(0, cid, poison, CONST_ME_NONE)) then
            return false
        end

        doCreatureSay(cid, "Urgh!", TALKTYPE_MONSTER_SAY)
    elseif(item.type == TYPE_LAVA) then
        if(not doTargetCombatCondition(0, cid, burn, CONST_ME_NONE)) then
            return false
        end

        doCreatureSay(cid, "Urgh!", TALKTYPE_MONSTER_SAY)
    else
        doCreatureSay(cid, "Gulp.", TALKTYPE_MONSTER_SAY)
    end

    doRemoveItem(item.uid)
    return true
end

if(not isCreature(itemEx.uid)) then
    if(item.type == TYPE_EMPTY) then
        if(isItemFluidContainer(itemEx.itemid) and itemEx.type ~= TYPE_EMPTY) then
            doChangeTypeItem(item.uid, itemEx.type)
            doChangeTypeItem(itemEx.uid, TYPE_EMPTY)
            print(4)
            return true
        end

        local tmp = casks[itemEx.itemid]
        if(tmp == nil) then
            tmp = getFluidSourceType(itemEx.itemid)
        end

        if(tmp) then
            doChangeTypeItem(item.uid, tmp)
            return true
        end

        doPlayerSendCancel(cid, "It is empty.")
        return true
    end

    local tmp = oilLamps[itemEx.itemid]
    if(item.type == TYPE_OIL and tmp ~= nil) then
        doTransformItem(itemEx.uid, tmp)
        doRemoveItem(item.uid)
        return true
    end

    if(isItemFluidContainer(itemEx.itemid) and itemEx.type == TYPE_EMPTY) then
        doChangeTypeItem(itemEx.uid, itemEx.type)
        print(5)
        doRemoveItem(item.uid)
        return true
    end

    if(hasProperty(itemEx.uid, CONST_PROP_BLOCKSOLID)) then
        return false
    end
end

if(item.type == TYPE_EMPTY) then
    doPlayerSendCancel(cid, "It is empty.")
    return true
end

print("--------")
print(toPosition.x, toPosition.y, toPosition.z)
local splash = doCreateItem(2016, item.type, toPosition)
if splash.uid > 0 then
    doDecayItem(splash) -- might need to be splash.uid.. can't remember 0.x stuff anymore
end
return true
end
 

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,245
Solutions
545
Reaction score
4,487
2022-06-30 18:36:54 - [Error - Action Interface]
2022-06-30 18:36:54 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 18:36:54 - Description:
2022-06-30 18:36:54 - (luaHasItemProperty) Item not found
2022-06-30 18:36:54 - --------
2022-06-30 18:36:54 - 0
2022-06-30 18:36:54 - 0
2022-06-30 18:36:54 - 0
2022-06-30 18:36:54 -
2022-06-30 18:36:54 - [Error - Action Interface]
2022-06-30 18:36:54 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 18:36:54 - Description:
2022-06-30 18:36:54 - (luaDoCreateItem) Tile not found
2022-06-30 18:36:54 -
2022-06-30 18:36:54 - [Error - Action Interface]
2022-06-30 18:36:54 - data/actions/scripts/liquids/potions.lua:eek:nUse
2022-06-30 18:36:54 - Description:
2022-06-30 18:36:54 - data/actions/scripts/liquids/potions.lua:151: attempt to index local 'splash' (a boolean value)
2022-06-30 18:36:54 - stack traceback:
2022-06-30 18:36:54 - data/actions/scripts/liquids/potions.lua:151: in function <data/actions/scripts/liquids/potions.lua:47>


Lua:
local ITEM_RUM_FLASK = 5553

local TYPE_EMPTY = 0
local TYPE_WATER = 1
local TYPE_BLOOD = 2
local TYPE_BEER = 3
local TYPE_SLIME = 4
local TYPE_LEMONADE = 5
local TYPE_MILK = 6
local TYPE_MANA_FLUID = 7
local TYPE_LIFE_FLUID = 10
local TYPE_OIL = 11
local TYPE_URINE = 13
local TYPE_COCONUT_MILK = 14
local TYPE_WINE = 15
local TYPE_MUD = 19
local TYPE_FRUIT_JUICE = 21
local TYPE_LAVA = 26
local TYPE_RUM = 27
local TYPE_SWAMP = 28
local TYPE_TEA = 35

local oilLamps = {[2046] = 2044}
local casks = {[1771] = TYPE_WATER, [1772] = TYPE_BEER, [1773] = TYPE_WINE}
local alcoholDrinks = {TYPE_BEER, TYPE_WINE, TYPE_RUM}
local poisonDrinks = {TYPE_SLIME, TYPE_SWAMP}

local drunk = createConditionObject(CONDITION_DRUNK)
setConditionParam(drunk, CONDITION_PARAM_TICKS, 60000)

local poison = createConditionObject(CONDITION_POISON)
setConditionParam(poison, CONDITION_PARAM_DELAYED, true) -- Condition will delay the first damage from when it's added
setConditionParam(poison, CONDITION_PARAM_MINVALUE, -50) -- Minimum damage the condition can do at total
setConditionParam(poison, CONDITION_PARAM_MAXVALUE, -120) -- Maximum damage
setConditionParam(poison, CONDITION_PARAM_STARTVALUE, -5) -- The damage the condition will do on the first hit
setConditionParam(poison, CONDITION_PARAM_TICKINTERVAL, 4000) -- Delay between damages
setConditionParam(poison, CONDITION_PARAM_FORCEUPDATE, true) -- Re-update condition when adding it(ie. min/max value)

local burn = createConditionObject(CONDITION_FIRE)
setConditionParam(burn, CONDITION_PARAM_DELAYED, true) -- Condition will delay the first damage from when it's added
setConditionParam(burn, CONDITION_PARAM_MINVALUE, -70) -- Minimum damage the condition can do at total
setConditionParam(burn, CONDITION_PARAM_MAXVALUE, -150) -- Maximum damage
setConditionParam(burn, CONDITION_PARAM_STARTVALUE, -10) -- The damage the condition will do on the first hit
setConditionParam(burn, CONDITION_PARAM_TICKINTERVAL, 10000) -- Delay between damages
setConditionParam(burn, CONDITION_PARAM_FORCEUPDATE, true) -- Re-update condition when adding it(ie. min/max value)

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(doComparePositions(getCreaturePosition(cid), toPosition))then
itemEx.uid = cid
end
 
    if(itemEx.uid == cid) then
    if(item.type == TYPE_EMPTY) then
        doPlayerSendCancel(cid, "It is empty.")
        print(1)
        return true
    end

    if(item.type == TYPE_MANA_FLUID) then
        if(not doPlayerAddMana(itemEx.uid, math.random(40, 80))) then
        print(2)
            return false
        end

        doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_MONSTER_SAY)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
        print(3)
    elseif(item.type == TYPE_LIFE_FLUID) then
        if(not doCreatureAddHealth(itemEx.uid, math.random(40, 80))) then
            return false
        end

        doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_MONSTER_SAY)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
    elseif(isInArray(alcoholDrinks, item.type)) then
        if(not doTargetCombatCondition(0, cid, drunk, CONST_ME_NONE)) then
            return false
        end

        doCreatureSay(cid, "Aaah...", TALKTYPE_MONSTER_SAY)
    elseif(isInArray(poisonDrinks, item.type)) then
        if(not doTargetCombatCondition(0, cid, poison, CONST_ME_NONE)) then
            return false
        end

        doCreatureSay(cid, "Urgh!", TALKTYPE_MONSTER_SAY)
    elseif(item.type == TYPE_LAVA) then
        if(not doTargetCombatCondition(0, cid, burn, CONST_ME_NONE)) then
            return false
        end

        doCreatureSay(cid, "Urgh!", TALKTYPE_MONSTER_SAY)
    else
        doCreatureSay(cid, "Gulp.", TALKTYPE_MONSTER_SAY)
    end

    doRemoveItem(item.uid)
    return true
end

if(not isCreature(itemEx.uid)) then
    if(item.type == TYPE_EMPTY) then
        if(isItemFluidContainer(itemEx.itemid) and itemEx.type ~= TYPE_EMPTY) then
            doChangeTypeItem(item.uid, itemEx.type)
            doChangeTypeItem(itemEx.uid, TYPE_EMPTY)
            print(4)
            return true
        end

        local tmp = casks[itemEx.itemid]
        if(tmp == nil) then
            tmp = getFluidSourceType(itemEx.itemid)
        end

        if(tmp) then
            doChangeTypeItem(item.uid, tmp)
            return true
        end

        doPlayerSendCancel(cid, "It is empty.")
        return true
    end

    local tmp = oilLamps[itemEx.itemid]
    if(item.type == TYPE_OIL and tmp ~= nil) then
        doTransformItem(itemEx.uid, tmp)
        doRemoveItem(item.uid)
        return true
    end

    if(isItemFluidContainer(itemEx.itemid) and itemEx.type == TYPE_EMPTY) then
        doChangeTypeItem(itemEx.uid, itemEx.type)
        print(5)
        doRemoveItem(item.uid)
        return true
    end

    if(hasProperty(itemEx.uid, CONST_PROP_BLOCKSOLID)) then
        return false
    end
end

if(item.type == TYPE_EMPTY) then
    doPlayerSendCancel(cid, "It is empty.")
    return true
end

print("--------")
print(toPosition.x, toPosition.y, toPosition.z)
local splash = doCreateItem(2016, item.type, toPosition)
if splash.uid > 0 then
    doDecayItem(splash) -- might need to be splash.uid.. can't remember 0.x stuff anymore
end
return true
end
Well, that's definitely a client issue not sending correct information.

You have 2 options at this point..

You can either ignore the usage of the potion in that scenario, and do nothing, or we can get the position of the player who used it and throw the splash under them.

So, this uses the position of the player..
Lua:
    if toPosition.x == 0 and toPosition.y == 0 and toPosition.z == 0 then
        toPosition = getCreaturePosition(cid)
    end
    doDecayItem(doCreateItem(2016, item.type, toPosition))
or this, which ignore the usage of the item, and creates no splash/doesn't remove item
Lua:
    if toPosition.x == 0 and toPosition.y == 0 and toPosition.z == 0 then
        return true
    end
    doDecayItem(doCreateItem(2016, item.type, toPosition))


Or the third option, fix the client issue directly.
 
OP
OP
potinho

potinho

Well-Known Member
Joined
Oct 11, 2009
Messages
1,190
Solutions
17
Reaction score
92
Location
Brazil
Well, that's definitely a client issue not sending correct information.

You have 2 options at this point..

You can either ignore the usage of the potion in that scenario, and do nothing, or we can get the position of the player who used it and throw the splash under them.

So, this uses the position of the player..
Lua:
    if toPosition.x == 0 and toPosition.y == 0 and toPosition.z == 0 then
        toPosition = getCreaturePosition(cid)
    end
    doDecayItem(doCreateItem(2016, item.type, toPosition))
or this, which ignore the usage of the item, and creates no splash/doesn't remove item
Lua:
    if toPosition.x == 0 and toPosition.y == 0 and toPosition.z == 0 then
        return true
    end
    doDecayItem(doCreateItem(2016, item.type, toPosition))


Or the third option, fix the client issue directly.
Thanks for your patience and help @Xikini , I'll see what I'll do. As it works well (the fluid mana script) I wanted to understand the errors and make them go away. Thank you so much for your help as always. There's a way to put it usable by hotkey in OTCv8?
 
Last edited:
Top