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

Lua how to fix my pot

arheon

Own3d PlAx.'?
Joined
Aug 31, 2009
Messages
92
Reaction score
3
Hello ppl.
I made a infity mana potion for my ot (with script of manarune) but i cant get it work correctly , beacuse when i put it in hotkeys it look something like that and it cant be used :
infi.png

inffffi.png


But if i click it manualy it works perfect!
manapotion.png

So it works good , but i have only problem with that thing and no idea how to solve it.
Here is script of that potion :
PHP:
-----------------------------------
------- Universal Mana Rune -------
----------- Version 1.1 -----------
------ Script By: OsoSangre -------
-----------------------------------
--Created to make the script easy to manipulate
--If used without using server potion exhaust (EX: potExhaust = false), it will work regardless of server
--Remember, true = yes, false = no, in the config

function onUse(cid, item, frompos, item2, topos)
    --Config
    local reqml = 0         --Magic Level required to use it
    local reqlvl = 100       --Character Level required to use it
    local potExhaust = false    -- causes exhaust like potions (false creates seperate exhaust for mana rune)
    local ani = 1          --Animation to be sent to player when used (these can be found in your global.lua; search for CONST_ME_)
    --If you dont want it to give health, set both to 0
    local minkinMana = 100      --Minimum amount of Mana to be added for knight
    local maxkinMana = 150     --Maximum amount of Mana to be added for knight
    local minpalMana = 280      --Minimum amount of Mana to be added for pally
    local maxpalMana = 320      --Maximum amount of Mana to be added for pally
    local mindruMana = 350      --Minimum amount of Mana to be added for druid
    local maxdruMana = 450      --Maximum amount of health to be added for druid
    local minsorMana = 350  --Minimum amount of health to be added for sorcerer
    local maxsorMana = 450  --Maximum amount of health to be added for sorcerer
    --If youre not using potion exhaust (potExhaust = false) edit the following the way youd like
    local storeValue = 50       --The storage value that will be used for exhaust if you have potexhaust to false
    local exhaustTime = 1       --Exhaust in seconds
    local infinite = true      --Will it cause rune to lose charges
    local canUseInPz = true    --If true, mana rune may be used in PZ, otherwise, it will not work.

    local player_say = "Aaahhh..."   --What player says after successfully using the mana rune
    local error_ml = "You don't have the required magic level to use that rune."    --What the cancel says when ml is too low
    local error_lvl = "You don't have the required level to use this potion."   --What the cancel says when level is too low
    local error_notPlayer = "You can only use this potion on players."        --What the cancel says when you try to use it on something not a player
    local error_exhaust = "You are exhausted."                  --What the cancel says when you are exhausted
    local error_pz = "You may not use this in Protected Zones." --What the cancel says when you are in PZ and canUseInPz is false
    ------------------------------------------- DO NOT EDIT BELOW THIS LINE!! -------------------------------------------

    ---------------------------START Check for Errors--------------------------------
    --If doesnt allow use in PZ, send poof and cancel message
    if canUseInPz == false  and getTilePzInfo(getPlayerPosition(cid)) == 1 then
        doSendMagicEffect(frompos, CONST_ME_POFF)
        doPlayerSendCancel(cid, error_pz)
        return 0
    end
    --If not high enough level, send poof and cancel message
    if getPlayerLevel(cid) < reqlvl then
        doSendMagicEffect(frompos, CONST_ME_POFF)
        doPlayerSendCancel(cid, error_lvl)
        return 0
    end

    --If ml is too low, send poof and cancel message
    if getPlayerMagLevel(cid) < reqml then
        doSendMagicEffect(frompos, CONST_ME_POFF)
        doPlayerSendCancel(cid, error_ml)
        return 0
    end

    --If its not a player, send poof and cancel message
    if item2.uid < 1 then
        doSendMagicEffect(frompos, CONST_ME_POFF)
        doPlayerSendCancel(cid, error_notPlayer)
        return 0
    end

    --Check if exhausted
    if potExhaust == false then --If not using Potion Exhaust
        if exhaust(cid, storeValue, exhaustTime) == 0 then
            doSendMagicEffect(frompos, CONST_ME_POFF)
            doPlayerSendCancel(cid, error_exhaust)
            return 0
        end
    else --If you are using potion exhaust
        if hasCondition(cid, CONDITION_EXHAUSTED) == 1 then
            doPlayerSendCancel(cid, error_exhaust)
            return 0
        end
    end

    ---------------------------END Check for Errors--------------------------------
     if isPaladin(cid) then
    	doCreatureAddMana(cid, math.random(minpalMana, maxpalMana))
        doCreatureSay(cid, "Aaaah....", TALKTYPE_ORANGE_2)
    	doSendMagicEffect(topos, ani)
     elseif isKnight(cid) then
	doCreatureAddMana(cid,math.random(minkinMana,maxkinMana))
        doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_2)
	doSendMagicEffect(topos, ani)
     elseif isDruid(cid) then
	doCreatureAddMana(cid,math.random(mindruMana,maxdruMana))
        doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_2)
	doSendMagicEffect(topos, ani)
     elseif isSorcerer(cid) then
	doCreatureAddMana(cid,math.random(minsorMana,maxsorMana))
        doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_2)
	doSendMagicEffect(topos, ani)
     end
end

--Exhaust System created by Alreth
--Edited by OsoSangre
function exhaust(cid, storeValue, exhaustTime)
    local newExhaust = os.time()
    local oldExhaust = getPlayerStorageValue(cid, storeValue)
    if (oldExhaust == nil or oldExhaust < 0) then
        oldExhaust = 0
    end
    if (exhaustTime == nil or exhaustTime < 0) then
        exhaustTime = 1
    end
    diffTime = os.difftime(newExhaust, oldExhaust)
    if (diffTime >= exhaustTime) then
        setPlayerStorageValue(cid, storeValue, newExhaust)
        return 1
    else
        return 0
    end
end
PHP:
	<action itemid="7440" script="liquids/infity_mana_potion.lua" allowfaruse="1"/>
rep + for help
 
Last edited:
What do you mean ?
I cant put in hotkey use with.
Its same like when u put gold coin to hotkeys. You cant use it on other ppl , or use on yourself.
You can just use it by click double mouse.
 
Change

Code:
    if item2.uid < 1 then
        doSendMagicEffect(frompos, CONST_ME_POFF)
        doPlayerSendCancel(cid, error_notPlayer)
        return 0
    end

for

Code:
    if isPlayer(item2.uid) then
        doSendMagicEffect(frompos, CONST_ME_POFF)
        doPlayerSendCancel(cid, error_notPlayer)
        return 0
    end
 
Code:
-----------------------------------
------- Universal Mana Rune -------
----------- Version 1.1 -----------
------ Script By: OsoSangre -------
-----------------------------------
--Created to make the script easy to manipulate
--If used without using server potion exhaust (EX: potExhaust = false), it will work regardless of server
--Remember, true = yes, false = no, in the config

	--Config
	local reqml = 0         --Magic Level required to use it
	local reqlvl = 100       --Character Level required to use it
	local potExhaust = false    -- causes exhaust like potions (false creates seperate exhaust for mana rune)
	local ani = 1          --Animation to be sent to player when used (these can be found in your global.lua; search for CONST_ME_)
	--If you dont want it to give health, set both to 0
	local minkinMana = 100      --Minimum amount of Mana to be added for knight
	local maxkinMana = 150     --Maximum amount of Mana to be added for knight
	local minpalMana = 280      --Minimum amount of Mana to be added for pally
	local maxpalMana = 320      --Maximum amount of Mana to be added for pally
	local mindruMana = 350      --Minimum amount of Mana to be added for druid
	local maxdruMana = 450      --Maximum amount of health to be added for druid
	local minsorMana = 350  --Minimum amount of health to be added for sorcerer
	local maxsorMana = 450  --Maximum amount of health to be added for sorcerer
	--If youre not using potion exhaust (potExhaust = false) edit the following the way youd like
	local storeValue = 50       --The storage value that will be used for exhaust if you have potexhaust to false
	local exhaustTime = 1       --Exhaust in seconds
	local infinite = true      --Will it cause rune to lose charges
	local canUseInPz = true    --If true, mana rune may be used in PZ, otherwise, it will not work.

	local player_say = "Aaahhh..."   --What player says after successfully using the mana rune
	local error_ml = "You don't have the required magic level to use that rune."    --What the cancel says when ml is too low
	local error_lvl = "You don't have the required level to use this potion."   --What the cancel says when level is too low
	local error_notPlayer = "You can only use this potion on players."        --What the cancel says when you try to use it on something not a player
	local error_exhaust = "You are exhausted."                  --What the cancel says when you are exhausted
	local error_pz = "You may not use this in Protected Zones." --What the cancel says when you are in PZ and canUseInPz is false

--Exhaust System created by Alreth
--Edited by OsoSangre
local function exhaust(cid, storeValue, exhaustTime)
	local newExhaust = os.time()
	local oldExhaust = getPlayerStorageValue(cid, storeValue)
	if(not oldExhaust or oldExhaust < 0) then
		oldExhaust = FALSE
	end
	if(not exhaustTime or exhaustTime < 0) then
		exhaustTime = TRUE
	end
	local diffTime = os.difftime(newExhaust, oldExhaust)
	if(diffTime >= exhaustTime) then
		setPlayerStorageValue(cid, storeValue, newExhaust)
		return TRUE
	else
		return FALSE
	end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	--If doesnt allow use in PZ, send poof and cancel message
	if(not(canUseInPz) and getTilePzInfo(getCreaturePosition(cid)) == TRUE) then
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendCancel(cid, error_pz)
		return FALSE
	--If not high enough level, send poof and cancel message
	elseif getPlayerLevel(cid) < reqlvl then
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendCancel(cid, error_lvl)
		return FALSE
	--If ml is too low, send poof and cancel message
	elseif getPlayerMagLevel(cid) < reqml then
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendCancel(cid, error_ml)
		return FALSE
	end
	--Check if exhausted
	if(not(potExhaust) and not(exhaust(cid, storeValue, exhaustTime))) then --If not using Potion Exhaust
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendCancel(cid, error_exhaust)
		return FALSE
	elseif(getCreatureCondition(cid, CONDITION_EXHAUSTED) == TRUE) then --If you are using potion exhaust
		doPlayerSendCancel(cid, error_exhaust)
		return FALSE
	end

	doCreatureAddMana(cid, math.random(isPaladin(cid) == TRUE and minpalMana or isKnight(cid) == TRUE and minkinMana or isDruid(cid) == TRUE and mindruMana or isSorcerer(cid) == TRUE and minsorMana, isPaladin(cid) == TRUE and maxpalMana or isKnight(cid) == TRUE and maxkinMana or isDruid(cid) == TRUE and maxdruMana or isSorcerer(cid) == TRUE and maxsorMana))
	doCreatureSay(cid, "Aaaah....", TALKTYPE_ORANGE_1)
	doSendMagicEffect(toPosition, ani)
end
 
Back
Top