• 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 Help, Food Script

furmansss

New Member
Joined
May 21, 2013
Messages
19
Reaction score
0
Hi players on my server need to eat food very often how do i increase the length so any food almost give infinite time? :D
 
Last edited:
I guess you have to change this :p

Lua:
if((getPlayerFood(cid) + food[1]) >= 400) then

Change 400 to something else :p

You can find the file in data/actions/scripts/other
Name of the file is "food"

This is the whole script if you are confused :p
Lua:
local FOODS =
{
	[2362] = {8, "Crunch."},
	[2666] = {15, "Munch."},
	[2667] = {12, "Munch."},
	[2668] = {10, "Mmmm."},
	[2669] = {17, "Munch."},
	[2670] = {4, "Gulp."},
	[2671] = {30, "Chomp."},
	[2672] = {60, "Chomp."},
	[2673] = {5, "Yum."},
	[2674] = {6, "Yum."},
	[2675] = {13, "Yum."},
	[2676] = {8, "Yum."},
	[2677] = {1, "Yum."},
	[2678] = {18, "Slurp."},
	[2679] = {1, "Yum."},
	[2680] = {2, "Yum."},
	[2681] = {9, "Yum."},
	[2682] = {20, "Yum."},
	[2683] = {17, "Munch."},
	[2684] = {8, "Crunch."},
	[2685] = {6, "Munch."},
	[2686] = {9, "Crunch."},
	[2687] = {2, "Crunch."},
	[2688] = {9, "Munch."},
	[2689] = {10, "Crunch."},
	[2690] = {3, "Crunch."},
	[2691] = {8, "Crunch."},
	[2792] = {6, "Munch."},
	[2793] = {9, "Munch."},
	[2695] = {6, "Gulp."},
	[2696] = {9, "Smack."},
	[2787] = {9, "Munch."},
	[2788] = {4, "Munch."},
	[2789] = {22, "Munch."},
	[2790] = {30, "Munch."},
	[2791] = {30, "Munch."},
	[2792] = {6, "Munch."},
	[2794] = {3, "Munch."},
	[2795] = {36, "Munch."},
	[2796] = {5, "Munch."},
	[2793] = {9, "Munch."},
	[5097] = {4, "Yum."},
	[6125] = {8, "Gulp."},
	[6278] = {10, "Mmmm."},
	[6279] = {15, "Mmmm."},
	[6393] = {12, "Mmmm."},
	[6394] = {15, "Mmmm."},
	[6501] = {20, "Mmmm."},
	[6541] = {6, "Gulp."},
	[6542] = {6, "Gulp."},
	[6543] = {6, "Gulp."},
	[6544] = {6, "Gulp."},
	[6545] = {6, "Gulp."},
	[6569] = {1, "Mmmm."},
	[6574] = {4, "Mmmm."},
	[7158] = {15, "Munch."},
	[7159] = {13, "Munch."},
	[7372] = {7, "Yum."},
	[7373] = {7, "Yum."},
	[7374] = {7, "Yum."},
	[7375] = {7, "Yum."},
	[7376] = {7, "Yum."},
	[7377] = {7, "Yum."},
	[7909] = {4, "Crunch."},
	[8838] = {7, "Gulp."},
	[8839] = {5, "Yum."},
	[8840] = {2, "Yum."},
	[8841] = {3, "Urgh."},
	[8842] = {3, "Munch."},
	[8843] = {3, "Crunch."},
	[8844] = {3, "Gulp."},
	[8845] = {2, "Munch."},
	[8847] = {11, "Yum."}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local food = FOODS[item.itemid]
	if(not food) then
		return false
	end

	if((getPlayerFood(cid) + food[1]) >= 400) then
		doPlayerSendCancel(cid, "You are full.")
		return true
	end

	doPlayerFeed(cid, food[1] * 4)
	doCreatureSay(cid, food[2], TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
	return true
end

Rep ++ if this helps :p (I haven't tested it)

Remember to change to "Solved" if this solved it.
 
changed it to this
Lua:
local food =
{
	[2362] = {80, "Crunch."},
	[2666] = {150, "Munch."},
	[2667] = {120, "Munch."},
	[2668] = {100, "Mmmm."},
	[2669] = {170, "Munch."},
	[2670] = {40, "Gulp."},
	[2671] = {300, "Chomp."},
	[2672] = {600, "Chomp."},
	[2673] = {50, "Yum."},
	[2674] = {60, "Yum."},
	[2675] = {130, "Yum."},
	[2676] = {80, "Yum."},
	[2677] = {10, "Yum."},
	[2678] = {180, "Slurp."},
	[2679] = {10, "Yum."},
	[2680] = {20, "Yum."},
	[2681] = {90, "Yum."},
	[2682] = {200, "Yum."},
	[2683] = {170, "Munch."},
	[2684] = {80, "Crunch."},
	[2685] = {60, "Munch."},
	[2686] = {90, "Crunch."},
	[2687] = {20, "Crunch."},
	[2688] = {90, "Munch."},
	[2689] = {100, "Crunch."},
	[2690] = {30, "Crunch."},
	[2691] = {80, "Crunch."},
	[2792] = {60, "Munch."},
	[2793] = {90, "Munch."},
	[2695] = {60, "Gulp."},
	[2696] = {90, "Smack."},
	[2787] = {90, "Munch."},
	[2788] = {40, "Munch."},
	[2789] = {22, "Munch."},
	[2790] = {30, "Munch."},
	[2791] = {30, "Munch."},
	[2792] = {60, "Munch."},
	[2794] = {30, "Munch."},
	[2795] = {360, "Munch."},
	[2796] = {50, "Munch."},
	[2793] = {90, "Munch."},
	[5097] = {40, "Yum."},
	[6125] = {80, "Gulp."},
	[6278] = {100, "Mmmm."},
	[6279] = {150, "Mmmm."},
	[6393] = {120, "Mmmm."},
	[6394] = {150, "Mmmm."},
	[6501] = {200, "Mmmm."},
	[6541] = {60, "Gulp."},
	[6542] = {60, "Gulp."},
	[6543] = {60, "Gulp."},
	[6544] = {60, "Gulp."},
	[6545] = {60, "Gulp."},
	[6569] = {10, "Mmmm."},
	[6574] = {40, "Mmmm."},
	[7158] = {150, "Munch."},
	[7159] = {130, "Munch."},
	[7372] = {70, "Yum."},
	[7373] = {70, "Yum."},
	[7374] = {70, "Yum."},
	[7375] = {70, "Yum."},
	[7376] = {70, "Yum."},
	[7377] = {70, "Yum."}
}
function onUse(cid, item, frompos, item2, topos)
	if(food[item.itemid] ~= nil) then
		if (getPlayerFood(cid) + food[item.itemid][1]) >= 4000 then
			doPlayerSendCancel(cid, "You are full.")
		else
			doPlayerFeed(cid, food[item.itemid][1] * 4)
			doCreatureSay(cid, food[item.itemid][2], TALKTYPE_ORANGE_1)
			doRemoveItem(item.uid, 1)
		end
		return TRUE
	end
	return FALSE
end
seems like i have to eat even more often, like all the time .. :(
 
No, you changed it so the player can eat more until he is full, so when he is full it lasts longer.

You can change:
Lua:
doPlayerFeed(cid, food[item.itemid][1] * 4)
to a static value like this:
Lua:
doPlayerFeed(cid, 1000)
 
Lua:
local foods = {
    [2362] = {5, "Crunch."}, -- carrot
    [2666] = {15, "Munch."}, -- meat
    [2667] = {12, "Munch."}, -- fish
    [2668] = {10, "Mmmm."}, -- salmon
    [2669] = {17, "Munch."}, -- northern pike
    [2670] = {4, "Gulp."}, -- shrimp
    [2671] = {30, "Chomp."}, -- ham
    [2672] = {60, "Chomp."}, -- dragon ham
    [2673] = {5, "Yum."}, -- pear
    [2674] = {6, "Yum."}, -- red apple
    [2675] = {13, "Yum."}, -- orange
    [2676] = {8, "Yum."}, -- banana
    [2677] = {1, "Yum."}, -- blueberry
    [2678] = {18, "Slurp."}, -- coconut
    [2679] = {1, "Yum."}, -- cherry
    [2680] = {2, "Yum."}, -- strawberry
    [2681] = {9, "Yum."}, -- grapes
    [2682] = {20, "Yum."}, -- melon
    [2683] = {17, "Munch."}, -- pumpkin
    [2684] = {5, "Crunch."}, -- carrot
    [2685] = {6, "Munch."}, -- tomato
    [2686] = {9, "Crunch."}, -- corncob
    [2687] = {2, "Crunch."}, -- cookie
    [2688] = {2, "Munch."}, -- candy cane
    [2689] = {10, "Crunch."}, -- bread
    [2690] = {3, "Crunch."}, -- roll
    [2691] = {8, "Crunch."}, -- brown bread
    [2695] = {6, "Gulp."}, -- egg
    [2696] = {9, "Smack."}, -- cheese
    [2787] = {9, "Munch."}, -- white mushroom
    [2788] = {4, "Munch."}, -- red mushroom
    [2789] = {22, "Munch."}, -- brown mushroom
    [2790] = {30, "Munch."}, -- orange mushroom
    [2791] = {9, "Munch."}, -- wood mushroom
    [2792] = {6, "Munch."}, -- dark mushroom
    [2793] = {12, "Munch."}, -- some mushrooms
    [2794] = {3, "Munch."}, -- some mushrooms
    [2795] = {36, "Munch."}, -- fire mushroom
    [2796] = {5, "Munch."}, -- green mushroom
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    
    local food = foods[item.itemid]
    if not food then
        return false
    end

    local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
    if condition and math.floor(condition:getTicks() / 1000 + (food[1] * 12)) >= 1200 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are full.")
        player:addMana(math.random(food[1],food[1]*2))
        player:addHealth(math.random(food[1],food[1]*2))
        player:say(food[2], TALKTYPE_MONSTER_SAY)
        item:remove(1)
    else
        player:feed(food[1] * 12)
        player:say(food[2], TALKTYPE_MONSTER_SAY)
        item:remove(1)
    end
    
    if item.itemid == 2681 then
        local exp = math.random(1, 50)
        player:addExperience(exp, true)
        --player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained " .. exp .. " experience from eating.")
    end
    
    if item.itemid == 2689 then
        local exp = math.random(1, 100)
        player:addExperience(exp, true)
        --player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained " .. exp .. " experience from eating.")
    end
    -- EGG HEALTH
    if item.itemid == 2695 then
        local exp = math.random(1, 120)
        player:addExperience(exp, true)
        player:addHealth(math.random(food[1],food[1]*3))
        if exp >= 100 then
        Game.createMonster("Chicken", toPosition)
        Game.createMonster("Chicken", toPosition)
        Game.createMonster("Chicken", toPosition)
        elseif exp >= 90 then
        Game.createMonster("Chicken", toPosition)
        Game.createMonster("Chicken", toPosition)
        elseif exp >= 70 then
        Game.createMonster("Chicken", toPosition)
        end
        --player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained " .. exp .. " experience from eating.")
    end
    
    if item.itemid == 2670 then
        local exp = math.random(1, 30)

        player:addExperience(exp, true)
        --player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained " .. exp .. " experience from eating.")
    end
    
    if item.itemid == 2669 then
        local exp = math.random(1, 120)
        player:addExperience(exp, true)
        player:addMana(math.random(food[1],food[1]*2))
        --player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained " .. exp .. " experience from eating.")
    end
    
    if item.itemid == 2667 then
        local exp = math.random(1, 60)
        player:addExperience(exp, true)
            return true
        
        --player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained " .. exp .. " experience from eating.")
    end
    
    
    if item.itemid == 2682 then

        local exp = math.random(1, 20)
        player:addExperience(exp, true)
            return true
        
        --player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained " .. exp .. " experience from eating.")
    end
    
    -- Add a unique storage to keep track of successful uses of the item
        local USES_STORAGE = 2689
        local uses = player:getStorageValue(USES_STORAGE) + 1
        player:setStorageValue(USES_STORAGE, uses)

        -- Check if the player has used the item 100 times, and reward them with random exp if true
        if uses % 2000 == 0 then
            local reward = math.random(1000, 2000)
            --player:setStorageValue(55656, player:getStorageValue(55656) + 1)
            player:addExperience(reward, true)
            --player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained " .. reward .. " experience from eating!")
            player:setStorageValue(USES_STORAGE, 0)
            player:getPosition():sendMagicEffect(28)
        end
    
    
    return true
end

FOOD+.lua
 
-- EGG HEALTH
if item.itemid == 2695 then
local exp = math.random(1, 120)
player:addExperience(exp, true)
player:addHealth(math.random(food[1],food[1]*3))
if exp >= 100 then
Game.createMonster("Chicken", toPosition)
Game.createMonster("Chicken", toPosition)
Game.createMonster("Chicken", toPosition)
elseif exp >= 90 then
Game.createMonster("Chicken", toPosition)
Game.createMonster("Chicken", toPosition)
elseif exp >= 70 then
Game.createMonster("Chicken", toPosition)
end
--player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained " .. exp .. " experience from eating.")
end
Not sure if you wrote this or not. If so, I have a few questions:

1. Why? Is this something in real tibia?
2. Please learn to tab your code correctly. Most IDE's will even do it for you if you are unable to figure it out.
3. Why are you "correcting" 11 year old thread/code?
 
Not sure if you wrote this or not. If so, I have a few questions:

1. Why? Is this something in real tibia?
2. Please learn to tab your code correctly. Most IDE's will even do it for you if you are unable to figure it out.
3. Why are you "correcting" 11 year old thread/code?
I currently cant post scripts in resources ? and i found this by accident so i figured why not put it here i mean if someone will look for food script google will lead here.
2. If your IDE can do it for you then go on I do not need your tabs and spaces
 
Back
Top