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

addskill system

yandere

New Member
Joined
Feb 1, 2014
Messages
76
Reaction score
4
who can help me make the system to add new skill points? points you get for each level, we can use them in the distance, fist, sword or club xD you know .. we are giving away points using the command !addskill "swordfighting

0.3.6 tfs
 
Besides few changes like disabling normal gaining skills in sources it can be all done with use of storage (IMO). I don't have much time now to think about it, maybe if I will find some I can try do it. Something like onAdvance adding 1 point to some storage and then you can spend it by talkaction which is reading from this storage. Looks easy, just requires time. Overall interesting idea, I wonder if someone have done this before.
 
Ok, did it really fast, so it can have bugs and it isn't the best method for sure, but it's working.

In creaturescripts.xml add line:
Code:
<event type="advance" name="AddPoint" event="script" value="addpoint.lua"/>
In data/creaturescripts/scripts add file addpoint.lua and paste inside:
Code:
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill == SKILL__LEVEL then
        local old = getPlayerStorageValue(cid, 33333)
        setPlayerStorageValue(cid, 33333, old + 1)
    end
end
In data/creaturescripts/scripts/login.lua add line:
Code:
registerCreatureEvent(cid, "AddPoint")

In data/talkactions/talkactions.xml add line:
Code:
<talkaction words="!skill"                     event="script" value="addskill.lua"/>
In data/talkactions/scripts add new file addskill.lua and paste inside:
Code:
function onSay(cid, words, param)
local parametres = string.explode(param, ",")

if(parametres[1] ~= nil) and (parametres[2] ~= nil) then
    local points = getPlayerStorageValue(cid, 33333)
        if points < 1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have any free skill points left")
            return true
        end
  
    local type2 = 0
        if parametres[1] == "sword" then
            type2 = 2
        elseif parametres[1] == "fist" then
            type2 = 0
        elseif parametres[1] == "club" then
            type2 = 1
        elseif parametres[1] == "axe" then
            type2 = 3
        elseif parametres[1] == "distance" then
            type2 = 4
        elseif parametres[1] == "shield" then
            type2 = 5
        elseif parametres[1] == "fishing" then
            type2 = 6
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong skill name")
            return true
        end
      
        local value = tonumber(parametres[2])
        if value > points then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't enough skill points.")
            return true
        end
        doPlayerAddSkill(cid, type2, value)
        setPlayerStorageValue(cid, 33333, points - value)
      
else
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough parametres")
    return true
end

return true
end

So, whenever player get level BY NORMAL WAY (wasn't working for me when I added level by command) he gets 1 skill point, which he can use to increase 1 of 6 skills by command:
!skill sword, 1 --adds 1 sword skill
!skill axe, 2 --adds 2 axe skill

If someone mind doing table with loop instead of this:
Code:
if parametres[1] == "sword" then
            type2 = 2
        elseif parametres[1] == "fist" then
            type2 = 0
        elseif parametres[1] == "club" then
            type2 = 1
        elseif parametres[1] == "axe" then
            type2 = 3
would be really nice. As I said before, I don't have much time right now, but feel free to improve this and post here ;)
 
when trying to add a level of skill that goes back storage and gives me only 96% skill, but not 100% and does not go to the next level
 
It must be something with your server then, becasue I was testing it with diffrent skills and it was always giving next lvl.
If player has, lets say 40% to next level it will give the missing 40% and nothing more, but it isn't an issue, becasue asuming that only this system is used all skills will be always on 0%.

Check if you have the same in this function in data/lib/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

@edit
Okay, I know what's wrong. It works properly when you have rateSkill = 1.0 on config :)
 
Last edited:
Ok, did it really fast, so it can have bugs and it isn't the best method for sure, but it's working.

In creaturescripts.xml add line:
Code:
<event type="advance" name="AddPoint" event="script" value="addpoint.lua"/>
In data/creaturescripts/scripts add file addpoint.lua and paste inside:
Code:
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill == SKILL__LEVEL then
        local old = getPlayerStorageValue(cid, 33333)
        setPlayerStorageValue(cid, 33333, old + 1)
    end
end
In data/creaturescripts/scripts/login.lua add line:
Code:
registerCreatureEvent(cid, "AddPoint")

In data/talkactions/talkactions.xml add line:
Code:
<talkaction words="!skill"                     event="script" value="addskill.lua"/>
In data/talkactions/scripts add new file addskill.lua and paste inside:
Code:
function onSay(cid, words, param)
local parametres = string.explode(param, ",")
 
if(parametres[1] ~= nil) and (parametres[2] ~= nil) then
    local points = getPlayerStorageValue(cid, 33333)
        if points < 1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have any free skill points left")
            return true
        end
 
    local type2 = 0
        if parametres[1] == "sword" then
            type2 = 2
        elseif parametres[1] == "fist" then
            type2 = 0
        elseif parametres[1] == "club" then
            type2 = 1
        elseif parametres[1] == "axe" then
            type2 = 3
        elseif parametres[1] == "distance" then
            type2 = 4
        elseif parametres[1] == "shield" then
            type2 = 5
        elseif parametres[1] == "fishing" then
            type2 = 6
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong skill name")
            return true
        end
     
        local value = tonumber(parametres[2])
        if value > points then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't enough skill points.")
            return true
        end
        doPlayerAddSkill(cid, type2, value)
        setPlayerStorageValue(cid, 33333, points - value)
     
else
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough parametres")
    return true
end
 
return true
end

So, whenever player get level BY NORMAL WAY (wasn't working for me when I added level by command) he gets 1 skill point, which he can use to increase 1 of 6 skills by command:
!skill sword, 1 --adds 1 sword skill
!skill axe, 2 --adds 2 axe skill

If someone mind doing table with loop instead of this:
Code:
if parametres[1] == "sword" then
            type2 = 2
        elseif parametres[1] == "fist" then
            type2 = 0
        elseif parametres[1] == "club" then
            type2 = 1
        elseif parametres[1] == "axe" then
            type2 = 3
would be really nice. As I said before, I don't have much time right now, but feel free to improve this and post here ;)
Is it possible to make it so one player could only put say 20 points on each skill?
 
Back
Top