• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Potion

Spo teh pro

New Member
Joined
Jan 3, 2008
Messages
319
Reaction score
1
Hello folks :D

I'm searching for a health potion script which is based on level and magic level (as UH in old times)
I'm sure anyone already has something like this but I couldn't find it with search function so I thought I'm going to ask here

Thank you in advance <3:p

- - - Updated - - -

Code:
local EMPTY_POTION = 7635 
local CHARGES = 3 
local EXHAUST_TIME = 1 -- Exhaust time in seconds. 
local STORE_VALUE = 3068 -- Value where exhaust is saved. 

function onUse(cid, item, fromPosition, itemEx, toPosition) 
     
    local level = getPlayerLevel(itemEx.uid) 
    local MIN = ((15((level)-8)+185)*(.60)) 
    local MAX = ((15((level)-8)+185)*(.75))  
     
     
    if isPlayer(itemEx.uid) == FALSE then 
        return FALSE 
    end 
     
    if exhaust(cid, STORE_VALUE, EXHAUST_TIME) > 0 then 
     
     
        if((not(isKnight(itemEx.uid)) or getPlayerLevel(itemEx.uid) < 130) and getPlayerCustomFlagValue(itemEx.uid, PlayerCustomFlag_GamemasterPrivileges) == FALSE) then 
        doCreatureSay(itemEx.uid, "Only knights of level 130 or above may drink this fluid.", TALKTYPE_ORANGE_1) 
        return TRUE 
         
        else  
            if doCreatureAddHealth(itemEx.uid, math.random(MIN, MAX)) == LUA_ERROR then 
                    return FALSE 
            end 
             
             
            doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE) 
            doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1) 
     
            if(item.actionid == 0) then 
                doSetItemActionId(item.uid, 99 + CHARGES) 
                return TRUE 
            end 

            local _charges = item.actionid - 100 
            if(_charges > 1) then 
                doSetItemActionId(item.uid, item.actionid - 1) 
            else 
                doRemoveItem(item.uid) 
            end 
        end 
             
    else 
        doPlayerSendCancel(cid, "You are exhausted.") 
    end 
    return 1 
end

I got this script now. Didn't try if it works (using TFS crying damson 0.3.8 or smth) I'm at work at the moment.
Question is. Could anyone explain the numbers in the brackets how to calculate?
I don't understand that :D

Also; Is magic level already included? because that's important for me too :p

Thank you
 
Last edited:
Well, that is a ultimate health potion script man, that doesn't have lvl or magic level... I can help you, but can you PM me?, im not at home so when i arrive home and see your PM i will remember that you need help
 
Yeah I understand ofcourse. But its should be possible I think tho I'm really bad at scripting and don't understand where to change the lines. I could also post my current ultimate healing script and maybe you can just add that "aahhh" appears and only knights over level 130 for example can use it
 
Here we are ;)
LUA:
local magicneeded = 10 -- magic level to use the item 
function onUse(cid, item, frompos, item2, topos)
if getPlayerMagLevel(cid) => 10 then
doSendMagicEffect(topos,1)
mini = (getPlayerLevel(cid) * 2.5 + getPlayerMagLevel(cid) * 3) * 4.6 - 25
maxi = (getPlayerLevel(cid) * 2.5 + getPlayerMagLevel(cid) * 3) * 5.2
 
    if doCreatureAddHealth(cid, math.random(mini, maxi)) == LUA_ERROR  then
        return FALSE
    end
else
        doPlayerSendCancel(cid, 'you need magic level " .. magic .. " to use this health.')
end
    return true
end

Not tested
 
Code:
[30/06/2013 02:01:16] [Error - LuaScriptInterface::loadFile] data/actions/scripts/liquids/uhp.lua:3: 'then' expected near '='
[30/06/2013 02:01:16] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/liquids/uhp.lua)
[30/06/2013 02:01:16] data/actions/scripts/liquids/uhp.lua:3: 'then' expected near '='
 
Okay mate, Sirion_mido got me an adventage here it is HIS script but i correct the error

LUA:
function onUse(cid, item, frompos, item2, topos)

local magicneeded = 10 -- magic level to use the item 
if getPlayerMagLevel(cid) >= magicneeded then
doSendMagicEffect(topos,1)
mini = (getPlayerLevel(cid) * 2.5 + getPlayerMagLevel(cid) * 3) * 4.6 - 25
maxi = (getPlayerLevel(cid) * 2.5 + getPlayerMagLevel(cid) * 3) * 5.2
 
    if doCreatureAddHealth(cid, math.random(mini, maxi)) == LUA_ERROR  then
        return FALSE
    end
else
        doPlayerSendCancel(cid, 'you need magic level " .. magic .. " to use this health.')
end
    return true
end

PD!!: The script is made by Sirion_mido, please don't say that i'm a thief i just correct the error
 
How can i change
" [8473] = {empty = 7635, splash = 42, health = {3500, 4000}, level = 2500, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion "

into

" function onUse(cid, item, frompos, item2, topos)

local magicneeded = 10 -- magic level to use the item
if getPlayerMagLevel(cid) >= magicneeded then
doSendMagicEffect(topos,1)
mini = (getPlayerLevel(cid) * 2.5 + getPlayerMagLevel(cid) * 3) * 4.6 - 25
maxi = (getPlayerLevel(cid) * 2.5 + getPlayerMagLevel(cid) * 3) * 5.2

if doCreatureAddHealth(cid, math.random(mini, maxi)) == LUA_ERROR then
return FALSE
end
else
doPlayerSendCancel(cid, 'you need magic level " .. magic .. " to use this health.')
end
return true
end "

can i just add it?
 
Back
Top