• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action A few food scripts

Animera

* * * * *
Joined
Dec 9, 2008
Messages
2,441
Solutions
5
Reaction score
612
Location
ANIMERA.ONLINE
Info:
I use these scripts in my server but because this is easy to create i decided to create it
so that people without scripting skills can use it.
I use this script it is bugfree on (the forgotten server 0.3.6 pl1/ 8.54).
So i am not sure this works on other distro's.

Mango tree:
Using the tree gives 2 to 5 mangos.
food3.png

Items.xml
Code:
<item id="5157" article="a" name="mango tree"/>
And
Code:
<item id="5156" article="a" name="empty mango tree">
	<attribute key="decayTo" value="5157" />
	<attribute key="duration" value="86400000"/>	
</item>
The fruit is growing on the tree every 24 hours in real life.

Actions.xml
Code:
<action itemid="5157" event="script" value="other/mangotree.lua"/>

Mangotree.lua
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	doPlayerAddItem(cid, 5097, math.random(2, 5), fromPosition)
	doTransformItem(item.uid, 5156)
	doDecayItem(item.uid)
	return true
end

Orange Tree:
Using the tree gives 2 to 5 Oranges.
Food4.png

Items.xml
Code:
<item id="4006" article="an" name="orange tree" />
And
Code:
<item id="4008" article="a" name="empty orange tree">
        <attribute key="decayTo" value="5157" />
	<attribute key="duration" value="86400000"/>
</item>

Actions.xml

Code:
<action itemid="4006" event="script" value="other/orangetree.lua"/>

Orangetree.lua
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	doPlayerAddItem(cid, 2675, math.random(2, 5), fromPosition)
	doTransformItem(item.uid, 4008)
	doDecayItem(item.uid)
	return true
end

Food
Food wich gives instantly health and mana depends on how rare it is or how much it fills.
Here are 2 samples:

A simple apple.
food1.png


A rare cake (+5k hp +5k M)

Food2.png


Food.lua (With a small bugfix thanks to cykotitan)
PHP:
local FOODS =
{
	[2362] = {8, "Crunch.", {10, 25}, {25, 50}}, -- Carrots of doom
	[2666] = {15, "Munch.", {5, 20}, {3, 10}}, -- Meat
	[2667] = {12, "Munch.", {5, 25}, {5, 15}}, -- Fish
	[2668] = {10, "Mmmm.", {3, 13}, {1, 9}}, -- Salmon
	[2669] = {17, "Munch.", {10, 45}, {15, 50}}, -- Northern pikes (big fish)
	[2670] = {4, "Gulp.", {1, 10}, {1, 10}}, -- Shrimps
	[2671] = {30, "Chomp.", {20, 60}, {25, 45}}, -- Ham
	[2672] = {60, "Chomp.", {30, 75}, {25, 65}}, -- Dragon ham
	[2673] = {5, "Yum.", {1, 15}, {5, 35}}, -- Pears
	[2674] = {6, "Yum.", {1, 10}, {10, 35}}, -- Red apple
	[2675] = {13, "Yum.", {1, 7}, {15, 40}}, -- Orange
	[2676] = {8, "Yum.", {5, 20}, {15, 30}}, -- Banana
	[2677] = {1, "Yum.", {1, 5}, {1, 5}}, -- Blueberry
	[2678] = {18, "Slurp.", {15, 50}, {30, 55}}, -- Coconut
	[2679] = {1, "Yum.", {1, 7}, {1, 7}}, -- Cherry
	[2680] = {2, "Yum.", {1, 10}, {2, 18}}, -- Strawberry
	[2681] = {9, "Yum.", {10, 35}, {25, 25}}, -- Grapes
	[2682] = {20, "Yum.", {20, 55}, {20, 55}}, -- Melon
	[2683] = {17, "Munch.", {15, 50}, {15, 50}}, -- Pumpkin
	[2684] = {8, "Crunch.", {10, 20}, {25, 45}}, -- Carrots
	[2685] = {6, "Munch.", {5, 15}, {5, 10}}, -- Tomato
	[2686] = {9, "Crunch.", {1, 15}, {1, 8}}, -- Corncobs
	[2687] = {2, "Crunch.", {1, 3}, {1, 2}}, -- Cookies
	[2688] = {9, "Munch.", {1, 5}, {1, 5}}, -- Candy canes
	[2689] = {10, "Crunch.", {1, 15}, {5, 15}}, -- Bread
	[2690] = {3, "Crunch.", {5, 20}, {5, 15}}, -- Rolls
	[2691] = {8, "Crunch.", {10, 25}, {10, 15}}, -- Brown bread
	[2792] = {6, "Munch.", {5, 15}, {5, 10}}, -- Dark mushrooms
	[2793] = {9, "Munch.", {10, 30}, {15, 25}}, -- Mushrooms
	[2695] = {6, "Gulp.", {10, 40}, {10, 40}}, -- Eggs
	[2696] = {9, "Smack.", {10, 30}, {10, 25}}, -- Cheese
	[2787] = {9, "Munch.", {10, 35}, {15, 30}}, -- White mushrooms
	[2788] = {4, "Munch.", {10, 35}, {15, 50}}, -- Red mushrooms
	[2789] = {22, "Munch.", {15, 55}, {15, 55}}, -- Brown mushrooms
	[2790] = {30, "Munch.", {10, 35}, {15, 35}}, -- Orange mushrooms
	[2791] = {30, "Munch.", {15, 35}, {15, 35}}, -- Wood mushrooms
	[2794] = {3, "Munch.", {15, 35}, {15, 35}}, -- Mushrooms
	[2795] = {36, "Munch.", {75, 150}, {80, 150}}, -- Fire mushrooms
	[2796] = {5, "Munch.", {30, 125}, {40, 120}}, -- Green mushrooms
	[5097] = {4, "Yum.", {10, 35}, {15, 35}}, -- Mango
	[6125] = {8, "Gulp.", {15, 35}, {25, 30}}, -- Tortoise egg
	[6278] = {10, "Mmmm.", {10, 20}, {15, 25}}, -- Cake
	[6279] = {15, "Mmmm.", {7, 20}, {10, 25}}, -- Decorated cake
	[6393] = {50, "The power of love!", {5000, 5000}, {5000, 5000}}, -- Valentine cake
	[6394] = {15, "Mmmm.", {15, 25}, {15, 25}}, -- Cream cake
	[6501] = {20, "Mmmm.", {10, 20}, {25, 40}}, -- gingerbread man
	[6541] = {6, "Gulp.", {10, 25}, {15, 25}}, -- Yellow eggs
	[6542] = {6, "Gulp.", {10, 25}, {15, 25}}, -- Red eggs
	[6543] = {6, "Gulp.", {10, 25}, {15, 25}}, -- Blue eggs
	[6544] = {6, "Gulp.", {10, 25}, {15, 25}}, -- Green eggs
	[6545] = {6, "Gulp.", {10, 25}, {15, 25}}, -- Purple eggs
	[6569] = {1, "Mmmm.", {5, 15}, {5, 15}}, -- Candy
	[6574] = {4, "Mmmm.", {10, 20}, {5, 20}}, -- Chocolate
	[7158] = {15, "Munch.", {55, 100}, {45, 105}}, -- Rainbow trouts (Fish)
	[7159] = {13, "Munch.", {40, 75}, {35, 80}}, -- Green perches (Fish)
	[7372] = {7, "Yum.", {25, 35}, {25, 50}}, -- Ice cream cone
	[7373] = {7, "Yum.", {15, 25}, {25, 50}}, -- Yellow ice
	[7374] = {7, "Yum.", {15, 25}, {25, 50}}, -- Red ice
	[7375] = {7, "Yum.", {15, 25}, {25, 50}}, -- Purple ice
	[7376] = {7, "Yum.", {15, 25}, {25, 50}}, -- Green ice
	[7377] = {7, "Yum.", {15, 25}, {25, 50}}, -- Blue ice
	[8838] = {7, "Gulp.", {15, 30}, {25, 30}}, -- Potato
	[8839] = {5, "Yum.", {10, 25}, {15, 25}}, -- Plum
	[8840] = {2, "Yum.", {5, 15}, {5, 10}}, -- Raspberry
	[8841] = {3, "Urgh.", {1, 20}, {5, 30}}, -- Lemon
	[8842] = {5, "Munch.", {5, 25}, {5, 25}}, -- Cucumber
	[8843] = {3, "Crunch.", {1, 20}, {5, 20}}, -- Onion
	[8844] = {3, "Gulp.", {25, 60}, {35, 70}}, -- Jalapeno peper
	[8845] = {2, "Munch.", {10, 25}, {5, 20}}, -- Beetroot
	[8847] = {11, "Yum.", {10, 25}, {20, 30}}, -- Chocolate cake
	[7910] = {4, "Crunch.", {15, 25}, {25, 30}}, -- Peanut
	[7909] = {4, "Crunch.", {15, 25}, {25, 30}}, -- Walnut
}
 
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)
	doCreatureAddHealth(cid, math.random(food[3][1], food[3][2]))
	doPlayerAddMana(cid, math.random(food[4][1], food[4][2]))
	return true
end
 
Last edited:
Talkaction makes you hungry

why a hungry spell?
I don't know, When i made the food scripts it had a few bugs, but everytime i edit it i try to test it, But sometimes i was full without this script i had to wait everytime until i can eat again.

Hungry.lua
PHP:
function onSay(cid, words, param, channel)
doPlayerFeed(cid, -1200)
doCreatureSay(cid, "I am hungry again!", TALKTYPE_ORANGE_1)
doSendMagicEffect(getThingPos(cid), CONST_ME_LOSEENERGY)
return TRUE
end

Code:
	<talkaction log="yes" words="/hungry" access="5" event="script" value="hungry.lua"/>


Nothing special consider this as a bump ^_^
 
PHP:
local FOODS =
{
	[2362] = {8, "Crunch.", math.random(10, 25), math.random(25, 50)}, -- Carrots of doom
	[2666] = {15, "Munch.", math.random(5, 20), math.random(3, 10)}, -- Meat
	[2667] = {12, "Munch.", math.random(5, 25), math.random(5, 15)}, -- Fish
The bad thing is that it will only be randomized once (while loading/reloading actions), not every time player uses it :p
 
strange o.O mine does always randomize however can you fix it? if it didn't work for you then i don't either think it work for others too then.

EDIT:
Wich distro you use? I use tfs crying damson 0.3.6pl1
 
TFS 0.3.6pl1 (Crying Damson)
LUA:
local FOODS =
{
	[2362] = {8, "Crunch.", {10, 25}, {25, 50}}, -- Carrots of doom
	[2666] = {15, "Munch.", {5, 20}, {3, 10}}, -- Meat
	[2667] = {12, "Munch.", {5, 25}, {5, 15}}, -- Fish
	[2668] = {10, "Mmmm.", {3, 13}, {1, 9}}, -- Salmon
	[2669] = {17, "Munch.", {10, 45}, {15, 50}}, -- Northern pikes (big fish)
	[2670] = {4, "Gulp.", {1, 10}, {1, 10}}, -- Shrimps
	[2671] = {30, "Chomp.", {20, 60}, {25, 45}}, -- Ham
	[2672] = {60, "Chomp.", {30, 75}, {25, 65}}, -- Dragon ham
	[2673] = {5, "Yum.", {1, 15}, {5, 35}}, -- Pears
	[2674] = {6, "Yum.", {1, 10}, {10, 35}}, -- Red apple
	[2675] = {13, "Yum.", {1, 7}, {15, 40}}, -- Orange
	[2676] = {8, "Yum.", {5, 20}, {15, 30}}, -- Banana
	[2677] = {1, "Yum.", {1, 5}, {1, 5}}, -- Blueberry
	[2678] = {18, "Slurp.", {15, 50}, {30, 55}}, -- Coconut
	[2679] = {1, "Yum.", {1, 7}, {1, 7}}, -- Cherry
	[2680] = {2, "Yum.", {1, 10}, {2, 18}}, -- Strawberry
	[2681] = {9, "Yum.", {10, 35}, {25, 25}}, -- Grapes
	[2682] = {20, "Yum.", {20, 55}, {20, 55}}, -- Melon
	[2683] = {17, "Munch.", {15, 50}, {15, 50}}, -- Pumpkin
	[2684] = {8, "Crunch.", {10, 20}, {25, 45}}, -- Carrots
	[2685] = {6, "Munch.", {5, 15}, {5, 10}}, -- Tomato
	[2686] = {9, "Crunch.", {1, 15}, {1, 8}}, -- Corncobs
	[2687] = {2, "Crunch.", {1, 3}, {1, 2}}, -- Cookies
	[2688] = {9, "Munch.", {1, 5}, {1, 5}}, -- Candy canes
	[2689] = {10, "Crunch.", {1, 15}, {5, 15}}, -- Bread
	[2690] = {3, "Crunch.", {5, 20}, {5, 15}}, -- Rolls
	[2691] = {8, "Crunch.", {10, 25}, {10, 15}}, -- Brown bread
	[2792] = {6, "Munch.", {5, 15}, {5, 10}}, -- Dark mushrooms
	[2793] = {9, "Munch.", {10, 30}, {15, 25}}, -- Mushrooms
	[2695] = {6, "Gulp.", {10, 40}, {10, 40}}, -- Eggs
	[2696] = {9, "Smack.", {10, 30}, {10, 25}}, -- Cheese
	[2787] = {9, "Munch.", {10, 35}, {15, 30}}, -- White mushrooms
	[2788] = {4, "Munch.", {10, 35}, {15, 50}}, -- Red mushrooms
	[2789] = {22, "Munch.", {15, 55}, {15, 55}}, -- Brown mushrooms
	[2790] = {30, "Munch.", {10, 35}, {15, 35}}, -- Orange mushrooms
	[2791] = {30, "Munch.", {15, 35}, {15, 35}}, -- Wood mushrooms
	[2794] = {3, "Munch.", {15, 35}, {15, 35}}, -- Mushrooms
	[2795] = {36, "Munch.", {75, 150}, {80, 150}}, -- Fire mushrooms
	[2796] = {5, "Munch.", {30, 125}, {40, 120}}, -- Green mushrooms
	[5097] = {4, "Yum.", {10, 35}, {15, 35}}, -- Mango
	[6125] = {8, "Gulp.", {15, 35}, {25, 30}}, -- Tortoise egg
	[6278] = {10, "Mmmm.", {10, 20}, {15, 25}}, -- Cake
	[6279] = {15, "Mmmm.", {7, 20}, {10, 25}}, -- Decorated cake
	[6393] = {50, "The power of love!", {5000, 5000}, {5000, 5000}}, -- Valentine cake
	[6394] = {15, "Mmmm.", {15, 25}, {15, 25}}, -- Cream cake
	[6501] = {20, "Mmmm.", {10, 20}, {25, 40}}, -- gingerbread man
	[6541] = {6, "Gulp.", {10, 25}, {15, 25}}, -- Yellow eggs
	[6542] = {6, "Gulp.", {10, 25}, {15, 25}}, -- Red eggs
	[6543] = {6, "Gulp.", {10, 25}, {15, 25}}, -- Blue eggs
	[6544] = {6, "Gulp.", {10, 25}, {15, 25}}, -- Green eggs
	[6545] = {6, "Gulp.", {10, 25}, {15, 25}}, -- Purple eggs
	[6569] = {1, "Mmmm.", {5, 15}, {5, 15}}, -- Candy
	[6574] = {4, "Mmmm.", {10, 20}, {5, 20}}, -- Chocolate
	[7158] = {15, "Munch.", {55, 100}, {45, 105}}, -- Rainbow trouts (Fish)
	[7159] = {13, "Munch.", {40, 75}, {35, 80}}, -- Green perches (Fish)
	[7372] = {7, "Yum.", {25, 35}, {25, 50}}, -- Ice cream cone
	[7373] = {7, "Yum.", {15, 25}, {25, 50}}, -- Yellow ice
	[7374] = {7, "Yum.", {15, 25}, {25, 50}}, -- Red ice
	[7375] = {7, "Yum.", {15, 25}, {25, 50}}, -- Purple ice
	[7376] = {7, "Yum.", {15, 25}, {25, 50}}, -- Green ice
	[7377] = {7, "Yum.", {15, 25}, {25, 50}}, -- Blue ice
	[8838] = {7, "Gulp.", {15, 30}, {25, 30}}, -- Potato
	[8839] = {5, "Yum.", {10, 25}, {15, 25}}, -- Plum
	[8840] = {2, "Yum.", {5, 15}, {5, 10}}, -- Raspberry
	[8841] = {3, "Urgh.", {1, 20}, {5, 30}}, -- Lemon
	[8842] = {5, "Munch.", {5, 25}, {5, 25}}, -- Cucumber
	[8843] = {3, "Crunch.", {1, 20}, {5, 20}}, -- Onion
	[8844] = {3, "Gulp.", {25, 60}, {35, 70}}, -- Jalapeno peper
	[8845] = {2, "Munch.", {10, 25}, {5, 20}}, -- Beetroot
	[8847] = {11, "Yum.", {10, 25}, {20, 30}}, -- Chocolate cake
	[7910] = {4, "Crunch.", {15, 25}, {25, 30}}, -- Peanut
	[7909] = {4, "Crunch.", {15, 25}, {25, 30}}, -- Walnut
}

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)
	doCreatureAddHealth(cid, math.random(food[3][1], food[3][2]))
	doPlayerAddMana(cid, math.random(food[4][1], food[4][2]))
	return true
end
 
Hmm it is a lot shorter so i wil put you're script with credits ofcourse, I won't think its strange that mine does randomize because mine is tfs crying damson 0.3.6pl1 but its modified and comboed with evolutions so i got some bugs (i will post it later when it really bugs me.)
 
I've taken the farming idea a step further and made plantable movable trees that give experience when you harvest and plant, and take energy to harvest and plant.
 
use exhaustion.get + exhaustion.set, search if you don't know how to
 
use exhaustion.get + exhaustion.set, search if you don't know how to

I tried with storage but it didn't work, I can only find scripts with exhaustion.get for talkactions and i never worked with it before so don't really know how to implement it.
Could you give an example for an action?
 
Code:
	if(exhaustion.check(cid, [COLOR="#FF0000"]EXHAUSTION_STORAGE[/COLOR])) then return true end
	exhaustion.set(cid, [COLOR="#FF0000"]EXHAUSTION_STORAGE[/COLOR], [COLOR="#FF0000"]EXHAUSTION_TIME_IN_SEK[/COLOR])
 
LUA:
local FOODS =
{
	[8847] = {11, "Yum.", {10, 25}, {20, 30}}, -- Chocolate cake
	[7910] = {4, "Crunch.", {15, 25}, {25, 30}}, -- Peanut
	[7909] = {4, "Crunch.", {15, 25}, {25, 30}}, -- Walnut
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local food = FOODS[item.itemid]
	if(not food) then
		return false
	end

	if(exhaustion.check(cid, EXHAUSTION_STORAGE)) then return true end
	exhaustion.set(cid, EXHAUSTION_STORAGE, EXHAUSTION_TIME_IN_SEK)
 
	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)
	doCreatureAddHealth(cid, math.random(food[3][1], food[3][2]))
	doPlayerAddMana(cid, math.random(food[4][1], food[4][2]))
	return true
end
 
Back
Top