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

Eat food - Instantly heals

  • Thread starter Deleted member 49793
  • Start date
D

Deleted member 49793

Guest
Hey i know this was released but cant find it... Could someone link me OR post a new script for it :)

Basicly just when player eats fish, instantly restores 50 mana and 50 health

AND

when eat cod instnatly restores 5% max hp and 5% max mana (No cooldown plz)
 
Post the script? Im currently using the script you suggested to me and nothing happens when you try and eat a shrimp, I set it all right in actions.xml

Code:
local t = {
	[2667] = {'Munch.', hp=50, mp=50},
	[cod??] = {'Munch.', hppc=5, mppc=5},
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = t[item.itemid]
 
	doCreatureSay(cid, v[1], TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
	if v.hp then
		doCreatureAddHealth(cid, v.hp)
	elseif v.hppc then
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid) * v.hppc / 100)
	end
 
	if v.mp then
		doCreatureAddMana(cid, v.mp)
	elseif v.mppc then
		doCreatureAddMana(cid, getCreatureMaxMana(cid) * v.mppc / 100)
	end
	return true
end
 
1) You didn't change cod?? to a valid itemid (number)
2) You haven't added a line with shrimp's ID, something like this:
Code:
local t = {
	[2667] = {'Munch.', hp=50, mp=50},
	[[I]cod_itemid_goes_here[/I]] = {'Munch.', hppc=5, mppc=5},
[B][COLOR="red"]	[2670] = {'Munch.', hp=50, mp=50},[/COLOR][/B]
}
 
Whats cod_itemid ? Like the ID of Cod (Fish?)
And i made it like so...
local t = {
[2670] = {'Munch.', hp=50, mp=50},
}

Just to test on a shrimp
 
You must be doing something wrong — as it's working just fine for me…

Here's the actions.xml part:
Code:
    <action itemid="2666;2668-2669;2671-2691" event="script" value="other/food.lua"/>
    <action itemid="2667;2670" event="script" value="other/magicfood.lua"/>
 
I have it like this
In actions.xml
<action itemid="2666;2668-2669;2671-2691" event="script" value="other/food.lua"/>
<action itemid="2667;2670" event="script" value="other/magicfood.lua"/>

In magicfood.lua

local t = {
[2670] = {'Munch.', hp=50, mp=50},
[2667] = {'Munch.', hppc=5, mppc=5},
}




function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[item.itemid]

doCreatureSay(cid, v[1], TALKTYPE_ORANGE_1)
doRemoveItem(item.uid, 1)
if v.hp then
doCreatureAddHealth(cid, v.hp)
elseif v.hppc then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid) * v.hppc / 100)
end

if v.mp then
doCreatureAddMana(cid, v.mp)
elseif v.mppc then
doCreatureAddMana(cid, getCreatureMaxMana(cid) * v.mppc / 100)
end
return true
end

And when you try and eat those 2 things, just eats them like a normal food. However does it not say +50 hp + 50 mana over your char? Is that maybe why? cause now it lets me use them but gives no effect saying im healed
 
Code:
local t = {
	[[COLOR="red"]xxxx[/COLOR]] = {'Munch.', hp=50, mp=50},
	[[COLOR="red"]xxxx[/COLOR]] = {'Munch.', hppc=5, mppc=5}
}
local add
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = t[item.itemid]
	doCreatureSay(cid, v[1], TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
	
	if v.hp then
		add = v.hp
		doCreatureAddHealth(cid, add)
	elseif v.hppc then
		add = v.hppc
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid) * (add / 100))
	elseif v.mp then
		add = v.mp
		doPlayerAddMana(cid, add)
	elseif v.mppc then
		add = v.mppc
		doPlayerAddMana(cid, getCreatureMaxMana(cid) * (add / 100))
	end
	
	doSendAnimatedText(getThingPos(cid), "+" (v.hp or v.mp and " .. add .. ") or (v.hppc or v.mppc and " .. (add / 100) .. "), TEXTCOLOR_RED)
	return true
end
 
Last edited:
Thank you so much jdp!

Edit: Do you know a way to make when you eat a something that it gives you the effect of a berserk potion for example?
So you eat, increases your weapon skills by 10 for 60 seconds? or something

Edit Edit: For some reason the script, The hppc: = hp regan not percent. Anyone know why? This player has 1200 hp and it gave him 5 Health and 100 mana (he has 400 mana max)
 
Last edited by a moderator:
Thank you so much jdp!

Edit: Do you know a way to make when you eat a something that it gives you the effect of a berserk potion for example?
So you eat, increases your weapon skills by 10 for 60 seconds? or something

Edit Edit: For some reason the script, The hppc: = hp regan not percent. Anyone know why? This player has 1200 hp and it gave him 5 Health and 100 mana (he has 400 mana max)

I don't think it gave only "5." I think it just showed "5" above the player. Copy the script again.
 
Hurr
Lua:
local berserk = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(berserk, CONDITION_PARAM_TICKS, 60 * 1000)
setConditionParam(berserk, CONDITION_PARAM_SKILL_MELEE, 10)
setConditionParam(berserk, CONDITION_PARAM_SUBID, 4)

local t = {
	[2670] = {'Munch.', hp=50, mp=50},
	[2667] = {'Munch.', hppc=5, mppc=5, condition=berserk},
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = t[item.itemid]
	local a, b, p = v.hp or math.ceil(getCreatureMaxHealth(cid) * (v.hppc or 0) / 100), v.mp or math.ceil(getCreatureMaxMana(cid) * (v.mppc or 0) / 100), getThingPos(cid)

	doCreatureSay(cid, v[1], TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)

	if a ~= 0 then
		doCreatureAddHealth(cid, a)
		doSendAnimatedText(p, '+' .. a, COLOR_GREEN)
	end

	if b ~= 0 then
		doCreatureAddMana(cid, b)
		doSendAnimatedText(p, '+' .. b, COLOR_PURPLE)
	end

	if v.condition then
		doAddCondition(cid, v.condition)
	end

	return true
end
 
Which is better approach?

Edit: Nice it works cyko
but can you edit it to make it also have 2 other fish
One that gives + magic level and one that gives + shielding :D?
Please and thank you
 
Mine, because it has the berserk thingy.
smilie.png

Lua:
local berserk = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(berserk, CONDITION_PARAM_TICKS, 60 * 1000)
setConditionParam(berserk, CONDITION_PARAM_SKILL_MELEE, 10)
setConditionParam(berserk, CONDITION_PARAM_SKILL_DISTANCE, 10)
setConditionParam(berserk, CONDITION_PARAM_SUBID, 4)

local magic = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(magic, CONDITION_PARAM_TICKS, 60 * 1000)
setConditionParam(magic, CONDITION_PARAM_STAT_MAGICLEVEL, 5)
setConditionParam(magic, CONDITION_PARAM_SUBID, 5)

local shield = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(shield, CONDITION_PARAM_TICKS, 60 * 1000)
setConditionParam(shield, CONDITION_PARAM_SKILL_SHIELD, 5)
setConditionParam(shield, CONDITION_PARAM_SUBID, 6)

local t = {
	[2670] = {'Munch.', hp=50, mp=50},
	[2667] = {'Munch.', hppc=5, mppc=5, condition=berserk},
	[fish1] = {'Munch.', condition=magic},
	[fish2] = {'Munch.', condition=shield},
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = t[item.itemid]
	local a, b, p = v.hp or math.ceil(getCreatureMaxHealth(cid) * (v.hppc or 0) / 100), v.mp or math.ceil(getCreatureMaxMana(cid) * (v.mppc or 0) / 100), getThingPos(cid)

	doCreatureSay(cid, v[1], TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)

	if a ~= 0 then
		doCreatureAddHealth(cid, a)
		doSendAnimatedText(p, '+' .. a, COLOR_GREEN)
	end

	if b ~= 0 then
		doCreatureAddMana(cid, b)
		doSendAnimatedText(p, '+' .. b, COLOR_PURPLE)
	end

	if v.condition then
		doAddCondition(cid, v.condition)
	end

	return true
end
Don't forget to un-bind them from food.lua, and bind to magicfood.lua or whatever.
 
Last edited:
Back
Top