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

CreatureEvent [TFS 1.1] Skill Points, modalwindow

Status
Not open for further replies.
You guys are having so many problems because you are still trying to actually use the real skills, it's so much simpler to just create the conditions and ties with them through storages, all can be handled through the creaturescripts and events, which means all could be handled in a global lib, so you can easily make the additions to this script, just make the additions in sp.lua and then find the appropriate scripts put in your code.

Why not go for the real fun and try to write your own from scratch? You can always use pieces of code from other scripts, but you learn so much more and have so much more fun and control doing it this way, naming your own variables, completely making it your own, only adding what you need and want.

Well basicly, I have learned alot in the past months. Just by taking yours and others advice of reading scripts, checking what does what and how to combine stuff. I have come a long way with doing that, I really have and I can only thank you guys! But now I only have limited time to spend on this, so to get things working as I want I really do need some help. But on top of that, I am willing to pay people to help me. At least with these a little more complicated scripts.
 
You guys are having so many problems because you are still trying to actually use the real skills, it's so much simpler to just create the conditions and ties with them through storages, all can be handled through the creaturescripts and events, which means all could be handled in a global lib, so you can easily make the additions to this script, just make the additions in sp.lua and then find the appropriate scripts put in your code.

Why not go for the real fun and try to write your own from scratch? You can always use pieces of code from other scripts, but you learn so much more and have so much more fun and control doing it this way, naming your own variables, completely making it your own, only adding what you need and want.
Yeah.. few hours ago started reworking my skillpoint system.
modalwindow is now automatic and working.
Started removing skill just a moment ago and realized. there is no removeSkill :eek:. LOL :D

Seems we do have to use conditions :/ (extra work....)
Problem with that, they don't last forever imo, although the condition could last days and relogin would refresh it.
 
Conditions can definitely last forever, just have to set the ticks to -1. Viola! And of course like you said, you would want a login script to make sure it is applied every-time you login.
 
Conditions can definitely last forever, just have to set the ticks to -1. Viola! And of course like you said, you would want a login script to make sure it is applied every-time you login.
-1 :eek:!??
Me so gona try that next time i continue.
 
I'm surprised you missed that one, you must never have looked at the slot system zbizu remade a good long while back that was a remake of an even older one, that's where I found example code to learn from.
 
I was testing my server and with help I killed a dl with a low lvl, what happens is the points only add the same amount, if I lvl 1 or 3 lvls, it doesn't matter, I always get 1 point only, is there a way to change it so it adds points based on your new level instead of the advance thing? Because I can skip lvls on advance so it would be better if I could calculate it using the difference between the old lvl and the new lvl, is this possible?
 
I don't know if I'm doing something wrong or what, but when I try to add fishing level, it doesn't add the whole level it only adds like 1/4 of level.. This is how i set it up:

Code:
local gainVoc = {
    [0] = {health = 10, mana = 10, cap = 20, skill = 1},
    [1] = {health = 10, mana = 15, cap = 20, skill = 1},
    [2] = {health = 10, mana = 15, cap = 20, skill = 1},
    [3] = {health = 10, mana = 15, cap = 20, skill = 1},
    [4] = {health = 10, mana = 15, cap = 20, skill = 1}
}

Code:
    [3] = {'Fishing', function(player) return player:getSkillLevel(SKILL_FISHING) end, function(player) local gain = gainVoc[player:getBaseVocId()].skill player:addSkillLevels(SKILL_FISHING, gain) return gain end, 15},

Also, why doesn't it display the changed HP and Mana? It only shows it in the ModalWindow for some reason...
 
the script wasn't meant to be used on high exp servers
anyway
try changing
Code:
self:addSkillPoints(skillPointsPerLevel)
to
Code:
self:addSkillPoints(skillPointsPerLevel * (nlevel - self:getStorageValue(skillPointsAdvanceStorage)))
 
This is confirmed not working anymore on tfs 1.2. skills only go up by a percent not a whole level.
 
the script wasn't meant to be used on high exp servers
anyway
try changing
Code:
self:addSkillPoints(skillPointsPerLevel)
to
Code:
self:addSkillPoints(skillPointsPerLevel * (nlevel - self:getStorageValue(skillPointsAdvanceStorage)))

thanks zbizu,
with that line, characters wont lose any points if they were to lvl up more than one level at a time.
it works great, awesome

thanks again for sharing
 
I need to limit one skill to add to 100 skill points maximum, example: I want it to be possible to add only 100 skill points in capacity and others can continue to add.
 
I need to limit one skill to add to 100 skill points maximum, example: I want it to be possible to add only 100 skill points in capacity and others can continue to add.

do it on storages
add to "local skills = {" subentries a number which will serve as a storage
and later:
Code:
local maxStor = skills[choiceId][5]
local getStor = player:getStorageValue(maxStor)
if getStor == -1 then
player:setStorageValue(maxStor, 0)
end

if getStor < 100 then
-- adding skill part
player:setStorageValue(maxStor, getStor + 1)
else
-- sending error message
end

Forgive me pathetic style and lack of tabbing. I haven't been doing it in a while.
 
do it on storages
add to "local skills = {" subentries a number which will serve as a storage
and later:
Code:
local maxStor = skills[choiceId][5]
local getStor = player:getStorageValue(maxStor)
if getStor == -1 then
player:setStorageValue(maxStor, 0)
end

if getStor < 100 then
-- adding skill part
player:setStorageValue(maxStor, getStor + 1)
else
-- sending error message
end

Forgive me pathetic style and lack of tabbing. I haven't been doing it in a while.

I'm still noob in this part, I'm trying to learn day long trying to do What you said but I could not, could you give me an example of how to do?
 
Spend skill points on skills/stats, configurable amount of points per level.
DF4hMqN.jpg


creaturescripts.xml:
Code:
    <event type="modalwindow" name="skillPoints_modal" script="sp.lua"/>
    <event type="advance" name="skillPoints_advance" script="sp.lua"/>
    <event type="login" name="skillPoints_register" script="sp.lua"/>

sp.lua Creaturescript
Code:
function onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:skillWindowChoice(modalWindowId, buttonId, choiceId)
    return true
end

function onAdvance(player, skill, oldLevel, newLevel)
    if skill == SKILL_LEVEL then
        player:skillPointsAdvance(newLevel)
    end
    return true
end

function onLogin(player)
    player:registerEvent("skillPoints_advance")
    player:registerEvent("skillPoints_modal")
    return true
end

talkactions.xml:
Code:
    <talkaction words="!points" script="sp.lua"/>

sp.lua Talkaction
Code:
function onSay(player, words, param)
    player:sendSkillPointsWindow()
    return false
end

now the lib file:
- if you use this: [TFS 1.x] lib folder in "data" like 0.4, just create sp.lua and put it in data\lib folder
- if you don't use this, just create file sp.lua in data folder and put this in global.lua:
Your code is hackeable.

Code:
    for i = 1, #skills do
        if isInArray(skillForVoc[self:getBaseVocId()], i) then
            window:addChoice(i, skills[i][1] .. ": [" .. skills[i][2](self) .. "][cost: " .. skills[i][4] .. "]")
        end
    end

Doing choices like this is not safe, anyone could send the packet with a different choiceId, you have to check in the "function Player:skillWindowChoice(windowId, buttonId, choiceId)" as well.
 
Your code is hackeable.
Doing choices like this is not safe, anyone could send the packet with a different choiceId, you have to check in the "function Player:skillWindowChoice(windowId, buttonId, choiceId)" as well.
the function you posted just generates skill points window
it's checked again in answer function

"checking part" makes sure player has enough points to use
Code:
local pts = self:getStorageValue(skillStorage)
...
if pts - skills[choiceId][4] >= 0 then

I quite don't get it where it might be hackable.
 
the function you posted just generates skill points window
it's checked again in answer function

"checking part" makes sure player has enough points to use
Code:
local pts = self:getStorageValue(skillStorage)
...
if pts - skills[choiceId][4] >= 0 then

I quite don't get it where it might be hackable.
A player can choose any choice even if its not in the modal window (because his vocation), he just have to change the choiceId. Not the amount of points.

It can be easily done with OTClient, tho its possible even without it but its just a bit harder.
 
Ah, I see. Thank you.

adding this:
Code:
isInArray(skillForVoc[self:getBaseVocId()], choiceId)
to this "if" with "and" operator should fix that:
Code:
if not skills[choiceId] then

let me know if it fixes the issue
can't test it myself now (need to maintain all ot stuff again due to OS reinstall)
 
Status
Not open for further replies.
Back
Top