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