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

TalkAction Level Points System

Zysen

=)
Joined
Sep 18, 2010
Messages
2,270
Reaction score
170
Location
Bosnia & Herzegovina
#Introduction

This is a basic system in which you gain points by leveling your character.These points can be distributed to increase your "stats".


Tested in : TFS 0.3.6 , 8.60

#Credits to:

MaXwEllDeN
Me (Zysen)



jCM_lu.png

UyHBo5.png

-DpUM.png



#Installation


@Creaturescripts

Go to data/creaturescripts/scripts and find a LUA file called login.lua,then add this :


Code:
		registerCreatureEvent(cid, "PointSystem")


After that,go to data/creaturescripts/scripts,copy a LUA file,rename it to PointsSystem. Enter the file and delete the content. Then copy-paste this:


Code:
local VocPoints = {
        [1] = 3,
        [2] = 3,
        [3] = 3,
        [4] = 5,
        [5] = 5,
        [6] = 5,
        [7] = 5,
        [8] = 8,
        }
function onAdvance(cid, skill, oldlevel, newlevel)
        if not (VocPoints[getPlayerVocation(cid)]) then
                return true
        end
        if (skill == 8) then
                if (getPlayerStorageValue(cid, 14573) < newlevel) then
                        if (getPlayerStorageValue(cid, 14574) < 0) then
                                setPlayerStorageValue(cid, 14574, 0)
                                setPlayerStorageValue(cid, 14573, 0)
                        end

                        setPlayerStorageValue(cid, 14573, newlevel)
                        setPlayerStorageValue(cid, 14574, getPlayerStorageValue(cid, 14574) + (newlevel - oldlevel) * (VocPoints[getPlayerVocation(cid)]))
                        doSendAnimatedText(getThingPos(cid), "+" .. (newlevel - oldlevel) * (VocPoints[getPlayerVocation(cid)]), 18)
                end
        end

        return true
end


Now go to data/creaturescripts ,and open creaturescripts.xml ! Then add this :


Code:
	<event type="advance" name="PointSystem" event="script" value="PointsSystem.lua"/>



@Talkaction


Go to data/talkactions/scripts and copy a LUA file and rename it to PointsSystem. Then open it,delete the content,and copy-paste this :


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 = 4, vl = 2, nm = "Mana Points"},
        ["magic"] = {np = 30, vl = 1, nm = "Magic Level"},
        ["shielding"] = {np = 40, vl = 1, nm = "Shielding Skill"},
        ["sword"] = {np = 20, vl = 1, nm = "Sword Skill"},
        ["axe"] = {np = 20, vl = 1, nm = "Axe Skill"},
        ["club"] = {np = 20, vl = 1, nm = "Club Skill"},
        ["distance"] = {np = 20, 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] == "vitalidade") 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


Now go to data/talkactions, and open talkactions.xml ! Then add this :


Code:
	<talkaction words="!points" event="script" value="PointsSystem.lua"/>



#Configuration


In the file PointsSystem.lua , data/creaturescripts/scripts :

Code:
local VocPoints = {
        [1] = 3,
        [2] = 3,
        [3] = 3,
        [4] = 5,
        [5] = 5,
        [6] = 5,
        [7] = 5,
        [8] = 8,
        }

Between the brackets is the id of the vocation,and the numbers next to the vocation ids are the amount of points that players earn per level.

In the file PointsSystem.lua, data/talkactions/scripts:


Code:
local VocPoints = {
        [1] = 3,
        [2] = 3,
        [3] = 3,
        [4] = 5,
        [5] = 5,
        [6] = 5,
        [7] = 5,
        [8] = 8,
        }


Between the brackets is the id of the vocation,and the numbers next to the vocation ids are the amount of points that players earn per level.



Code:
        local attributes = {
                ["vitality"] = {np = 2, vl = 5, nm = "Hit Points"}, -- Need to use two points to add 10 hp
                ["energy"] = {np = 4, vl = 2, nm = "Mana Points"},
                ["magic"] = {np = 30, vl = 1, nm = "Magic Level"},
                ["shielding"] = {np = 40, vl = 1, nm = "Shielding Skill"},
                ["sword"] = {np = 20, vl = 1, nm = "Sword Skill"},
                ["axe"] = {np = 20, vl = 1, nm = "Axe Skill"},
                ["club"] = {np = 20, vl = 1, nm = "Club Skill"},
                ["distance"] = {np = 20, vl = 1, nm = "Distance Skill"},
                }

np - the amount of points that you need to spend
vl - how much will it heal

Example :

Code:
["vitality"] = {np = 2, vl = 5, nm = "Hit Points"}

With 2 points you'll get 5 HP.




/Zysen.
 
Last edited:
Going to test it out on my Realmap ot i have! maybe it will give the players more reason to levelup!
 
it works in my rl map but when players say .!points add blahblahblah it doesn't give them anything
 
Yeah sofar I have a problem with "magic" it does not work! takes the points but nothing else :/. My players LOVE this but alot of people use mages so magic would really help :p
 
You should use lib instead of doubling config. And I'm not sure about balance but thats thing for people using it to customize to their needs
 
I get this error in the talkaction script:
Code:
Attemp to compare string with number
Line:
Code:
if (getPlayerStorageValue(cid, 14574) < 0) then

(when players say !points)

EDIT:
I get that error from creaturescript/PointsSystem.lua too.
 
I got this error...
What should I do?

Code:
data/talkactions/scripts/PointsSystem.lua:42: attempt to index local 'p2' (a nil value)
[11/07/2012 17:37:18] stack traceback:
[11/07/2012 17:37:18] 	data/talkactions/scripts/PointsSystem.lua:42: in function <data/talkactions/scripts/PointsSystem.lua:11>
 
I had posted a fixed version of this script somewhere in the support section, with working mlvl and fixed small bugs, Zysen honestly just ctrl+c ctrl+v Max post from another forum, you don't deserve any credit for that.
 
I get this error in the talkaction script:
Code:
Attemp to compare string with number
Line:
Code:
if (getPlayerStorageValue(cid, 14574) < 0) then

(when players say !points)

EDIT:
I get that error from creaturescript/PointsSystem.lua too.

help pls.
 
Lol, this script is good, and 1 year ago, i create a server with another script, Like WOW but tibia. I put it online, but nobody enter to play and some problems...

From where take this idea?! I make it, but with SQL functions, better to save it
 
this system does not work I do not make any mistake just in top level does not give me the point!

help me or pass it to mod ;/ plz help
 
Using TFS 0.3.7 (Crying Damson)

For some reason it's only giving my Admin character points every levelup, but he cannot use the command "!points".... but my regular character can use "!points" but never gains any points when leveling up... this makes no since to me... if you go into the database and add point for the regular char to use "!points add,vitiality,5" it works, altought the addition of any HP or MANA and even the Magic Level just does not work, & it will take your points away but not upgrade the skill/object(hp or mana). But the other skills all work.. Any thought's?
 
Back
Top