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

Set player skill

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
Need a function to set player skill, and a function to get weapon skill, example:

Code:
local function value(cid)
    local lv = (getPlayerLevel(cid)/2)
    if lv <= 10 then
        return 10
    else
        return lv
    end
    return true
end

local function getWeaponSkill(cid)
    -- if equiped a sword then
        return SKILL_SWORD
    -- elseif equiped a axe then
        return SKILL_AXE
    -- elseif equiped a club then
        return SKILL_CLUB
    end
    return true
end

setPlayerSkill(cid, getWeaponSkill(cid), value)
 
Custom
Code:
skills = {
    [0] = 'fist',
    [1] = 'club',
    [2] = 'sword',
    [3] = 'axe',
    [4] = 'distance',
    [5] = 'shield'
    }
function table.assc_insert(t, i, v)
    if type(t) == 'table' then
        t[i] = v
    end
    return t
end

player = {}
function getAllPlayerSkills(cid)
    for id = 0, #skills do
        table.assc_insert(player, skills[id], getPlayerSkillLevel(cid, id))
    end
end

-- example: getPlayerskills(cid, 'fist')
function getPlayerskills(cid, skill)
    getAllPlayerSkills(cid)
    return player[skill]
end
Just alter the custom functions to use the enums rather than the strings if need be.


050-function.lua
Code:
function doPlayerAddSkill(cid, skill, amount, round)
    if(skill == SKILL__LEVEL) then
        return doPlayerAddLevel(cid, amount, round)
    elseif(skill == SKILL__MAGLEVEL) then
        return doPlayerAddMagLevel(cid, amount)
    end

    return doPlayerAddSkillTry(cid, skill, (getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill)) / getConfigInfo('rateSkill'))
end
 
Last edited:
Back
Top