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

TFS 1.X+ help putting vocation to this scrip, thank you

nyebez

New Member
Joined
Oct 27, 2012
Messages
34
Reaction score
1
hello, i found this scrip, and im using it in 7.4 tfs 1.2, potion script, and its working well, but i wanna add vocacion to it, is it possible?



function onUse(cid, item, frompos, itemEx, toPosition)
local health_minimum = 425
local health_maximum = 575

-- Mana Formula Settings END --
if getPlayerLevel(cid) >= 80 then
local health_add = math.random(health_minimum, health_maximum)
doCreatureAddHealth(cid, health_add)
doRemoveItem(item.uid, 1)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER_SAY)
doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
else
doCreatureSay(cid, "This potion can only be consumed by players of level 80 or higher.", TALKTYPE_MONSTER_SAY)
end
return TRUE
end
 
Lua:
local config = {
    ['vocations'] = {1, 2, 5, 6}, -- allowed ids
    ['min'] = 425, ['max'] = 575, -- heal values
}

function onUse(player, item, fromPosition, target, toPosition)
    if not table.contains(config['vocations'], player:getVocation():getId()) then
        player:say("Your vocation cannot use this potion.", TALKTYPE_MONSTER_SAY)
        return false
    elseif player:getLevel() < 80 then
        player:say("This potion can only be consumed by players of level 80 or higher.", TALKTYPE_MONSTER_SAY)
        return false
    end

    item:remove(1)
    toPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:addHealth(math.random(config['min'], config['max']))
    player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    return true
end
 
Lua:
local config = {
    ['vocations'] = {1, 2, 5, 6}, -- allowed ids
    ['min'] = 425, ['max'] = 575, -- heal values
}

function onUse(player, item, fromPosition, target, toPosition)
    if not table.contains(config['vocations'], player:getVocation():getId()) then
        player:say("Your vocation cannot use this potion.", TALKTYPE_MONSTER_SAY)
        return false
    elseif player:getLevel() < 80 then
        player:say("This potion can only be consumed by players of level 80 or higher.", TALKTYPE_MONSTER_SAY)
        return false
    end

    item:remove(1)
    toPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:addHealth(math.random(config['min'], config['max']))
    player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    return true
end

Lua:
local config = {
    level = 80,
    vocation = {1, 2, 5, 6},
    removeItem = false, -- True for remove or false to keep
    minHealing = 100,
    maxHealing = 200
}

function onUse(player, item, fromPosition, target, toPosition)
    
    if player:getLevel() < config.level then
        player:say("This potion can only be consumed by players of level "..config.level.." or higher.", TALKTYPE_MONSTER_SAY)
        return true
    end
    
    if not table.contains(config.vocation, player:getVocation():getId()) then
        player:say("Your vocation cannot use this potion.", TALKTYPE_MONSTER_SAY)
        return true
    end
    
    if not target:isPlayer() then
        player:say("You can use it only on players.", TALKTYPE_MONSTER_SAY)
        return true
    end

    if config.removeFlask then
        item:remove(1)
    end
    
    toPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:addHealth(math.random(config.minHealing, config.maxHealing)
    player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    return true
end

this is mine xD
 
im going to try both, thank you so much guys!
Post automatically merged:

Lua:
local config = {
    level = 80,
    vocation = {1, 2, 5, 6},
    removeItem = false, -- True for remove or false to keep
    minHealing = 100,
    maxHealing = 200
}

function onUse(player, item, fromPosition, target, toPosition)
   
    if player:getLevel() < config.level then
        player:say("This potion can only be consumed by players of level "..config.level.." or higher.", TALKTYPE_MONSTER_SAY)
        return true
    end
   
    if not table.contains(config.vocation, player:getVocation():getId()) then
        player:say("Your vocation cannot use this potion.", TALKTYPE_MONSTER_SAY)
        return true
    end
   
    if not target:isPlayer() then
        player:say("You can use it only on players.", TALKTYPE_MONSTER_SAY)
        return true
    end

    if config.removeFlask then
        item:remove(1)
    end
   
    toPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:addHealth(math.random(config.minHealing, config.maxHealing)
    player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    return true
end

this is mine xD
to change it to mana, i just change
player:addHealth to player:addMana??
 
Last edited:
Back
Top