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

How can I create an infinite food?

Jpstafe

Well-Known Member
Joined
Aug 8, 2011
Messages
507
Reaction score
68
Hello Otland community, I wanted to know how can I create a food inifity to put in the shop,
I'm using tfs 1.2
in:data\actions\scripts\Other\food
Lua:
local foods = {
    [2695] = {6, 'Gulp.'}, -- egg
    [2362] = {5, 'Crunch.'}, -- carrot
    [2666] = {15, 'Munch.'}, -- meat
    [23516] = {15, 'Burp.'}, -- Bottle of Glooth Wine
    [23515] = {15, 'Slurp.'}, -- Bowl of Glooth Soup
    [23514] = {10, 'Munch.'}, -- Bowl of Glooth Soup
    [2667] = {12, 'Munch.'}, -- fish
    [2668] = {10, 'Mmmm.'}, -- salmon
    [26191] = {30, 'Mmmm.'}, -- energy bar
    [26201] = {30, 'Mmmm.'}, -- energy drink
    [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
    [7966] = {9, 'Hum.'}, -- cream cake
    [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
    [9111] = {10, 'Crunch.'}, -- bread
    [2690] = {3, 'Crunch.'}, -- roll
    [2691] = {8, 'Crunch.'}, -- brown bread
    [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
    [5097] = {4, 'Yum.'}, -- mango
    [22644] = {4, 'Mmmm.'}, -- Christmas Cookie Tray
    [6125] = {8, 'Gulp.'}, -- tortoise egg
    [6278] = {10, 'Mmmm.'}, -- cake
    [6279] = {15, 'Mmmm.'}, -- decorated cake
    [6393] = {12, 'Mmmm.'}, -- valentine's cake
    [6394] = {15, 'Mmmm.'}, -- cream cake
    [6501] = {20, 'Mmmm.'}, -- gingerbread man
    [6541] = {6, 'Gulp.'}, -- coloured egg (yellow)
    [6542] = {6, 'Gulp.'}, -- coloured egg (red)
    [6543] = {6, 'Gulp.'}, -- coloured egg (blue)
    [6544] = {6, 'Gulp.'}, -- coloured egg (green)
    [6545] = {6, 'Gulp.'}, -- coloured egg (purple)
    [6569] = {1, 'Mmmm.'}, -- candy
    [6574] = {5, 'Mmmm.'}, -- bar of chocolate
    [7158] = {15, 'Munch.'}, -- rainbow trout
    [7159] = {13, 'Munch.'}, -- green perch
    [7372] = {2, 'Yum.'}, -- ice cream cone (crispy chocolate chips)
    [7373] = {2, 'Yum.'}, -- ice cream cone (velvet vanilla)
    [7374] = {2, 'Yum.'}, -- ice cream cone (sweet strawberry)
    [7375] = {2, 'Yum.'}, -- ice cream cone (chilly cherry)
    [7376] = {2, 'Yum.'}, -- ice cream cone (mellow melon)
    [7377] = {2, 'Yum.'}, -- ice cream cone (blue-barian)
    [7909] = {4, 'Crunch.'}, -- walnut
    [7910] = {4, 'Crunch.'}, -- peanut
    [7963] = {60, 'Munch.'}, -- marlin
    [8112] = {9, 'Urgh.'}, -- scarab cheese
    [8838] = {10, 'Gulp.'}, -- potato
    [8839] = {5, 'Yum.'}, -- plum
    [8840] = {1, 'Yum.'}, -- raspberry
    [8841] = {1, 'Urgh.'}, -- lemon
    [8842] = {7, 'Munch.'}, -- cucumber
    [8843] = {5, 'Crunch.'}, -- onion
    [8844] = {1, 'Gulp.'}, -- jalapeño pepper
    [8845] = {5, 'Munch.'}, -- beetroot
    [8847] = {11, 'Yum.'}, -- chocolate cake
    [9005] = {7, 'Slurp.'}, -- yummy gummy worm
    [9114] = {5, 'Crunch.'}, -- bulb of garlic
    [10454] = {0, 'Your head begins to feel better.'}, -- headache pill
    [11246] = {15, 'Yum.'}, -- rice ball
    [11370] = {3, 'Urgh.'}, -- terramite eggs
    [11429] = {10, 'Mmmm.'}, -- crocodile steak
    [12415] = {20, 'Yum.'}, -- pineapple
    [12416] = {10, 'Munch.'}, -- aubergine
    [12417] = {8, 'Crunch.'}, -- broccoli
    [12418] = {9, 'Crunch.'}, -- cauliflower
    [12637] = {55, 'Gulp.'}, -- ectoplasmic sushi
    [12638] = {18, 'Yum.'}, -- dragonfruit
    [12639] = {2, 'Munch.'}, -- peas
    [13297] = {20, 'Crunch.'}, -- haunch of boar
    [15405] = {55, 'Munch.'}, -- sandfish
    [15487] = {14, 'Urgh.'}, -- larvae
    [15488] = {15, 'Munch.'}, -- deepling filet
    [16014] = {60, 'Mmmm.'}, -- anniversary cake
    [18306] = {0, 'Phew!'}, -- stale mushroom beer
    [18397] = {33, 'Munch.'}, -- mushroom pie
    [19737] = {10, 'Urgh.'}, -- insectoid eggs
    [20100] = {15, 'Smack.'}, -- soft cheese
    [20101] = {12, 'Smack.'}, -- rat cheese
    [23517] = {25, 'Chomp.'}, -- glooth steak
    [24843] = {25, 'Chomp.'}, -- Roasted Meat
    [24841] = {8, 'Yum.'}, -- pickle pear
    [27050] = {20, 'Urgh.'}, -- bug meat
    [27051] = {10, 'Gulp.'}, -- cave turnip
    [27064] = {60, 'Mmmm.'}, -- birthday cake
    [27616] = {10, 'Slurp.'}, -- bottle of tibian wine
    [28997] = {15, 'Mmmmm!'}, -- fresh fruit
    [35057] = {40, 'Mmmmm!'}, -- meringue cake
    [35060] = {15, 'Slurp.'} -- winterberry liquor
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local food = foods[item.itemid]
    if not food then
        return false
    end
    
    if(item.itemid == 9111 and player:getStorageValue(45230) == 1) then
        player:setStorageValue(45230, 2)         
    end
    
    --player:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)

    local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
    if condition and math.floor(condition:getTicks() / 1000 + (food[1] * 24)) >= 2400 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You are full.')
        return true
    end

    player:feed(food[1] * 24)
    player:say(food[2], TALKTYPE_MONSTER_SAY)
    item:remove(1)

    local client = player:getClient()
    if client.version > 1140 then
        player:updateSupplyTracker(item)
    end

    return true
end
You will find a scrip called Infinity
infinity.lua:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local size = 180
   if(getPlayerFood(cid) + size > MAX_FOOD) then
     doPlayerSendCancel(cid, "You are full.")
     return true
   end

   doPlayerFeed(cid, size)

   doCreatureSay(cid, "Hmmm.", TALKTYPE_MONSTER)
   return true
end
To put the Food Infinity, I create it with the item editor, I put it in items.xml, and then how do I add it to the food folder and make it infinite? There in that step I got stuck
 
Solution
Try
Lua:
local foods = {
    [12345] = {10, 'Yum.', infinite = true}, -- If true: dont apply item:remove(1)
    -- Add the rest here
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local food = foods[item.itemid]
    if not food then
        return false
    end
    
    if(item.itemid == 9111 and player:getStorageValue(45230) == 1) then
        player:setStorageValue(45230, 2)         
    end
    
    --player:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)

    local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
    if condition and math.floor(condition:getTicks() / 1000 + (food[1] * 24)) >= 2400 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You are...
Do you want the food script to become infinite? Then just remove this simple line '-'.
I want a new food that I created to be infinite, the others are not...,
When creating the new food I must put it in food.lua right?
Where are these?
" [2695] = {6, 'Gulp.'}, -- egg
[2362] = {5, 'Crunch.'}, -- carrot
[2666] = {15, 'Munch.'}, -- meat"
When I add the new food to the Food.lua list, how can I make this new food infinite?
 
Try
Lua:
local foods = {
    [12345] = {10, 'Yum.', infinite = true}, -- If true: dont apply item:remove(1)
    -- Add the rest here
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local food = foods[item.itemid]
    if not food then
        return false
    end
    
    if(item.itemid == 9111 and player:getStorageValue(45230) == 1) then
        player:setStorageValue(45230, 2)         
    end
    
    --player:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)

    local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
    if condition and math.floor(condition:getTicks() / 1000 + (food[1] * 24)) >= 2400 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You are full.')
        return true
    end

    player:feed(food[1] * 24)
    player:say(food[2], TALKTYPE_MONSTER_SAY)

    if not food.infinite then
        item:remove(1)  -- Remove the item only if it's not marked as infinite
    end

    local client = player:getClient()
    if client.version > 1140 then
        player:updateSupplyTracker(item)
    end

    return true
end
 
Solution
Lua:
local foods = {
    [2695] = {6, 'Gulp.'}, -- egg
    [2362] = {5, 'Crunch.'}, -- carrot
    [2666] = {15, 'Munch.'}, -- meat
    [23516] = {15, 'Burp.'}, -- Bottle of Glooth Wine
    [23515] = {15, 'Slurp.'}, -- Bowl of Glooth Soup
    [23514] = {10, 'Munch.'}, -- Bowl of Glooth Soup
    [2667] = {12, 'Munch.'}, -- fish
    [2668] = {10, 'Mmmm.'}, -- salmon
    [26191] = {30, 'Mmmm.'}, -- energy bar
    [26201] = {30, 'Mmmm.'}, -- energy drink
    [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
    [7966] = {9, 'Hum.'}, -- cream cake
    [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
    [9111] = {10, 'Crunch.'}, -- bread
    [2690] = {3, 'Crunch.'}, -- roll
    [2691] = {8, 'Crunch.'}, -- brown bread
    [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
    [5097] = {4, 'Yum.'}, -- mango
    [22644] = {4, 'Mmmm.'}, -- Christmas Cookie Tray
    [6125] = {8, 'Gulp.'}, -- tortoise egg
    [6278] = {10, 'Mmmm.'}, -- cake
    [6279] = {15, 'Mmmm.'}, -- decorated cake
    [6393] = {12, 'Mmmm.'}, -- valentine's cake
    [6394] = {15, 'Mmmm.'}, -- cream cake
    [6501] = {20, 'Mmmm.'}, -- gingerbread man
    [6541] = {6, 'Gulp.'}, -- coloured egg (yellow)
    [6542] = {6, 'Gulp.'}, -- coloured egg (red)
    [6543] = {6, 'Gulp.'}, -- coloured egg (blue)
    [6544] = {6, 'Gulp.'}, -- coloured egg (green)
    [6545] = {6, 'Gulp.'}, -- coloured egg (purple)
    [6569] = {1, 'Mmmm.'}, -- candy
    [6574] = {5, 'Mmmm.'}, -- bar of chocolate
    [7158] = {15, 'Munch.'}, -- rainbow trout
    [7159] = {13, 'Munch.'}, -- green perch
    [7372] = {2, 'Yum.'}, -- ice cream cone (crispy chocolate chips)
    [7373] = {2, 'Yum.'}, -- ice cream cone (velvet vanilla)
    [7374] = {2, 'Yum.'}, -- ice cream cone (sweet strawberry)
    [7375] = {2, 'Yum.'}, -- ice cream cone (chilly cherry)
    [7376] = {2, 'Yum.'}, -- ice cream cone (mellow melon)
    [7377] = {2, 'Yum.'}, -- ice cream cone (blue-barian)
    [7909] = {4, 'Crunch.'}, -- walnut
    [7910] = {4, 'Crunch.'}, -- peanut
    [7963] = {60, 'Munch.'}, -- marlin
    [8112] = {9, 'Urgh.'}, -- scarab cheese
    [8838] = {10, 'Gulp.'}, -- potato
    [8839] = {5, 'Yum.'}, -- plum
    [8840] = {1, 'Yum.'}, -- raspberry
    [8841] = {1, 'Urgh.'}, -- lemon
    [8842] = {7, 'Munch.'}, -- cucumber
    [8843] = {5, 'Crunch.'}, -- onion
    [8844] = {1, 'Gulp.'}, -- jalapeño pepper
    [8845] = {5, 'Munch.'}, -- beetroot
    [8847] = {11, 'Yum.'}, -- chocolate cake
    [9005] = {7, 'Slurp.'}, -- yummy gummy worm
    [9114] = {5, 'Crunch.'}, -- bulb of garlic
    [10454] = {0, 'Your head begins to feel better.'}, -- headache pill
    [11246] = {15, 'Yum.'}, -- rice ball
    [11370] = {3, 'Urgh.'}, -- terramite eggs
    [11429] = {10, 'Mmmm.'}, -- crocodile steak
    [12415] = {20, 'Yum.'}, -- pineapple
    [12416] = {10, 'Munch.'}, -- aubergine
    [12417] = {8, 'Crunch.'}, -- broccoli
    [12418] = {9, 'Crunch.'}, -- cauliflower
    [12637] = {55, 'Gulp.'}, -- ectoplasmic sushi
    [12638] = {18, 'Yum.'}, -- dragonfruit
    [12639] = {2, 'Munch.'}, -- peas
    [13297] = {20, 'Crunch.'}, -- haunch of boar
    [15405] = {55, 'Munch.'}, -- sandfish
    [15487] = {14, 'Urgh.'}, -- larvae
    [15488] = {15, 'Munch.'}, -- deepling filet
    [16014] = {60, 'Mmmm.'}, -- anniversary cake
    [18306] = {0, 'Phew!'}, -- stale mushroom beer
    [18397] = {33, 'Munch.'}, -- mushroom pie
    [19737] = {10, 'Urgh.'}, -- insectoid eggs
    [20100] = {15, 'Smack.'}, -- soft cheese
    [20101] = {12, 'Smack.'}, -- rat cheese
    [23517] = {25, 'Chomp.'}, -- glooth steak
    [24843] = {25, 'Chomp.'}, -- Roasted Meat
    [24841] = {8, 'Yum.'}, -- pickle pear
    [27050] = {20, 'Urgh.'}, -- bug meat
    [27051] = {10, 'Gulp.'}, -- cave turnip
    [27064] = {60, 'Mmmm.'}, -- birthday cake
    [27616] = {10, 'Slurp.'}, -- bottle of tibian wine
    [28997] = {15, 'Mmmmm!'}, -- fresh fruit
    [35057] = {40, 'Mmmmm!'}, -- meringue cake
    [35060] = {15, 'Slurp.'} -- winterberry liquor
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local food = foods[item.itemid]
    if not food then
        return false
    end
   
    if(item.itemid == 9111 and player:getStorageValue(45230) == 1) then
        player:setStorageValue(45230, 2)        
    end
   
    --player:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)

    local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
    if condition and math.floor(condition:getTicks() / 1000 + (food[1] * 24)) >= 2400 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You are full.')
        return true
    end

    player:feed(food[1] * 24)
    player:say(food[2], TALKTYPE_MONSTER_SAY)
 
--infinite fish
    if item.itemid ~= 2667 then
         item:remove(1)        
    end

    local client = player:getClient()
    if client.version > 1140 then
        player:updateSupplyTracker(item)
    end

    return true
end
try this - not tested
 
Last edited:
I misread it. Sometimes, Google Translate translates very poorly, and I misunderstood it. I went back and re-read the post. Now I understand that you want to create a new script called 'nfinity.lua'. So, I took it and did some simple adaptations. See if it works or not.

infinity.lua
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local size = 180

    local player = Player(cid)
    if not player then
        return false
    end

    local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
    if condition and math.floor(condition:getTicks() / 1000 + (size * 12)) >= 1200 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are full.")
        return true
    end

    player:feed(size)
    player:say("Hmmm.", TALKTYPE_MONSTER)
    item:remove(1)

    return true
end

Study a bit about the functions for TFS 1.x. Do you know where you can find information about using the functions of TFS 1.x? Just go to the server, then to data/lib/compat/compat.lua and open it to see. It will provide better explanations and understanding. Afterwards, you can try creating a script. Start with something small and simple, then you can quickly progress. I hope this helps.
 
Lua:
local foods = {
    [2695] = {6, 'Gulp.'}, -- egg
    [2362] = {5, 'Crunch.'}, -- carrot
    [2666] = {15, 'Munch.'}, -- meat
    [23516] = {15, 'Burp.'}, -- Bottle of Glooth Wine
    [23515] = {15, 'Slurp.'}, -- Bowl of Glooth Soup
    [23514] = {10, 'Munch.'}, -- Bowl of Glooth Soup
    [2667] = {12, 'Munch.'}, -- fish
    [2668] = {10, 'Mmmm.'}, -- salmon
    [26191] = {30, 'Mmmm.'}, -- energy bar
    [26201] = {30, 'Mmmm.'}, -- energy drink
    [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
    [7966] = {9, 'Hum.'}, -- cream cake
    [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
    [9111] = {10, 'Crunch.'}, -- bread
    [2690] = {3, 'Crunch.'}, -- roll
    [2691] = {8, 'Crunch.'}, -- brown bread
    [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
    [5097] = {4, 'Yum.'}, -- mango
    [22644] = {4, 'Mmmm.'}, -- Christmas Cookie Tray
    [6125] = {8, 'Gulp.'}, -- tortoise egg
    [6278] = {10, 'Mmmm.'}, -- cake
    [6279] = {15, 'Mmmm.'}, -- decorated cake
    [6393] = {12, 'Mmmm.'}, -- valentine's cake
    [6394] = {15, 'Mmmm.'}, -- cream cake
    [6501] = {20, 'Mmmm.'}, -- gingerbread man
    [6541] = {6, 'Gulp.'}, -- coloured egg (yellow)
    [6542] = {6, 'Gulp.'}, -- coloured egg (red)
    [6543] = {6, 'Gulp.'}, -- coloured egg (blue)
    [6544] = {6, 'Gulp.'}, -- coloured egg (green)
    [6545] = {6, 'Gulp.'}, -- coloured egg (purple)
    [6569] = {1, 'Mmmm.'}, -- candy
    [6574] = {5, 'Mmmm.'}, -- bar of chocolate
    [7158] = {15, 'Munch.'}, -- rainbow trout
    [7159] = {13, 'Munch.'}, -- green perch
    [7372] = {2, 'Yum.'}, -- ice cream cone (crispy chocolate chips)
    [7373] = {2, 'Yum.'}, -- ice cream cone (velvet vanilla)
    [7374] = {2, 'Yum.'}, -- ice cream cone (sweet strawberry)
    [7375] = {2, 'Yum.'}, -- ice cream cone (chilly cherry)
    [7376] = {2, 'Yum.'}, -- ice cream cone (mellow melon)
    [7377] = {2, 'Yum.'}, -- ice cream cone (blue-barian)
    [7909] = {4, 'Crunch.'}, -- walnut
    [7910] = {4, 'Crunch.'}, -- peanut
    [7963] = {60, 'Munch.'}, -- marlin
    [8112] = {9, 'Urgh.'}, -- scarab cheese
    [8838] = {10, 'Gulp.'}, -- potato
    [8839] = {5, 'Yum.'}, -- plum
    [8840] = {1, 'Yum.'}, -- raspberry
    [8841] = {1, 'Urgh.'}, -- lemon
    [8842] = {7, 'Munch.'}, -- cucumber
    [8843] = {5, 'Crunch.'}, -- onion
    [8844] = {1, 'Gulp.'}, -- jalapeño pepper
    [8845] = {5, 'Munch.'}, -- beetroot
    [8847] = {11, 'Yum.'}, -- chocolate cake
    [9005] = {7, 'Slurp.'}, -- yummy gummy worm
    [9114] = {5, 'Crunch.'}, -- bulb of garlic
    [10454] = {0, 'Your head begins to feel better.'}, -- headache pill
    [11246] = {15, 'Yum.'}, -- rice ball
    [11370] = {3, 'Urgh.'}, -- terramite eggs
    [11429] = {10, 'Mmmm.'}, -- crocodile steak
    [12415] = {20, 'Yum.'}, -- pineapple
    [12416] = {10, 'Munch.'}, -- aubergine
    [12417] = {8, 'Crunch.'}, -- broccoli
    [12418] = {9, 'Crunch.'}, -- cauliflower
    [12637] = {55, 'Gulp.'}, -- ectoplasmic sushi
    [12638] = {18, 'Yum.'}, -- dragonfruit
    [12639] = {2, 'Munch.'}, -- peas
    [13297] = {20, 'Crunch.'}, -- haunch of boar
    [15405] = {55, 'Munch.'}, -- sandfish
    [15487] = {14, 'Urgh.'}, -- larvae
    [15488] = {15, 'Munch.'}, -- deepling filet
    [16014] = {60, 'Mmmm.'}, -- anniversary cake
    [18306] = {0, 'Phew!'}, -- stale mushroom beer
    [18397] = {33, 'Munch.'}, -- mushroom pie
    [19737] = {10, 'Urgh.'}, -- insectoid eggs
    [20100] = {15, 'Smack.'}, -- soft cheese
    [20101] = {12, 'Smack.'}, -- rat cheese
    [23517] = {25, 'Chomp.'}, -- glooth steak
    [24843] = {25, 'Chomp.'}, -- Roasted Meat
    [24841] = {8, 'Yum.'}, -- pickle pear
    [27050] = {20, 'Urgh.'}, -- bug meat
    [27051] = {10, 'Gulp.'}, -- cave turnip
    [27064] = {60, 'Mmmm.'}, -- birthday cake
    [27616] = {10, 'Slurp.'}, -- bottle of tibian wine
    [28997] = {15, 'Mmmmm!'}, -- fresh fruit
    [35057] = {40, 'Mmmmm!'}, -- meringue cake
    [35060] = {15, 'Slurp.'} -- winterberry liquor
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local food = foods[item.itemid]
    if not food then
        return false
    end
  
    if(item.itemid == 9111 and player:getStorageValue(45230) == 1) then
        player:setStorageValue(45230, 2)       
    end
  
    --player:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)

    local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
    if condition and math.floor(condition:getTicks() / 1000 + (food[1] * 24)) >= 2400 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You are full.')
        return true
    end

    player:feed(food[1] * 24)
    player:say(food[2], TALKTYPE_MONSTER_SAY)
 
--infinite fish
    if item.itemid ~= 2667 then
         item:remove(1)       
    end

    local client = player:getClient()
    if client.version > 1140 then
        player:updateSupplyTracker(item)
    end

    return true
end
try this - not tested
I copied the part of the Infinity Food, in the food.lua, but when I use it it is spent. In item:remove(1), I put it like this: 'item:remove(1)' and it gives me an error on the console.
[Warning - Event::checkScript] Can not load script: scripts/Other/food/food.lua
data/actions/scripts/Other/food/food.lua:143: unexpected symbol near ''item:remove(1)''
Post automatically merged:

Try
Lua:
local foods = {
    [12345] = {10, 'Yum.', infinite = true}, -- If true: dont apply item:remove(1)
    -- Add the rest here
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local food = foods[item.itemid]
    if not food then
        return false
    end
   
    if(item.itemid == 9111 and player:getStorageValue(45230) == 1) then
        player:setStorageValue(45230, 2)        
    end
   
    --player:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)

    local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
    if condition and math.floor(condition:getTicks() / 1000 + (food[1] * 24)) >= 2400 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You are full.')
        return true
    end

    player:feed(food[1] * 24)
    player:say(food[2], TALKTYPE_MONSTER_SAY)

    if not food.infinite then
        item:remove(1)  -- Remove the item only if it's not marked as infinite
    end

    local client = player:getClient()
    if client.version > 1140 then
        player:updateSupplyTracker(item)
    end

    return true
end
In the food folder, I created another food, and put this script,
actions\scripts\Other\food\infinityfood.lua
I've created the new article, which is a red fish,
XML:
<item id="7555" name="infinity food">
        <attribute key="weight" value="1300" />
        <attribute key="showcount" value="0" />
    </item>
In action I've also put it
XML:
<action fromid="7555" script="Other/food/infinityfood.lua" />
But when I open the server I get this error.
[Warning - Actions::registerEvent] Missing toid in fromid: 7555
Post automatically merged:

Try
Lua:
local foods = {
    [12345] = {10, 'Yum.', infinite = true}, -- If true: dont apply item:remove(1)
    -- Add the rest here
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local food = foods[item.itemid]
    if not food then
        return false
    end
   
    if(item.itemid == 9111 and player:getStorageValue(45230) == 1) then
        player:setStorageValue(45230, 2)        
    end
   
    --player:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)

    local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
    if condition and math.floor(condition:getTicks() / 1000 + (food[1] * 24)) >= 2400 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You are full.')
        return true
    end

    player:feed(food[1] * 24)
    player:say(food[2], TALKTYPE_MONSTER_SAY)

    if not food.infinite then
        item:remove(1)  -- Remove the item only if it's not marked as infinite
    end

    local client = player:getClient()
    if client.version > 1140 then
        player:updateSupplyTracker(item)
    end

    return true
end
In the food folder, I created another food, and put this script,
actions\scripts\Other\food\infinityfood.lua
I've created the new article, which is a red fish,
XML:
XML:
<item id="7555" name="infinity food">
        <attribute key="weight" value="1300" />
        <attribute key="showcount" value="0" />
    </item>
In action I've also put it
XML:
<action fromid="7555" script="Other/food/infinityfood.lua" />
But when I open the server I get this error.
[Warning - Actions::registerEvent] Missing toid in fromid: 7555
 
Last edited:
I copied the part of the Infinity Food, in the food.lua, but when I use it it is spent. In item:remove(1), I put it like this: 'item:remove(1)' and it gives me an error on the console.
[Warning - Event::checkScript] Can not load script: scripts/Other/food/food.lua
data/actions/scripts/Other/food/food.lua:143: unexpected symbol near ''item:remove(1)''
Post automatically merged:


In the food folder, I created another food, and put this script,
actions\scripts\Other\food\infinityfood.lua
I've created the new article, which is a red fish,
XML:
<item id="7555" name="infinity food">
        <attribute key="weight" value="1300" />
        <attribute key="showcount" value="0" />
    </item>
In action I've also put it
XML:
<action fromid="7555" script="Other/food/infinityfood.lua" />
But when I open the server I get this error.
[Warning - Actions::registerEvent] Missing toid in fromid: 7555
Post automatically merged:


In the food folder, I created another food, and put this script,
actions\scripts\Other\food\infinityfood.lua
I've created the new article, which is a red fish,
XML:
XML:
<item id="7555" name="infinity food">
        <attribute key="weight" value="1300" />
        <attribute key="showcount" value="0" />
    </item>
In action I've also put it
XML:
<action fromid="7555" script="Other/food/infinityfood.lua" />
But when I open the server I get this error.
[Warning - Actions::registerEvent] Missing toid in fromid: 7555

The error message indicates that there is a missing configuration in your action.xml. Specifically, it's complaining about a missing toid attribute in the <action> tag. So instead of declearing fromid, use.
Lua:
<action itemid="7555" script="Other/food/infinityfood.lua" />
 
The error message indicates that there is a missing configuration in your action.xml. Specifically, it's complaining about a missing toid attribute in the <action> tag. So instead of declearing fromid, use.
Lua:
<action itemid="7555" script="Other/food/infinityfood.lua" />
there it was solved, it works perfect
 
Back
Top