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

Foods

Dogrinha

New Member
Joined
Oct 6, 2019
Messages
206
Solutions
1
Reaction score
2
Hey Guys, when a character make food with the backpack full, the food drop in the ground and doesn't count mana. How do i Fix it? TFS 0.4
LUA:
local FOODS = {
    2666, -- meat
    2671, -- ham
    2681, -- grape
    2674, -- aple
    2689, -- bread
    2690, -- roll
    2696 -- cheese
}

function onCastSpell(cid, var)
    local size = table.maxn(FOODS)
    if(not doPlayerAddItem(cid, FOODS[math.random(1, size)])) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return false
    end

    if(math.random(1, 100) > 50) then
        doPlayerAddItem(cid, FOODS[math.random(1, size)])
    end

    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    return true
end
 
Solution
100% rl tibia
It will always create food and always will take mana. If your bp is full or you dont have cap, it will drop food on the ground instead. Exactly like in real Tibia.

LUA:
local FOODS = {
    2666, -- meat
    2671, -- ham
    2681, -- grape
    2674, -- aple
    2689, -- bread
    2690, -- roll
    2696 -- cheese
}

function onCastSpell(cid, var)
    doPlayerAddItem(cid, FOODS[math.random(1, #FOODS)])
    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    return true
end
Try this maybe? I forgot so much from old distros

Code:
local FOODS = {
    2666, -- meat
    2671, -- ham
    2681, -- grape
    2674, -- aple
    2689, -- bread
    2690, -- roll
    2696 -- cheese
}

function onCastSpell(cid, var)
    local food = FOODS[math.random(#FOODS)]

    if getPlayerCapacity(cid) < getItemWeight(food) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    return false
    end

    if(math.random(1, 100) > 50) then
        doPlayerAddItem(cid, food, 1)
    end

    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    return true
end
 
no work, my script work, but
the only problem is that you stop spending mana when you don't have a backpack capacity
 
Last edited:
100% rl tibia
It will always create food and always will take mana. If your bp is full or you dont have cap, it will drop food on the ground instead. Exactly like in real Tibia.

LUA:
local FOODS = {
    2666, -- meat
    2671, -- ham
    2681, -- grape
    2674, -- aple
    2689, -- bread
    2690, -- roll
    2696 -- cheese
}

function onCastSpell(cid, var)
    doPlayerAddItem(cid, FOODS[math.random(1, #FOODS)])
    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    return true
end
 
Last edited:
Solution
Back
Top