• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

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

nyebez

Banned User
Joined
Oct 27, 2012
Messages
30
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
 

emil92b

Intermediate OT User
Joined
Aug 21, 2013
Messages
323
Solutions
13
Reaction score
123
Location
Sweden
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
 

Levi999x

AoT
Joined
Dec 14, 2017
Messages
2,169
Solutions
58
Reaction score
1,406
Location
Germany
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
 
OP
OP
N

nyebez

Banned User
Joined
Oct 27, 2012
Messages
30
Reaction score
1
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:
Top