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

Empty Potion Script

Godely

Member
Joined
Aug 19, 2007
Messages
233
Reaction score
16
I want a script that you just use 1 empty potion on your BP, and it check how many empty potions you have, and mutiply it for 5. Then, it add the number of empty potions * 5 gold to you, and remove all the empty potions. The problem is: If the empty potions were agroupable, I would do it easy. But the function "doRemoveItem" do not remove many itens that can not be putted together.

It's like this:

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
emptypotion = getPlayerItemCount(cid,7636)
number = emptypotion * 5
	doRemoveItem(cid,item.uid,1)
	doPlayerAddItem(cid,2148,number)
	end
	return TRUE
end
 
numberToRemove = getPlayerItemCount(cid, itemId)
doPlayerRemoveItem(cid, idEmptyPot, numberToRemove)
 
It doesn't work, because, as I said, "doRemoveItem" do not work with 2+ itens that are not agroupable.
I think we must use the function "for i =...", something like that.

Someone please?
 
PHP:
local greatHealthPot = 7591
local greatManaPot = 7590
local strongHealthPot = 7588
local strongManaPot = 7589
local healthPot = 7618
local manaPot = 7620
local greatEmptyPot = 7635
local strongEmptyPot = 7634
local emptyPot = 7636

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.uid ~= cid or itemEx.itemid ~= 1 then
		return TRUE
	end

	if(item.itemid == healthPot) then
		if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 170, 230, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
			return FALSE
		end
		doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
            doRemoveItem(item.uid,1)

	elseif(item.itemid == manaPot) then
		if(doTargetCombatMana(0, cid, 85, 150, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
			return FALSE
		end
		doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
            doRemoveItem(item.uid,1)

	elseif(item.itemid == strongHealthPot) then
		if (not(isKnight(cid) or isPaladin(cid)) or (getPlayerLevel(cid) < 50)) and not(getPlayerGroupId(cid) >= 2) then
			doCreatureSay(cid, "This potion can only be consumed by paladins and knights of level 50 or higher.", TALKTYPE_ORANGE_1)
			return TRUE
		end

		if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 300, 500, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
			return FALSE
		end
		doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
            doRemoveItem(item.uid,1)

	elseif(item.itemid == strongManaPot) then
		if (not(isSorcerer(cid) or isDruid(cid) or isPaladin(cid)) or (getPlayerLevel(cid) < 50)) and not(getPlayerGroupId(cid) >= 2) then
			doCreatureSay(cid, "This potion can only be consumed by sorcerers, druids and paladins of level 50 or higher.", TALKTYPE_ORANGE_1)
			return TRUE
		end

		if(doTargetCombatMana(0, cid, 100, 200, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
			return FALSE
		end
		doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
            doRemoveItem(item.uid,1)

	elseif(item.itemid == greatHealthPot) then
		if (not(isKnight(cid)) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
			doCreatureSay(cid, "This potion can only be consumed by knights of level 80 or higher.", TALKTYPE_ORANGE_1)
			return TRUE
		end

		if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 500, 800, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
			return FALSE
		end
		doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
            doRemoveItem(item.uid,1)

	elseif(item.itemid == greatManaPot) then
		if (not(isSorcerer(cid) or isDruid(cid)) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
			doCreatureSay(cid, "This potion can only be consumed by sorcerers and druids of level 80 or higher.", TALKTYPE_ORANGE_1)
			return TRUE
		end

		if(doTargetCombatMana(0, cid, 200, 350, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
			return FALSE
		end
		doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
            doRemoveItem(item.uid,1)
	end

	return TRUE
end
 
Code:
local emptyFlaskId = 7636
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local i = 0
	local emptyFlasks = getPlayerItemCount(cid, emptyFlaskId)
	for i = 1, emptyFlasks do
		doPlayerRemoveItem(cid, emptyFlaskId, 1)
	end
	doPlayerAddMoney(cid, (emptyFlasks * 5))
	return TRUE
end
gl hf.
 
Last edited:
PHP:
local emptyFlaskId = 7636
local priceFlask = 5

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local emptyFlasks = getPlayerItemCount(cid, emptyFlaskId)
	for i=1, emptyFlasks do
		doPlayerRemoveItem(cid, emptyFlaskId, 1)
	end
	doPlayerAddMoney(cid, (emptyFlasks * priceFlask))
	return TRUE
end

:eek:
 
It doesn't work, because, as I said, "doRemoveItem" do not work with 2+ itens that are not agroupable.
I think we must use the function "for i =...", something like that.

Someone please?

Actually doPlayerRemoveItem would take the number stated in function.
 
Back
Top