• 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 custom health potion

amr shalapy

Banned User
Joined
Aug 28, 2014
Messages
122
Reaction score
8
i was wondering if it possible to edit this script i have tried once but it's not working I just wanted to add some options at cfg,but I didn't know how to add it in the main code
here it's
Lua:
local cfg = {
   level = 16, ---here the level is not working i want if u Less than the required leve can't be used and send text message "you can't use this only the required level or higher"
   magic = 16, ----also same with level
   min = 1750,
   max = 1800,
Vocation={26} ---and custom vocation only can use
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if isCreature(itemEx.uid) then
     mini = (getPlayerLevel(cid) * cfg.level + getPlayerMagLevel(cid) * cfg.magic + cfg.min)
     maxi = (getPlayerLevel(cid) * cfg.level + getPlayerMagLevel(cid) * cfg.magic + cfg.max)
     doCreatureAddHealth(itemEx.uid, math.random(mini, maxi))
     doSendMagicEffect(toPosition, 12)
     doRemoveCondition(cid, 32)
     doRemoveItem(item.uid, 1)
   else
     doCreatureSay(cid, "This rune can only be used on creatures.", TALKTYPE_ORANGE_1)
   end
   return true
end
 
Last edited:
Solution
i was wondering if it possible to edit this script i have tried once but it's not working I just wanted to add some options at cfg,but I didn't know how to add it in the main code
here it's
Lua:
local cfg = {
   level = 16, ---here the level is not working i want if u Less than the required leve can't be used and send text message "you can't use this only the required level or higher"
   magic = 16, ----also same with level
   min = 1750,
   max = 1800,
Vocation={26} ---and custom vocation only can use
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if isCreature(itemEx.uid) then
     mini = (getPlayerLevel(cid) * cfg.level + getPlayerMagLevel(cid) * cfg.magic + cfg.min)
     maxi = (getPlayerLevel(cid) * cfg.level +...
i was wondering if it possible to edit this script i have tried once but it's not working I just wanted to add some options at cfg,but I didn't know how to add it in the main code
here it's
Lua:
local cfg = {
   level = 16, ---here the level is not working i want if u Less than the required leve can't be used and send text message "you can't use this only the required level or higher"
   magic = 16, ----also same with level
   min = 1750,
   max = 1800,
Vocation={26} ---and custom vocation only can use
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if isCreature(itemEx.uid) then
     mini = (getPlayerLevel(cid) * cfg.level + getPlayerMagLevel(cid) * cfg.magic + cfg.min)
     maxi = (getPlayerLevel(cid) * cfg.level + getPlayerMagLevel(cid) * cfg.magic + cfg.max)
     doCreatureAddHealth(itemEx.uid, math.random(mini, maxi))
     doSendMagicEffect(toPosition, 12)
     doRemoveCondition(cid, 32)
     doRemoveItem(item.uid, 1)
   else
     doCreatureSay(cid, "This rune can only be used on creatures.", TALKTYPE_ORANGE_1)
   end
   return true
end
Lua:
local cfg = {
    level = 16, -- minimum level to use item
    magic = 16, -- minimum magic level to use item
    min = 1750,
    max = 1800,
    vocation = {26} -- {1, 2, 3} -- vocations that can use item
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    
    -- check vocation
    if not isInArray(cfg.vocation, getPlayerVocation(cid)) then
        doCreatureSay(cid, "You do not have the required vocation to use this item.", TALKTYPE_ORANGE_1)
        return true
    end
    
    -- check level
    local player_level = getPlayerLevel(cid)
    if player_level < cfg.level then
        doCreatureSay(cid, "You can't use this. Only players of level " .. cfg.level .. " or higher can use this item.", TALKTYPE_ORANGE_1)
        return true
    end
    
    -- check magic level
    local player_magic_level = getPlayerMagLevel(cid)
    if player_magic_level < cfg.magic then
        doCreatureSay(cid, "You can't use this. Only players with magic level " .. cfg.magic .. " or higher can use this item.", TALKTYPE_ORANGE_1)
        return true
    end
    
    -- check that item is being used on a creature.
    if not isCreature(itemEx.uid) then
        doCreatureSay(cid, "This rune can only be used on creatures.", TALKTYPE_ORANGE_1)
        return true
    end
    
    -- heal target, send magic effect, remove condition, remove item
    local mini = (player_level * cfg.level + player_magic_level * cfg.magic + cfg.min)
    local maxi = (player_level * cfg.level + player_magic_level * cfg.magic + cfg.max)
    doCreatureAddHealth(itemEx.uid, math.random(mini, maxi))
    doSendMagicEffect(toPosition, 12)
    doRemoveCondition(cid, 32)
    doRemoveItem(item.uid, 1)
    return true
end
 
Last edited:
Solution
Back
Top