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

Lua Item atribute by vocation

maikons

Member
Joined
Aug 1, 2015
Messages
227
Reaction score
17
Code:
<item id="11302" name="zaoan helmet"

Is possible onequip if you are mage add 3 ml
if you are knight add +3sword/club/axe
if you are paladin +3 dist

and

Could be possible change
<attribute key="armor" value="9"/>

By vocation?
ex: knight def = 9
paladin def = 8
mage def = 5

Using 0.4
 
Last edited:
i think skills not possible
but armor i think its possible
anyway let me try when have free time
It is possible and the code exists already either i myself have written it or some one else has...

You have to understand that the majority of requested scripts are something someone has seen or heard of.

There are only a handful of unique ideas and those are just either too rediculous or too complex to write.
 
It is possible and the code exists already either i myself have written it or some one else has...

You have to understand that the majority of requested scripts are something someone has seen or heard of.

There are only a handful of unique ideas and those are just either too rediculous or too complex to write.
Wow! One post without cursing or name callings. Congrats! You are really doing progress, keep it up!
 
Oh, ty im searching

i think skills not possible
but armor i think its possible
anyway let me try when have free time


Ty :)

It is possible and the code exists already either i myself have written it or some one else has...

You have to understand that the majority of requested scripts are something someone has seen or heard of.

There are only a handful of unique ideas and those are just either too rediculous or too complex to write.


No man, i just think about it cause i have only 1 legs and need use that to all vocations

Wow! One post without cursing or name callings. Congrats! You are really doing progress, keep it up!

I dont understand what are u talking about xD




---

So guys, u know whats the function to <attribute key="magiclevelpoints" value="1" /> on lua?
Sorry im noob

I tried this base script but need this atribute key

Its right?
Code:
function onEquip(cid, item, slot)
   if (getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 5 or getPlayerVocation(cid) == 9 or getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 6 or getPlayerVocation(cid) == 10 ) then
     addml -= 3
   elseif (getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7 or getPlayerVocation(cid) == 11 ) then
     addml -= 2
   elseif (getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 or getPlayerVocation(cid) == 12 ) then
     addml -= 1
   end
   return true
end

function onDeEquip(cid, item, slot)
   if (getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 5 or getPlayerVocation(cid) == 9 or getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 6 or getPlayerVocation(cid) == 10 ) then
     addml += 3
   elseif (getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7 or getPlayerVocation(cid) == 11 ) then
     addml += 2
   elseif (getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 or getPlayerVocation(cid) == 12 ) then
     addml += 1
   end
   return true
end
 
A+ effort, very good, but that is not how this works :p

Try this out
Code:
-- base vocations
local vocations = {
    -- sorcerer
    [1] = {
        stats = {
            {CONDITION_PARAM_STAT_MAGICLEVEL, 3},
            {CONDITION_PARAM_SKILL_SHIELD, 5}
        },
        buff = false
    },
    -- druid
    [2] = {
        stats = {
            {CONDITION_PARAM_STAT_MAGICLEVEL, 3},
            {CONDITION_PARAM_SKILL_SHIELD, 5}
        },
        buff = false
    },
    -- paladin
    [3] = {
        stats = {
            {CONDITION_PARAM_SKILL_DISTANCE, 9},
            {CONDITION_PARAM_SKILL_SHIELD, 8}
        },
        buff = false
    },
    -- knight
    [4] = {
        stats = {
            {CONDITION_PARAM_SKILL_CLUB, 3},
            {CONDITION_PARAM_SKILL_SWORD, 3},
            {CONDITION_PARAM_SKILL_AXE, 3},
            {CONDITION_PARAM_SKILL_SHIELD, 9}
        },
        buff = false
    }
}
-- Do not edit
---------------------------------------------------
--[[
    Slot Id's of equipment
    1 - helmet
    2 - necklace slot (amulet of loss etc.)
    3 - backpack, bag
    4 - armor
    5 - left hand
    6 - right hand
    7 - legs
    8 - boots
    9 - ring slot
    10 - ammo slot (arrows etc.)
]]
local subId = 7 -- leave this as is or change it correspond with the slot id

local condition = {}

function getBaseVocations(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

for voc, param in pairs(vocations) do
    condition[voc] = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(condition[voc], CONDITION_PARAM_SUBID, subId)
    setConditionParam(condition[voc], CONDITION_PARAM_TICKS, -1)

    for x = 1, #param.stats do
        setConditionParam(condition[voc], param.stats[x][1], param.stats[x][2])
    end

    if param.buff ~= nil then
        setConditionParam(condition[voc], CONDITION_PARAM_BUFF, param.buff)
    end
end

function onEquip(cid, item, slot)
    local slots = getPlayerSlotItem(cid, slot)
    if slots then
        if slots.itemid ~= item.itemid then
            return true
        else
            local playerVocation = getBaseVocations(getPlayerVocation(cid))
            doAddCondition(cid, condition[playerVocation])
        end
    end
    return true
end

function onDeEquip(cid, item, slot)
    doRemoveCondition(cid, CONDITION_ATTRIBUTES, subId)
    return true
end
 
Last edited:
A+ effort, very good, but that is not how this works :p

Try this out
Code:
-- base vocations
local vocations = {
    -- sorcerer
    [1] = {
        stats = {
            {CONDITION_PARAM_STAT_MAGICLEVEL, 3},
            {CONDITION_PARAM_SKILL_SHIELD, 5}
        },
        buff = false
    },
    -- druid
    [2] = {
        stats = {
            {CONDITION_PARAM_STAT_MAGICLEVEL, 3},
            {CONDITION_PARAM_SKILL_SHIELD, 5}
        },
        buff = false
    },
    -- paladin
    [3] = {
        stats = {
            {CONDITION_PARAM_SKILL_DISTANCE, 9},
            {CONDITION_PARAM_SKILL_SHIELD, 8}
        },
        buff = false
    },
    -- knight
    [4] = {
        stats = {
            {CONDITION_PARAM_SKILL_CLUB, 3},
            {CONDITION_PARAM_SKILL_SWORD, 3},
            {CONDITION_PARAM_SKILL_AXE, 3},
            {CONDITION_PARAM_SKILL_SHIELD, 9}
        },
        buff = false
    }
}
-- Do not edit
---------------------------------------------------
--[[
    Slot Id's of equipment
    1 - helmet
    2 - necklace slot (amulet of loss etc.)
    3 - backpack, bag
    4 - armor
    5 - left hand
    6 - right hand
    7 - legs
    8 - boots
    9 - ring slot
    10 - ammo slot (arrows etc.)
]]
local subId = 7 -- leave this as is or change it correspond with the slot id

local condition = {}

function getBaseVocations(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

for voc, param in pairs(vocations) do
    condition[voc] = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(condition[voc], CONDITION_PARAM_SUBID, subId)
    setConditionParam(condition[voc], CONDITION_PARAM_TICKS, -1)

    for x = 1, #param.stats do
        setConditionParam(condition[voc], param.stats[x][1], param.stats[x][2])
    end

    if param.buff ~= nil then
        setConditionParam(condition[voc], CONDITION_PARAM_BUFF, param.buff)
    end
end

function onEquip(cid, item, slot)
    local slots = getPlayerSlotItem(cid, slot)
    if slots then
        if slots.itemid ~= item.itemid then
            return true
        else
            local playerVocation = getBaseVocations(getPlayerVocation(cid))
            doAddCondition(cid, condition[playerVocation])
        end
    end
    return true
end

function onDeEquip(cid, item, slot)
    doRemoveCondition(cid, CONDITION_ATTRIBUTES, subId)
    return true
end

Ty man so much, lol your good, u made a function to select vocation by only one number, i never was think it :D
Ty
 
Back
Top