• 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 Potions with charges 2.0

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil

  • [*]Author: Mock
    [*]Tested on: TFS 0.3.6

Like the first but better and without bugs. You can now set level multipiler :)
Add this tag on actions.xml and delete old potions tag:
Code:
 <action itemid="7588" script="liquids/potions charges.lua" allowfaruse="1"/>
	<action itemid="7589" script="liquids/potions charges.lua" allowfaruse="1"/>
	<action itemid="7590" script="liquids/potions charges.lua" allowfaruse="1"/>
	<action itemid="7591" script="liquids/potions charges.lua" allowfaruse="1"/>
	<action itemid="8472" script="liquids/potions charges.lua" allowfaruse="1"/>
	<action itemid="8473" script="liquids/potions charges.lua" allowfaruse="1"/>
	<action itemid="7618" script="liquids/potions charges.lua" allowfaruse="1"/>
	<action itemid="7620" script="liquids/potions charges.lua" allowfaruse="1"/>
create the scritp and add it:
Lua:
-- Script by Mock (the bear)
local storage = {
[1] = {17073,function(hmax,hmin,cid,multipiler) doCreatureAddHealth(cid, math.random(hmin+multipiler,hmax+multipiler)) end},
[2] = {17074,function(hmax,hmin,cid,multipiler) doCreatureAddMana(cid, math.random(hmin+multipiler,hmax+multipiler)) end},
[3] = {17075,function(hmax,hmin,cid,multipiler) doCreatureAddHealth(cid, math.random(hmin[1]+multipiler,hmax[1]+multipiler)) doCreatureAddMana(cid, math.random(hmin[2]+multipiler,hmax[2]+multipiler)) end},
}
local potions = {
	-- smalll
	--ITEMID  level  type    max      min     empyt       vocation                    exhaust delay   level increase heal
	[7620] = {lvl=0,tipo=2,hmax=101,hmin=100,vasio=7636,vocs={0,1,2,3,4,5,6,7,8,9,10,11,12},exaust=1,lvladd=0},
	[7618] = {lvl=0,tipo=1,hmax=100,hmin=50,vasio=7636,vocs={0,1,2,3,4,5,6,7,8,9,10,11,12},exaust=1,lvladd=0},  -- HP
	---strong
	[7589] = {lvl=50,tipo=2,hmax=190,hmin=110,vasio=7634,vocs={1,2,3,5,6,7,11,10,9},exaust=1,lvladd=0},
	[7588] = {lvl=50,tipo=1,hmax=400,hmin=200,vasio=7634,vocs={3,4,7,8,12,11},exaust=1,lvladd=0},    -- HP
	-- great
	[7591] = {lvl=80,tipo=1,hmax=800,hmin=600,vasio=7635,vocs={4,8,12},exaust=1,lvladd=0}, -- hP
	[7590] = {lvl=80,tipo=2,hmax=800,hmin=600,vasio=7635,vocs={1,2,5,6,10,9},exaust=1,lvladd=0}, -- MP
	[8472] = {lvl=80,tipo=3,hmax={400,190},hmin={200,110},vasio=7635,vocs={3,7,11},exaust=1,lvladd=0},
	--- ultimate
	[8473] = {lvl=130,tipo=1,hmax=1000,hmin=800,vasio=7635,vocs={4,8,0,0,12},exaust=1,lvladd=0},
	--My custom mana potion
	[2363] = {lvl=130,tipo=2,hmax=2000,hmin=1000,vasio=7635,vocs={4,8,0,0,12},exaust=1,lvladd=0.5},
	config={
		startCharges=5, -- If potion has no one charge it change

	}

}
--- Script by Mock (the bear)
local function getItemDName(uid)
	return getItemAttribute(uid,'name')
end
local function setItemName(uid,name)
	return doItemSetAttribute(uid,'name',name)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isPlayer(itemEx.uid) == false or potions[item.itemid] == nil or isCreature(itemEx.uid) == false then
		return FALSE
   elseif tonumber(getPlayerStorageValue(itemEx.uid, storage[potions[item.itemid].tipo][1])) and tonumber(getPlayerStorageValue(itemEx.uid, storage[potions[item.itemid].tipo][1])) > tonumber(os.clock()*100) then
		doPlayerSendDefaultCancel(itemEx.uid, RETURNVALUE_YOUAREEXHAUSTED)
		return TRUE
	elseif getPlayerLevel(itemEx.uid) < potions[item.itemid].lvl or not isInArray(potions[item.itemid].vocs,getPlayerVocation(itemEx.uid)) then
       doCreatureSay(itemEx.uid, "Only required vocation and level "..potions[item.itemid].lvl.." or above may drink this fluid.", TALKTYPE_ORANGE_1)
		return TRUE
	end
	setPlayerStorageValue(itemEx.uid,  storage[potions[item.itemid].tipo][1], (os.clock()+potions[item.itemid].exaust)*100)
    local multipiler = (potions[item.itemid].lvladd or 0)*getPlayerLevel(itemEx.uid)
	storage[potions[item.itemid].tipo][2](potions[item.itemid].hmax,potions[item.itemid].hmin,itemEx.uid,multipiler)
	local cnt =(getItemName(item.uid) or ''):match('(%d+)')
	cnt = (tonumber(cnt) or potions.config.startCharges)
	if cnt and cnt > 1 then
		setItemName(item.uid, getItemNameById(item.itemid).." x "..cnt-1)
	else
	   doTransformItem(item.uid,potions[item.itemid].vasio)
	end
	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
	return TRUE   --- Script by Mock (the bear)
end

And enjoy ;D
dont forget to config.

18:09 You see a mana potion x 4.
It weighs 1.80 oz.
 
Last edited:
@Derek Boom Boom
why? ^^
did you see that?
--ITEMID level type max min empyt vocation exhaust delay level increase heal
and i think 2 vars wrtie in br dont kill no one
 
@Derek Boom Boom
why? ^^
did you see that?

and i think 2 vars wrtie in br dont kill no one

Well, it's better to use english variables, why? Let's say you get a job and you're giving away code for producer with br variables. You can write end of this story by urself...


learn br plz;)
@Mock, stack, 8.6 like?

Omg, why are you so offenvise against me? Because I said once it's better to use constants instead of numbers? It wasn't offenvise, it was just my thought. Also, it's international forum so it's better to use english variables because everybody uses english here so it's easier for everybody to read variables in english instead of learning brazilian (Correct me if I'm wrong with this word.) language.
 
Last edited:
i didn't say anything lol'd
mock is not getting a job rofl
naj not better to use english variables, the script won't know it ^_^
 
Derek you have to excuse this mudfuk above me, he's on one (or two)...

Mock scripts always niceeeeeeeee
 
Derek you have to excuse this mudfuk above me, he's on one (or two)...

Mock scripts always niceeeeeeeee
+1 not matter in which language;)
even his pacman in br pwnz
 
+1 not matter in which language;)
even his pacman in br pwnz

But don't you think it's easier to read organized code? I know, there are many leechers (Maybe even you're one of them.) who just copy/paste scripts and doesn't care about code, but there are few persons who'd like to read the code, edit and understand.
 
the forum is for that, they ask :p
:$ ^_^ :p
 
Well, it's better to use english variables, why? Let's say you get a job and you're giving away code for producer with br variables. You can write end of this story by urself...




Omg, why are you so offenvise against me? Because I said once it's better to use constants instead of numbers? It wasn't offenvise, it was just my thought. Also, it's national forum so it's better to use english variables because everybody uses english here so it's easier for everybody to read variables in english instead of learning brazilian (Correct me if I'm wrong with this word.) language.

? i tought it was international :/ :/ :/ :/
 
@Cybershot
no. "stack" in name.
@Derek Boom Boom
yes but here its a job?
 
Maybe you could do the same for runes... stacking charges and increasing their weight, and a max of 100 charges?
 
Don`t Work usain tfs 0.3.6 pl1

just change the potions for those yours?
 
If you make an actual charge system for potions, I will be impressed. It will require .otb, .dat, and .spr editing though. <_<
 
Work 100% Nice!!!!

"08:38 You see an ultimate health potion x 4.
It weighs 2.20 oz.
This potion can only be consumed by knights of level 130 or higher.
ItemID: [8473].
Position: [X: 160] [Y: 36] [Z: 7]."
 
@Mock, nice script but if you use it all charges the empty potion have 1 charge in the description

15:46 You see an mana potion x 1.
It weighs 1.80 oz.

fix:

Lua:
 if cnt and cnt > 1 then
                setItemName(item.uid, getItemNameById(item.itemid).." x "..cnt-1)
        else
	       	setItemName(item.uid, getItemNameById(item.itemid).." dont have charges"))
		doTransformItem(item.uid,potions[item.itemid].vasio)
        
 end
 
Back
Top