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

Solved Level points system

knighters god

Active Member
Joined
Feb 14, 2009
Messages
166
Solutions
1
Reaction score
40
Found the script posted by Zysen.

I'm hosting on Tfs 0.3.6.
This script works great when I want to use the points I get, except when I want to add magic levels.
It does not add any magic levels.
Code:
local VocPoints = {
    [1] = 3,
    [2] = 3,
    [3] = 3,
    [4] = 5,
    [5] = 5,
    [6] = 5,
    [7] = 5,
    [8] = 8,
    }
function onSay(cid, words, param)
    if not (VocPoints[getPlayerVocation(cid)]) then
        return false
    end

    local param = param:lower()
    local p2 = string.explode(param, ",")
    if (getPlayerStorageValue(cid, 14574) < 0) then
        setPlayerStorageValue(cid, 14574, 0)
    end

    local skillids = {
        ["shielding"] = 5,
        ["sword"] = 2,
        ["axe"] = 3,
        ["club"] = 1,
        ["distance"] = 4
        }

    local attributes = {
        ["vitality"] = {np = 2, vl = 5, nm = "Hit Points"}, -- Need to use two points to add 10 hp
        ["energy"] = {np = 2, vl = 3, nm = "Mana Points"},
        ["magic"] = {np = 20, vl = 1, nm = "Magic Level"},
        ["shielding"] = {np = 10, vl = 1, nm = "Shielding Skill"},
        ["sword"] = {np = 10, vl = 1, nm = "Sword Skill"},
        ["axe"] = {np = 10, vl = 1, nm = "Axe Skill"},
        ["club"] = {np = 10, vl = 1, nm = "Club Skill"},
        ["distance"] = {np = 10, vl = 1, nm = "Distance Skill"},
        }
    if (param == "check") then
        doPlayerPopupFYI(cid, "Level Points System\n\nPoints available: ".. getPlayerStorageValue(cid, 14574) .."\nPoints per level: ".. VocPoints[getPlayerVocation(cid)])
    elseif (p2[1] and p2[1] == "add") and (attributes[p2[2]]) and (tonumber(p2[3])) then
        if (getPlayerStorageValue(cid, 14574) < tonumber(p2[3]) * attributes[p2[2]].np) then
            doPlayerSendCancel(cid, "You do not have enough points to distribute!")
            return doSendMagicEffect(getThingPos(cid), 2)
        end

        if (p2[2] == "vitality") then
            setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + attributes[p2[2]].vl * tonumber(p2[3]))
            doCreatureAddHealth(cid, attributes[p2[2]].vl * tonumber(p2[3]))
        elseif (p2[2] == "energy") then
            setCreatureMaxMana(cid, getCreatureMaxMana(cid) + attributes[p2[2]].vl * tonumber(p2[3]))
            doCreatureAddMana(cid, attributes[p2[2]].vl * tonumber(p2[3]))
        elseif(skillids[p2[2]]) then
            for a = 1, tonumber(p2[3]) do
                doPlayerAddSkillTry(cid, skillids[p2[2]], getPlayerRequiredSkillTries(cid, skillids[p2[2]], getPlayerSkillLevel(cid, skillids[p2[2]]) + 1) - getPlayerSkillTries(cid, skillids[p2[2]]), false)
            end
        end


        doSendMagicEffect(getThingPos(cid), 29)
        doSendMagicEffect(getThingPos(cid), 30)
        doSendAnimatedText(getThingPos(cid), "-" .. tonumber(p2[3]) * attributes[p2[2]].np, 180)
        setPlayerStorageValue(cid, 14574, getPlayerStorageValue(cid, 14574) - tonumber(p2[3]) * attributes[p2[2]].np)
    else
        local msgx = ""
        for i, v in pairs(attributes) do
            local add = (v.np > 1) and "s" or ""
            msgx = msgx .. string.upper(i:sub(1,1)) .. i:sub(2, #i) .. " - ".. v.np .. " point".. add .. " ~ " .. v.vl .. " ".. v.nm .. "\n"
        end
        doPlayerPopupFYI(cid, "Level Points System\n\nPoints needed to increase stats:\n\n".. msgx .. "\nExample of use: ".. words .." add, vitality, 5\n\nPoints available: ".. getPlayerStorageValue(cid, 14574))
    end

    return true
end
If anyone could help me I would appreciate it very much!
 
Code:
elseif p2[2] == "magic" then
     for m = 1, tonumber(p2[3]) do
         doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)), false)
     end
 
Code:
elseif p2[2] == "magic" then
     for m = 1, tonumber(p2[3]) do
         doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)), false)
     end
This works like a charm!
Thank you so much <3
 
Back
Top