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

[Action]How to make rune charges remove?

Northnorial

Member
Joined
May 30, 2009
Messages
742
Reaction score
5
Location
Germany
I made this script for a mana rune. But I don't know how to make it removing rune charges. Could you help me? :)

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local level = getPlayerLevel(cid)
local magicbonus = getPlayerMagLevel(cid)
local config = {
      mana = level + magicbonus*5,
      level = 50, 
      mlvl = 3,
      itemid = 2314
}
if (getPlayerItemCount(cid, config.itemid) >= 1) and (getPlayerLevel(cid) >= config.level) and (getPlayerMagLevel(cid) >= config.mlvl) then
	doPlayerAddMana(cid, config.mana)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
	doSendAnimatedText(getCreaturePosition(cid), config.mana, TEXTCOLOR_LIGHTBLUE)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You gained "..config.mana.." mana.")
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You gained "..config.mana.." mana.")
else
	doPlayerSendCancel(cid, "You need level "..config.level.." and magic level "..config.mlvl.." to use this rune.")
end
return TRUE
end
 
Code:
local config = {
      level = 50, 
      mlvl = 3
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local level, magic = getPlayerLevel(cid), getPlayerMagLevel(cid)
	if level >= config.level and magic >= config.mlvl then
		if isPlayer(itemEx.uid) then
			local mana = level + magic * 5
			doPlayerAddMana(itemEx.uid, mana)
			doRemoveItem(item.uid, 1)
			doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
			doSendAnimatedText(toPosition, mana, TEXTCOLOR_LIGHTBLUE)
			doPlayerSendTextMessage(itemEx.uid, MESSAGE_STATUS_SMALL, "You gained " .. mana .. " mana.")
			doPlayerSendTextMessage(itemEx.uid, MESSAGE_STATUS_DEFAULT, "You gained " .. mana .. " mana.")
		else
			doPlayerSendCancel(cid, "You can only use this rune on players.")
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		end
	else
		doPlayerSendCancel(cid, "You need level " .. config.level .. " and magic level " .. config.mlvl .. " to use this rune.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	end
	return true
end
Also make sure you added it in items.xml, as well as charges attribute.
 
I added it like that:
Code:
	<item id="2314" article="a" name="mana rune">
		<attribute key="weight" value="150" />
		<attribute key="charges" value="33" />		
	</item>
But it is removing the whole rune ... any idea?
 
Code:
local config = {
      level = 50, 
      mlvl = 3
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local level, magic = getPlayerLevel(cid), getPlayerMagLevel(cid)
	if level >= config.level and magic >= config.mlvl then
		if isPlayer(itemEx.uid) then
			local mana = level + magic * 5
			doPlayerAddMana(itemEx.uid, mana)
[B][COLOR="Red"]			if item.type > 1 then
				doChangeTypeItem(item.uid, item.type - 1)
			else
				doRemoveItem(item.uid)
			end[/COLOR][/B]
			doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
			doSendAnimatedText(toPosition, mana, TEXTCOLOR_LIGHTBLUE)
			doPlayerSendTextMessage(itemEx.uid, MESSAGE_STATUS_SMALL, "You gained " .. mana .. " mana.")
			doPlayerSendTextMessage(itemEx.uid, MESSAGE_STATUS_DEFAULT, "You gained " .. mana .. " mana.")
		else
			doPlayerSendCancel(cid, "You can only use this rune on players.")
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		end
	else
		doPlayerSendCancel(cid, "You need level " .. config.level .. " and magic level " .. config.mlvl .. " to use this rune.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	end
	return true
end
 
Back
Top