• 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 Requesting Potions Healling HP in "%"

GeKirAh

Banned User
Joined
Feb 14, 2009
Messages
163
Reaction score
0
Location
Brazil !!!
I'm requesting, New LUA Script for potions,
Be cause with my Ot-Server I will put new promotions,
And I think is necessary to configure Potions!!!


Need new functions for health potions:
-Health Potions will Heall Hp in % !!!
*Great Health potion: Healling 40% HP
*Ultimate Health Potion: Healling 50% HP

{Need all scripts to I can modify vocations
to use them, exemple: UHP: to vocation 12}
I need this script, to I configure How many %
and to I configure vocations to use them


Thx for atention!!!
 
PHP:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

	local MIN = getCreatureMaxHealth(cid) * .4 -- 40%
	local MAX = getCreatureMaxHealth(cid) * .4 -- 40%
	local EMPTY_POTION = 7635

	if isPlayer(itemEx.uid) == FALSE then
		return FALSE
	end

	if hasCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return TRUE
	end

	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
	end

	if doCreatureAddHealth(itemEx.uid, math.random(MIN, MAX)) == LUA_ERROR then
		return FALSE
	end

	doAddCondition(cid, exhaust)
	doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
	doTransformItem(item.uid, EMPTY_POTION)
	return TRUE
end

works with 0.3
 
Thxx A loot, but where I put the vocations to use them? :P

in the above script
PHP:
  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
    end

if the player is NOT a knight it will return that error, so you can change that to like isDruid, isSorcerer, isPlaladin, etc.. the level requirement is there as well
 
This way you can easily add new vocations etc.
PHP:
local config = {
    percentage = 0.20, -- 20 percentage
    levelRequirement = 130,
    allowedVocations = {
        2, -- druid
        6 -- elder druid
    }
}

local EMPTY_POTION = 7635
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
    -- Check if player has a proper vocation.
    if isInArray(config.allowedVocations, getPlayerVocation(cid)) == FALSE then
        doPlayerSendCancel(cid, "Your vocation is not able to use this potion.")
        return TRUE
    end
    
    -- Check if player has a proper level.
    if getPlayerLevel(cid) < config.levelRequirement then
        doPlayerSendCancel(cid, "You need to be atleast level " .. config.levelRequirement .. " to use this potion.")
        return TRUE
    end
    
    -- Check if the health was added.
    if doCreatureAddHealth(itemEx.uid, (getCreatureMaxHealth(cid) * config.percentage)) == LUA_ERROR then
        return FALSE
    end
    
    doAddCondition(cid, exhaust)
    doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
    doTransformItem(item.uid, EMPTY_POTION)
    return TRUE
end
 
Back
Top