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

Solved Manafluid & Lifefluid problem (7.4)

auda

Advanced OT User
Joined
Jun 29, 2014
Messages
273
Reaction score
233
Location
Sweden
It seems that manafluids and lifefluids aren't cooperating with me. Instead of adding mana and health it goes with the:
else
doPlayerSay(cid, "Gulp.", 1)
end

Can anyone see a prolem here? Thanks!

Code:
local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000)

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

local poison = createConditionObject(CONDITION_POISON)
setConditionParam(poison, CONDITION_PARAM_DELAYED, true)
addDamageCondition(poison, 5, 6000, -5)
addDamageCondition(poison, 5, 6000, -4)
addDamageCondition(poison, 7, 6000, -3)
addDamageCondition(poison, 10, 6000, -2)
addDamageCondition(poison, 19, 6000, -1)

local SPLASH = 2025
local FLUID = {WATER = 1, BLOOD = 2, BEER = 3, SLIME = 4, LEMONADE = 5, MILK = 6, MANA = 7,
                LIFE = 10, OIL = 11, URINE = 13, WINE = 15, MUD = 19, LAVA = 26, SWAMP = 28}

function onUse(cid, item, frompos, item2, topos)
 
    if item2.itemid == 1 then
        if item2.uid == cid then
            -- using fluid container on yourself
            if item.type ~= 0 then
                -- can't be empty
                if item.type == FLUID.BEER or item.type == FLUID.WINE then
                    doPlayerSay(cid, "Aah...", 1)
                    doAddCondition(cid, drunk)
             
                elseif item.type == FLUID.SLIME then
                    doPlayerSay(cid, "Argh!", 1)
                    doAddCondition(cid, poison)
             
                elseif item.type == FLUID.MANA then
                    if hasCondition(cid, CONDITION_EXHAUST_COMBAT) == TRUE or hasCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE then
                        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)         
                        return TRUE 
                    end
     
                    doPlayerSay(cid, "Aaaah...", 1)
                    doPlayerAddMana(cid, math.random(40, 80))
                    doSendMagicEffect(topos, 12)
                    doAddCondition(cid, exhaust)
             
                elseif item.type == FLUID.LIFE then
                    if hasCondition(cid, CONDITION_EXHAUST_COMBAT) == TRUE or hasCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE then
                        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
                        return TRUE
                    end
             
                    doPlayerSay(cid, "Aaaah...", 1)
                    doPlayerAddHealth(cid, math.random(40, 80))
                    doSendMagicEffect(topos, 12)
                    doAddCondition(cid, exhaust)
                else
                    doPlayerSay(cid, "Gulp.", 1)
                end
            end
         
            doChangeTypeItem(item.uid, 0)
        else
            -- using fluid container on somebody
            local splash = doCreateItem(SPLASH, item.type, topos)
            doDecayItem(splash)
            doChangeTypeItem(item.uid, 0)
        end
    elseif getFluidSourceType(item2.itemid) ~= 0 then
        if item.type ~= 0 then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHROOM)
        else
            -- fill it
            local fluidType = getFluidSourceType(item2.itemid)
            doChangeTypeItem(item.uid, fluidType)
        end
    elseif isItemFluidContainer(item2.itemid) and topos.stackpos ~= 0 then
        -- using fluid container on another fluid container
        if item.type ~= 0 and item2.type ~= 0 then
            -- trying to fill fluid container that is already filled
            local splash = doCreateItem(SPLASH, item.type, topos)
            doDecayItem(splash)
            doChangeTypeItem(item.uid, 0)
        elseif item.type ~= 0 and item2.type == 0 then
            if hasProperty(item2.uid, CONST_PROP_BLOCKSOLID) then
                -- we can't use it on doors, walls, etc.
                return FALSE
            end
         
            -- transfer fluid to another container
            doChangeTypeItem(item2.uid, item.type)
            doChangeTypeItem(item.uid, 0)
        else
            -- trying to use empty on empty or empty on filled
            doPlayerSendDefaultCancel(cid, RETURNVALUE_CANNOTUSETHISOBJECT)
        end
    else
        -- using fluid container on ground
        if item.type ~= 0 then
            local splash = doCreateItem(SPLASH, item.type, topos)
            doDecayItem(splash)
            doChangeTypeItem(item.uid, 0)
        else
            -- fluid container is empty
            doPlayerSendDefaultCancel(cid, RETURNVALUE_CANNOTUSETHISOBJECT)
        end
    end
 
    return TRUE
end
vialbug.png
 
Last edited:
You'd need something like

if item.type == 7 then (which is probably fluid_mana in global.lua or whatever).

What distro are you using? seems you are using an outdated fluids.lua.
 
Sorry for not including it in the title. I use Avesta 0.6.5 (7.40). Also as soon as I now buy a vial from Icarus it's "You see a vial of." I can't even buy a life fluid which is in this script here, I get a "manafluid" instead when buying a life fluid. Any way to solve both these problems?


Code:
_state = 0
_count = 0
_index = 0
_delay = 1000

items = {}
items[0] = {name = 'blank rune', id = 2260, subtype = -1, sell = 10}
items[1] = {name = 'mana fluid', id = 2006, 7, subtype =-1, sell = 50}
items[2] = {name = 'vial', id = 2006, subtype =-1, buy = 5}
items[3] = {name = 'life fluid', id = 2006, 10, subtype =-1, sell = 45}
function getNext()
    nextPlayer = getQueuedPlayer()
    if (nextPlayer ~= nil) then
        if (getDistanceToCreature(nextPlayer) <= 4) then
            updateNpcIdle()
            setNpcFocus(nextPlayer)
            greet(nextPlayer, _delay * 3)
            return
        else
            getNext()
        end
    end


    setNpcFocus(0)
    resetNpcIdle()
end

local function onActionItem(action)
    if ((action == 'buy' and items[_index].sell == -1) or
        (action == 'sell' and items[_index].buy == -1)) then
        return
    end
  
    amount = ''
    suffix = ''
    plural = 'a'
  
    if (_count > 1) then
        amount = ' ' .. tostring(_count)
        suffix = 's'
        plural = ''
    end
  
    cost = items[_index].buy
    if (action == 'buy') then
        cost = items[_index].sell
    end
  
    selfSay('Do you want to ' .. action .. ' each ' .. plural .. amount .. ' ' .. items[_index].name .. suffix .. ' for ' .. cost .. ' gold?')
end

function _selfSay(message)
    selfSay(message, _delay)
    updateNpcIdle()
end

local function greet(cid, delay)
    selfSay('Hi there ' .. getCreatureName(cid) .. '.', delay)
end

function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
    if (getNpcFocus() == cid) then
        selfSay('See you.', _delay)
        getNext()
    else
        unqueuePlayer(cid)
    end
end

function onCreatureMove(cid, oldPos, newPos)
    if (getNpcFocus() == cid) then
        faceCreature(cid)
    end
end

function onCreatureSay(cid, type, msg)
    if (getNpcFocus() == 0) then
        if ((msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) and getDistanceToCreature(cid) <= 4) then
            updateNpcIdle()
            setNpcFocus(cid)
            greet(cid, _delay)
        end
      
    elseif (getNpcFocus() ~= cid) then
        if ((msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) and getDistanceToCreature(cid) <= 4) then
            selfSay('Just wait, ' .. getCreatureName(cid) .. '.', _delay)
            queuePlayer(cid)
        end
      
    else
        if (msgcontains(msg, 'bye')) then
            selfSay('See you.', _delay)
            getNext()
      
        elseif (msgcontains(msg, 'name')) then
            _selfSay('I am Icarus')
      
        elseif (msgcontains(msg, 'job')) then
            _selfSay('I study the art of spellcasting and conjuring.')
      
        elseif (msgcontains(msg, 'king') or msgcontains(msg, 'calvin')) then
            _selfSay('I was kicked out of the city castle by Calvin himself for one slight miscalculation!')
      
        elseif (msgcontains(msg, 'ferumbras')) then
            _selfSay('We do not speak of him here...')
      
        elseif (msgcontains(msg, 'meadowfield')) then
            _selfSay('Hmpf!')
      
        elseif (msgcontains(msg, 'offer') or msgcontains(msg, 'goods')) then
            _selfSay('I\'m selling runes and fluids.')
          
        elseif (msgcontains(msg, 'rune') and not(msgcontains(msg, 'blank'))) then
            _selfSay('I only sell blank runes, for the sake of security.')
          
        elseif (_state == 1) then
            if (msgcontains(msg, 'yes')) then
                if (doPlayerRemoveMoney(cid, items[_index].sell * _count) == 1) then
                    for i = 1, _count do
                        doPlayerAddItem(cid, items[_index].id, items[_index].subtype)
                    end
              
                    selfSay('Here you are.', _delay)
                else
                    selfSay('Come back down here when you have money.', _delay)
                end
              
                updateNpcIdle()
            else
                selfSay('Hmm.', _delay)
            end
          
            _state = 0
          
        elseif (_state == 2) then
            if (msgcontains(msg, 'yes')) then
                if (doPlayerRemoveItem(cid, items[_index].id, _count, items[_index].subtype) == 1) then
                    doPlayerAddMoney(cid, items[_index].buy * _count)
                    selfSay('Ok. Here is your money.')
                else
                    if (count > 1) then
                        selfSay('Sorry, you do not have so many.', _delay)
                    else
                        selfSay('Sorry, you do not have one.', _delay)
                    end
                end
              
                updateNpcIdle()
            else
                selfSay('Perhaps another time.', _delay)
            end
      
            _state = 0
          
        else
            for n = 0, table.getn(items) do
                if (msgcontains(msg, items[n].name) or msgcontains(msg, items[n].name .. "s")) then
                    _count = getCount(msg)
                    _index = n
                  
                    if (msgcontains(msg, 'sell')) then
                        onActionItem('sell')
                        _state = 2
                    else
                        onActionItem('buy')
                        _state = 1
                    end
                  
                    updateNpcIdle()
                    break
                end
            end
        end
    end
end

function onThink()
    if (getNpcFocus() ~= 0) then
        if (isNpcIdle() or getDistanceToCreature(getNpcFocus()) > 4) then
            selfSay('See you.', _delay)
            getNext()
        end
    end
end
 
Last edited:
SOLVED:
I did as you adviced me to and chose to use item.type == number instead of FLUID.MANA to get the vials to work properly.
I also changed in the NPC code:

Code:
items = {}
items[0] = {name = 'blank rune', id = 2260, subtype = -1, sell = 10}
items[1] = {name = 'mana fluid', id = 2006, 7, subtype =-1, sell = 50}
items[2] = {name = 'vial', id = 2006, subtype =-1, buy = 5}
items[3] = {name = 'life fluid', id = 2006, 10, subtype =-1, sell = 45}

To:

Code:
items = {}
items[0] = {name = 'blank rune', id = 2260, subtype = -1, sell = 10}
items[1] = {name = 'mana fluid', id = 2006, subtype = 7, sell = 50}
items[2] = {name = 'vial', id = 2006, subtype =-1, buy = 5}
items[3] = {name = 'life fluid', id = 2006,  subtype = 10, sell = 45}
 
Back
Top