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

/addskill problem

UchihaClan

Only you can be you
Joined
Oct 25, 2014
Messages
164
Reaction score
33
Hello !

Hi, I got a small problem with the command /addskill I can´t add magic level or any other skill the only skill I can change is level for example /addskill joe,level,+2 works he get 2 lvls but if I say /addskill joe,magic,+2 he dosn´t get anything or if I write /addskill joe,sword,+2.
It is maybe a problem with my skill.lua I use tfs 0.4 client 8.6

Skill.lua
Code:
function onSay(cid, words, param, channel)
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = string.explode(param, ",")
    if(not t[2]) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough params.")
        return true
    end

    local pid = getPlayerByNameWildcard(t[1])
    if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
        return true
    end

    t[2] = t[2]:lower()
    local skill = SKILL_IDS[t[2]]
    if(not skill) then
        local tmp = t[2]:sub(1, 1)
        if(tmp == 'l' or tmp == 'e') then
            skill = SKILL__LEVEL
        elseif(tmp == 'm') then
            skill = SKILL__MAGLEVEL
        else
            skill = tonumber(t[2])
            if(not skill or skill < SKILL_FIRST or SKILL > SKILL__LAST) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Such skill does not exists.")
                return true
            end
        end
    end

    local amount = tonumber(t[3])
    if(not amount or amount == 0) then
        amount = 1
    end

    doPlayerAddSkill(pid, skill, amount, true)
    return true
end
 
Woops forgot to add, script in talcation maybe a problem with that
Code:
 <talkaction log="yes" words="/skill;/addskill" access="5" event="script" value="skill.lua"/>>
 
Try this script, with same talkaction.xml

Script: /data/talkactions/scripts/addskill.lua

HTML:
local function getSkillId(skillName)
    if skillName == "club" then
        return SKILL_CLUB
    elseif skillName == "sword" then
        return SKILL_SWORD
    elseif skillName == "axe" then
        return SKILL_AXE
    elseif skillName:sub(1, 4) == "dist" then
        return SKILL_DISTANCE
    elseif skillName:sub(1, 6) == "shield" then
        return SKILL_SHIELD
    elseif skillName:sub(1, 4) == "fish" then
        return SKILL_FISHING
    else
        return SKILL_FIST
    end
end

local function getExpForLevel(level)
    level = level - 1
    return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
end

function onSay(cid, words, param)
    local player = Player(cid)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local split = param:split(",")
    if split[2] == nil then
        player:sendCancelMessage("Insufficient parameters.")
        return false
    end

    local target = Player(split[1])
    if target == nil then
        player:sendCancelMessage("A player with that name is not online.")
        return false
    end

    -- Trim left
    split[2] = split[2]:gsub("^%s*(.-)$", "%1")

    local count = 1
    if split[3] ~= nil then
        count = tonumber(split[3])
    end

    local ch = split[2]:sub(1, 1)
    for i = 1, count do
        if ch == "l" or ch == "e" then
            target:addExperience(getExpForLevel(target:getLevel() + 1) - target:getExperience(), false)
        elseif ch == "m" then
            target:addManaSpent(target:getVocation():getRequiredManaSpent(target:getBaseMagicLevel() + 1) - target:getManaSpent())
        else
            local skillId = getSkillId(split[2])
            target:addSkillTries(skillId, target:getVocation():getRequiredSkillTries(skillId, target:getSkillLevel(skillId) + 1) - target:getSkillTries(skillId))
        end
    end
    return false
end
 
Back
Top