• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Please someone help me with potions! FAST AS POSSIBLE PLEASE :(

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,780
Solutions
31
Reaction score
2,299
Location
Sweden?
Omg i got a problem help!!

Ok its work when your low its heal 1.0x , but when you relog on a higher char which is lvl 500+ then you heal 1.2x more then if you relog too your lvl 8 char he heal too 1.2x more
 
Last edited:
its just normal potion script on tfs 0.3.6!

Code:
local config = {
	removeOnUse = "no",
	usableOnTarget = "yes", -- can be used on target? (fe. healing friend)
	splashable = "no",
	realAnimation = "no", -- make text effect visible only for players in range 1x1
	healthMultiplier = 1.0,
	manaMultiplier = 1.0
}

config.removeOnUse = getBooleanFromString(config.removeOnUse)
config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
config.splashable = getBooleanFromString(config.splashable)
config.realAnimation = getBooleanFromString(config.realAnimation)

local POTIONS = {
	[8704] = {empty = 7636, splash = 2, health = {30, 80}}, -- small health potion
	[7618] = {empty = 7636, splash = 2, health = {50, 100}}, -- health potion
	[7588] = {empty = 7634, splash = 2, health = {200, 400}, level = 50, vocations = {4, 8}, vocStr = "knights"}, -- strong health potion
	[7591] = {empty = 7635, splash = 2, health = {500, 700}, level = 1, vocations = {4, 8}, vocStr = "knights"}, -- great health potion
	[8473] = {empty = 7635, splash = 2, health = {2300, 2700}, level = 1, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion
	[8472] = {empty = 8472, splash = 2, health = {2800, 3000}, level = 1300, vocations = {4, 8}, vocStr = "only knight with subclasses"}, -- sub ultimate health potion

	[7620] = {empty = 7636, splash = 7, mana = {570, 730}}, -- mana potion
	[7589] = {empty = 7634, splash = 7, mana = {800, 1000}, level = 1, vocations = {1, 2, 3, 4, 5, 6, 7, 8}, vocStr = "sorcerers, druids, paladins and knights"}, -- strong mana potion
	[7590] = {empty = 7635, splash = 7, mana = {1400, 1600}, level = 1, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- great mana potion
	[5928] = {empty = 5928, splash = 7, mana = {1800, 2100}, level = 1300, vocations = {1, 2, 5, 6}, vocStr = "only mage with subclasses"}, -- sub great mana potion
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

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

	if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
		if(not config.splashable) then
			return false
		end

		if(toPosition.x == CONTAINER_POSITION) then
			toPosition = getThingPos(item.uid)
		end

		doDecayItem(doCreateItem(2016, potion.splash, toPosition))
		doTransformItem(item.uid, potion.empty)
		return true
	end

	if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return true
	end

	if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
		not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
	then
		doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
		return true
	end

	local health = potion.health
	if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2]) * config.healthMultiplier))) then
		return false
	end

	local mana = potion.mana
	if(mana and not doPlayerAddMana(itemEx.uid, math.ceil(math.random(mana[1], mana[2]) * config.manaMultiplier))) then
		return false
	end

	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	if(not realAnimation) then
		doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
	else
		for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
			if(isPlayer(tid)) then
				doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid)
			end
		end
	end
	return true
end
 
Last edited:
I hate this, why you do not use
LUA:
 for lua scripts
[code=xml] xml for scripts .. etc.

wrr ;(

-- edit I mean, of course forum!
like that:
[code=lua]
function blabla()
  if blabla then
    youSeeBeter("so you can see better!!!")
  end
end

edit your post and instead of
give
LUA:
 
Last edited:
But you could make seprate pot, i need only 1 health pot and 1 mana pot! llv 500 heal with helath pot 1.5k 1,7k random between those numbers and lvl 1000 heal 2,2k and 2,5k between those number random! please could you make it? :(
 
LUA:
local config = {
	removeOnUse = "no",
	usableOnTarget = "yes", -- can be used on target? (fe. healing friend)
	splashable = "no",
	realAnimation = "no", -- make text effect visible only for players in range 1x1
	healthMultiplier = 1.0,
	manaMultiplier = 1.0
}

config.removeOnUse = getBooleanFromString(config.removeOnUse)
config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
config.splashable = getBooleanFromString(config.splashable)
config.realAnimation = getBooleanFromString(config.realAnimation)

local POTIONS = {
	[8704] = {empty = 7636, splash = 2, health = {30, 80}}, -- small health potion
	[7618] = {empty = 7636, splash = 2, health = {50, 100}}, -- health potion
	[7588] = {empty = 7634, splash = 2, health = {200, 400}, level = 50, vocations = {4, 8}, vocStr = "knights"}, -- strong health potion
	[7591] = {empty = 7635, splash = 2, health = {500, 700}, level = 1, vocations = {4, 8}, vocStr = "knights"}, -- great health potion
	[8473] = {empty = 7635, splash = 2, health = {2300, 2700}, level = 1, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion
	[8472] = {empty = 8472, splash = 2, health = {2800, 3000}, level = 1300, vocations = {4, 8}, vocStr = "only knight with subclasses"}, -- sub ultimate health potion

	[7620] = {empty = 7636, splash = 7, mana = {570, 730}}, -- mana potion
	[7589] = {empty = 7634, splash = 7, mana = {800, 1000}, level = 1, vocations = {1, 2, 3, 4, 5, 6, 7, 8}, vocStr = "sorcerers, druids, paladins and knights"}, -- strong mana potion
	[7590] = {empty = 7635, splash = 7, mana = {1400, 1600}, level = 1, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- great mana potion
	[5928] = {empty = 5928, splash = 7, mana = {1800, 2100}, level = 1300, vocations = {1, 2, 5, 6}, vocStr = "only mage with subclasses"}, -- sub great mana potion
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

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

	if getPlayerLevel(ci) >= 100 then
		config.healthMultiplier = 2
		config.manaMultiplier = 2
	end
		
	if(not potion) then
		return false
	end

	if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
		if(not config.splashable) then
			return false
		end

		if(toPosition.x == CONTAINER_POSITION) then
			toPosition = getThingPos(item.uid)
		end

		doDecayItem(doCreateItem(2016, potion.splash, toPosition))
		doTransformItem(item.uid, potion.empty)
		return true
	end

	if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return true
	end

	if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
		not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
	then
		doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
		return true
	end

	local health = potion.health
	if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2]) * config.healthMultiplier))) then
		return false
	end

	local mana = potion.mana
	if(mana and not doPlayerAddMana(itemEx.uid, math.ceil(math.random(mana[1], mana[2]) * config.manaMultiplier))) then
		return false
	end

	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	if(not realAnimation) then
		doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
	else
		for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
			if(isPlayer(tid)) then
				doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid)
			end
		end
	end
	return true
end
 
Last edited:
Andy you understand what i need?

Example item 8473, its heal when your lvl 1-500 it heals 1,5k to 1,7k then if you get lvl 1000 it will then heal 2,2k and 2,5k
 
i have do that
LUA:
	if getPlayerLevel(ci) >= 100 then
		config.healthMultiplier = 2
		config.manaMultiplier = 2
	end
very simple. you set the level, and what is to be a multiplier
You can add more:
LUA:
	if getPlayerLevel(ci) >= 500 then -- for 500 up
		config.healthMultiplier = 3.5
		config.manaMultiplier = 3.5
	end
	if getPlayerLevel(ci) >= 700 then -- for 700 lvl up
		config.healthMultiplier = 6.5
		config.manaMultiplier = 6.5
	end

and do not forget .. here ;)
 
No andy not like that.

I want lvl 1 - 500 heal same 1.5k and 1,7k then if you are 1000 you heal between this number 2,2k and 2,7k!

Im not scripter xD but i think it would be like this
Itemid: 8927
if getPlayerLevel (cid) > 1 - 500 = heal => min: 1,5k max 1,7k then if if getPlayerLevel (cid) >1000-2000 = heal => min: 2,2k max: 2,7k
 
Last edited:
and just so you can set. You had mathematics?

-- edit
you can do so:
LUA:
local config = {
	removeOnUse = "no",
	usableOnTarget = "yes", -- can be used on target? (fe. healing friend)
	splashable = "no",
	realAnimation = "no", -- make text effect visible only for players in range 1x1
	healthMultiplier = 1.0,
	manaMultiplier = 1.0
}

config.removeOnUse = getBooleanFromString(config.removeOnUse)
config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
config.splashable = getBooleanFromString(config.splashable)
config.realAnimation = getBooleanFromString(config.realAnimation)

local POTIONS = {
	[8704] = {empty = 7636, splash = 2, health = {30, 80}}, -- small health potion
	[7618] = {empty = 7636, splash = 2, health = {50, 100}}, -- health potion
	[7588] = {empty = 7634, splash = 2, health = {200, 400}, level = 50, vocations = {4, 8}, vocStr = "knights"}, -- strong health potion
	[7591] = {empty = 7635, splash = 2, health = {500, 700}, level = 1, vocations = {4, 8}, vocStr = "knights"}, -- great health potion
	[8473] = {empty = 7635, splash = 2, health = {2300, 2700}, level = 1, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion
	[8472] = {empty = 8472, splash = 2, health = {2800, 3000}, level = 1300, vocations = {4, 8}, vocStr = "only knight with subclasses"}, -- sub ultimate health potion

	[7620] = {empty = 7636, splash = 7, mana = {570, 730}}, -- mana potion
	[7589] = {empty = 7634, splash = 7, mana = {800, 1000}, level = 1, vocations = {1, 2, 3, 4, 5, 6, 7, 8}, vocStr = "sorcerers, druids, paladins and knights"}, -- strong mana potion
	[7590] = {empty = 7635, splash = 7, mana = {1400, 1600}, level = 1, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- great mana potion
	[5928] = {empty = 5928, splash = 7, mana = {1800, 2100}, level = 1300, vocations = {1, 2, 5, 6}, vocStr = "only mage with subclasses"}, -- sub great mana potion
}
local POTIONS500 = { -- for 500lv up
	[8704] = {empty = 7636, splash = 2, health = {300, 800}}, -- small health potion
	[7618] = {empty = 7636, splash = 2, health = {500, 1000}}, -- health potion
	[7588] = {empty = 7634, splash = 2, health = {2000, 4000}, level = 50, vocations = {4, 8}, vocStr = "knights"}, -- strong health potion
	[7591] = {empty = 7635, splash = 2, health = {5000, 7000}, level = 1, vocations = {4, 8}, vocStr = "knights"}, -- great health potion
	[8473] = {empty = 7635, splash = 2, health = {23000, 27000}, level = 1, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion
	[8472] = {empty = 8472, splash = 2, health = {28000, 3000}, level = 1300, vocations = {4, 8}, vocStr = "only knight with subclasses"}, -- sub ultimate health potion

	[7620] = {empty = 7636, splash = 7, mana = {570, 730}}, -- mana potion
	[7589] = {empty = 7634, splash = 7, mana = {800, 1000}, level = 1, vocations = {1, 2, 3, 4, 5, 6, 7, 8}, vocStr = "sorcerers, druids, paladins and knights"}, -- strong mana potion
	[7590] = {empty = 7635, splash = 7, mana = {1400, 1600}, level = 1, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- great mana potion
	[5928] = {empty = 5928, splash = 7, mana = {1800, 2100}, level = 1300, vocations = {1, 2, 5, 6}, vocStr = "only mage with subclasses"}, -- sub great mana potion
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

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

	if getPlayerLevel(cid) >= 500 then  -- for 500lv up
		potion = POTIONS500[item.itemid]
	end
		
	if(not potion) then
		return false
	end

	if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
		if(not config.splashable) then
			return false
		end

		if(toPosition.x == CONTAINER_POSITION) then
			toPosition = getThingPos(item.uid)
		end

		doDecayItem(doCreateItem(2016, potion.splash, toPosition))
		doTransformItem(item.uid, potion.empty)
		return true
	end

	if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return true
	end

	if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
		not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
	then
		doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
		return true
	end

	local health = potion.health
	if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2]) * config.healthMultiplier))) then
		return false
	end

	local mana = potion.mana
	if(mana and not doPlayerAddMana(itemEx.uid, math.ceil(math.random(mana[1], mana[2]) * config.manaMultiplier))) then
		return false
	end

	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	if(not realAnimation) then
		doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
	else
		for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
			if(isPlayer(tid)) then
				doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid)
			end
		end
	end
	return true
end

but i don't like it
 
Last edited:
Andy bro so you know i only use 2 potion in whole game ultimate health and great mana. could you do only on this pot instead making new pots :( please bro

Because i dont want the script so long make it just simple :D
 
LUA:
local config = {
	removeOnUse = "no",
	usableOnTarget = "yes", -- can be used on target? (fe. healing friend)
	splashable = "no",
	realAnimation = "no", -- make text effect visible only for players in range 1x1
	healthMultiplier = 1.0,
	manaMultiplier = 1.0
}
 
config.removeOnUse = getBooleanFromString(config.removeOnUse)
config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
config.splashable = getBooleanFromString(config.splashable)
config.realAnimation = getBooleanFromString(config.realAnimation)
 
local POTIONS = {
	[8473] = {empty = 7635, splash = 2, health = {1500, 1700}, level = 1, vocations = {1, 2, 3, 4, 5, 6, 7, 8}, vocStr = "sorcerers, druids, palladins and knights"}, -- ultimate health potion
	[7590] = {empty = 7635, splash = 7, mana = {1500, 1700}, level = 1, vocations = {1, 2, 3, 4, 5, 6, 7, 8}, vocStr = "sorcerers, druids, palladins and knights"} -- great mana potion
}
 
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local potion = POTIONS[item.itemid]
 
	if getPlayerLevel(cid) >= 500 then  -- for 500lv up
		config.healthMultiplier = 1.5
		config.manaMultiplier = 1.5
	end
 
	if(not potion) then
		return false
	end
 
	if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
		if(not config.splashable) then
			return false
		end
 
		if(toPosition.x == CONTAINER_POSITION) then
			toPosition = getThingPos(item.uid)
		end
 
		doDecayItem(doCreateItem(2016, potion.splash, toPosition))
		doTransformItem(item.uid, potion.empty)
		return true
	end
 
	if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return true
	end
 
	if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
		not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
	then
		doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
		return true
	end
 
	local health = potion.health
	if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2]) * config.healthMultiplier))) then
		return false
	end
 
	local mana = potion.mana
	if(mana and not doPlayerAddMana(itemEx.uid, math.ceil(math.random(mana[1], mana[2]) * config.manaMultiplier))) then
		return false
	end
 
	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	if(not realAnimation) then
		doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
	else
		for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
			if(isPlayer(tid)) then
				doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid)
			end
		end
	end
	return true
end
that is ok?
 
bro but is it same potion? because i want the same potion when you are lvl 1-500 heal 1,5-1,7k and same potion for lvl 501-1000 to heal 2,2k and 2.5k
 
ok bro but i have to test it tomorrow :( i have my server on, so i cant risk it :( but if it works i will rep you :)
 

Similar threads

Back
Top