• 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 ModalWindow Skill Point System

Codinablack

Dreamer
Content Editor
Joined
Dec 26, 2013
Messages
1,551
Solutions
11
Reaction score
771
First off lets give credit where credit is due!
I found the code to start this with from http://otland.net/threads/points-system.200268/
and so credits go to @Ninja @MadMOOK and unnamed being from blacktibia....

What this system is used for is more perks from leveling, and thus more customization. Everytime a player levels they gain X amount of skill points (configurable of course), and they can use these skill points to purchase either, HP MP or SKILLS.

UPDATE: This is now a modalwindow system. Hasn't been fully tested, would love some feedback. It is updated to 1.1. This system differs from Zbizu's system in the fact that it was intended to be configured for different vocations, more modalwindows, and more options for gaining 1, or 2 or 5 of a skill at a time. His system is still all around better in terms of coding. I recommend his system, however if you prefer this one it is here. My true recommendation is to learn from both and see what you can make for yourself :D Enjoy!

Now for the code

/creaturescripts/scripts/skillpoints.lua

http://pastebin.com/h6Bf8HVQ

/creaturescripts/scripts/login.lua
Code:
  player:registerEvent("SkillPointSystem")
/creaturescripts/creaturescripts.xml
Code:
<event type="modalwindow" name="PointWindow" script="skillpoints.lua"/>
<event type="advance" name="SkillPointSystem" script="skillpoints.lua"/>

/talkactions/scripts/skillpoints.lua
Code:
function onSay(player, words, param)
local SKILL_POINTS = 45200

local Point = ModalWindow(1, "Skill Points", "You have skill " ..player:getStorageValue(SKILL_POINTS)..  " points make your choice:\n\n Skill          Required Points         Increase Amount")
    Point:addChoice(1, "1. Health              1                                                2")
    Point:addChoice(2, "2. Mana")
    Point:addChoice(3, "3. Magic Level")
    Point:addChoice(4, "4. Sword")
    Point:addChoice(5, "5. Axe")
    Point:addChoice(6, "6. Club")
    Point:addChoice(7, "7. Shielding")
    Point:addChoice(8, "8. Distance")

    Point:addButton(1, 'Gain 1')
    Point:addButton(2, 'Gain 2')
    Point:addButton(3, 'Gain 5')
    Point:addButton(4, 'Cancel')

    player:registerEvent("PointWindow")
    Point:sendToPlayer(player)
    return false
end

AND FINALLY /talkactions/talkactions.xml
Code:
  <talkaction words="!points" separator=" " script="skillpoints.lua"/>
 
Last edited:
Yeah I should have added some magic effects for when you upgrade a skill as well, make it look nicer, maybe even add a config, but I wasn't for sure if anyone would even be using it...

So I am open to requests, ideas, or suggestions
 
its old:

Code:
function onModalWindow(cid, modalWindowId, buttonId, choiceId)

if modalWindowId == 1 then

local accid = getAccountNumberByPlayerName(getCreatureName(cid))
local orderQuery = db.storeQuery("SELECT `strenght`, `agility`, `inteligence`,`ppoints` FROM `players` WHERE `id` =  ".. getPlayerGUID(cid) .." ")
local taskai = result.getDataInt(orderQuery, "ppoints")

local str = result.getDataInt(orderQuery, "strenght")
local agi = result.getDataInt(orderQuery, "agility")
local inte = result.getDataInt(orderQuery, "inteligence")


if buttonId == 4 then
skaiciujam = taskai - 1
skaiciujam2 = str + 1
skaiciujam3 = agi + 1
skaiciujam4 = inte + 1
end

if buttonId == 5 then
skaiciujam = 0
skaiciujam2 = str + taskai
skaiciujam3 = agi + taskai
skaiciujam4 = inte + taskai
end


if buttonId == 6 then
return false
else

if buttonId == 4 or buttonId == 5 then

    if choiceId == 1 then
db.query("UPDATE `players` SET `ppoints` = " .. skaiciujam .. ", `strenght` = " .. skaiciujam2 .. "  WHERE `id` =  ".. getPlayerGUID(cid) .." ")
doPlayerPopupFYI(cid, 'You succesfull used stenght points!')
return true
    end
    if choiceId == 2 then
doPlayerPopupFYI(cid, 'You succesfull used agility points!')
db.query("UPDATE `players` SET `ppoints` = " .. skaiciujam .. ", `agility` = " .. skaiciujam3 .. "  WHERE `id` =  ".. getPlayerGUID(cid) .." ")
return true
    end
     if choiceId == 3 then
doPlayerPopupFYI(cid, 'You succesfull used inteligence points!')
db.query("UPDATE `players` SET `ppoints` = " .. skaiciujam .. ", `agility` = " .. skaiciujam4 .. "  WHERE `id` =  ".. getPlayerGUID(cid) .." ")
return true
    end  

    end
    end
end
end


Level up get point:

Code:
function onAdvance(cid, skill, oldlevel, newlevel)
local player = Player(cid)
local accid = getAccountNumberByPlayerName(getCreatureName(cid))
local orderQuery = db.storeQuery("SELECT `ppoints` FROM `players` WHERE `id` =  ".. getPlayerGUID(cid) .." ")
local taskai = result.getDataInt(orderQuery, "ppoints")

local sumuojam = newlevel - oldlevel + taskai

db.query("UPDATE `players` SET `ppoints` = " .. sumuojam .. "  WHERE `id` =  ".. getPlayerGUID(cid) .." ")

                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have received: '..newlevel - oldlevel..' skill points type: !points')
end

(BETTER USE STORAGE)



Talkactions:
Code:
function onSay(cid, words, param)
local storage = 30020
local cooldown = 10

if getPlayerStorageValue(cid, storage) <= os.time() then
setPlayerStorageValue(cid, storage, os.time() + cooldown)
local playeris = getCreatureName(cid)

local accid = getAccountNumberByPlayerName(getCreatureName(cid))
local orderQuery = db.storeQuery("SELECT `name`, `strenght`, `agility`, `inteligence`,`ppoints` FROM `players` WHERE `id` =  ".. getPlayerGUID(cid) .." ")
local taskai = result.getDataInt(orderQuery, "ppoints")

local str = result.getDataInt(orderQuery, "strenght")
local agi = result.getDataInt(orderQuery, "agility")
local inte = result.getDataInt(orderQuery, "inteligence")
local player = Player(cid)

if taskai == 0 then
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have any skill point.")

    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Strengt: '..str..'')
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Agility: '..agi..'')
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Inteligence: '..inte..'')

return false
else

    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Strengt: '..str..'')
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Agility: '..agi..'')
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Inteligence: '..inte..'')
   
   
    local Point = ModalWindow(1, 'You have: '..taskai..' points.', "Make your choice:")
    Point:addChoice(1, "1. Strengt")
    Point:addChoice(2, "2. Agility")
    Point:addChoice(3, "3. Inteligence")
 
    Point:addButton(4, 'Learn')
    Point:addButton(5, 'Learn all')
    Point:addButton(6, 'Exit')
   
    Point:sendToPlayer(player)
   

    return false
   
    end
   
    else
  
   
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: "..
getPlayerStorageValue(cid, storage) - os.time())   
    end
   
end


You welcome guys.
 
Nope, you will have to change some functions, but it should still work if you tailor it to your server version...
is it working with 0.3.6?
if is it i need something more ,if i level up and get my points after then i die and get level again does it gone give me more points i mean double with same level

its old:

Code:
function onModalWindow(cid, modalWindowId, buttonId, choiceId)

if modalWindowId == 1 then

local accid = getAccountNumberByPlayerName(getCreatureName(cid))
local orderQuery = db.storeQuery("SELECT `strenght`, `agility`, `inteligence`,`ppoints` FROM `players` WHERE `id` =  ".. getPlayerGUID(cid) .." ")
local taskai = result.getDataInt(orderQuery, "ppoints")

local str = result.getDataInt(orderQuery, "strenght")
local agi = result.getDataInt(orderQuery, "agility")
local inte = result.getDataInt(orderQuery, "inteligence")


if buttonId == 4 then
skaiciujam = taskai - 1
skaiciujam2 = str + 1
skaiciujam3 = agi + 1
skaiciujam4 = inte + 1
end

if buttonId == 5 then
skaiciujam = 0
skaiciujam2 = str + taskai
skaiciujam3 = agi + taskai
skaiciujam4 = inte + taskai
end


if buttonId == 6 then
return false
else

if buttonId == 4 or buttonId == 5 then

    if choiceId == 1 then
db.query("UPDATE `players` SET `ppoints` = " .. skaiciujam .. ", `strenght` = " .. skaiciujam2 .. "  WHERE `id` =  ".. getPlayerGUID(cid) .." ")
doPlayerPopupFYI(cid, 'You succesfull used stenght points!')
return true
    end
    if choiceId == 2 then
doPlayerPopupFYI(cid, 'You succesfull used agility points!')
db.query("UPDATE `players` SET `ppoints` = " .. skaiciujam .. ", `agility` = " .. skaiciujam3 .. "  WHERE `id` =  ".. getPlayerGUID(cid) .." ")
return true
    end
     if choiceId == 3 then
doPlayerPopupFYI(cid, 'You succesfull used inteligence points!')
db.query("UPDATE `players` SET `ppoints` = " .. skaiciujam .. ", `agility` = " .. skaiciujam4 .. "  WHERE `id` =  ".. getPlayerGUID(cid) .." ")
return true
    end 

    end
    end
end
end


Level up get point:

Code:
function onAdvance(cid, skill, oldlevel, newlevel)
local player = Player(cid)
local accid = getAccountNumberByPlayerName(getCreatureName(cid))
local orderQuery = db.storeQuery("SELECT `ppoints` FROM `players` WHERE `id` =  ".. getPlayerGUID(cid) .." ")
local taskai = result.getDataInt(orderQuery, "ppoints")

local sumuojam = newlevel - oldlevel + taskai

db.query("UPDATE `players` SET `ppoints` = " .. sumuojam .. "  WHERE `id` =  ".. getPlayerGUID(cid) .." ")

                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have received: '..newlevel - oldlevel..' skill points type: !points')
end

(BETTER USE STORAGE)



Talkactions:
Code:
function onSay(cid, words, param)
local storage = 30020
local cooldown = 10

if getPlayerStorageValue(cid, storage) <= os.time() then
setPlayerStorageValue(cid, storage, os.time() + cooldown)
local playeris = getCreatureName(cid)

local accid = getAccountNumberByPlayerName(getCreatureName(cid))
local orderQuery = db.storeQuery("SELECT `name`, `strenght`, `agility`, `inteligence`,`ppoints` FROM `players` WHERE `id` =  ".. getPlayerGUID(cid) .." ")
local taskai = result.getDataInt(orderQuery, "ppoints")

local str = result.getDataInt(orderQuery, "strenght")
local agi = result.getDataInt(orderQuery, "agility")
local inte = result.getDataInt(orderQuery, "inteligence")
local player = Player(cid)

if taskai == 0 then
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have any skill point.")

    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Strengt: '..str..'')
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Agility: '..agi..'')
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Inteligence: '..inte..'')

return false
else

    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Strengt: '..str..'')
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Agility: '..agi..'')
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Inteligence: '..inte..'')
  
  
    local Point = ModalWindow(1, 'You have: '..taskai..' points.', "Make your choice:")
    Point:addChoice(1, "1. Strengt")
    Point:addChoice(2, "2. Agility")
    Point:addChoice(3, "3. Inteligence")

    Point:addButton(4, 'Learn')
    Point:addButton(5, 'Learn all')
    Point:addButton(6, 'Exit')
  
    Point:sendToPlayer(player)
  

    return false
  
    end
  
    else
 
  
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: "..
getPlayerStorageValue(cid, storage) - os.time())  
    end
  
end


You welcome guys.
where i write these codes? please tell me the positions of them
 
Last edited by a moderator:
If you really want a working skill/attribute system for your server I will help you when I get time, private message me and I will help you. It would be tremendously useful to have a list of all the functions used for the server version you are using.
 
If you really want a working skill/attribute system for your server I will help you when I get time, private message me and I will help you. It would be tremendously useful to have a list of all the functions used for the server version you are using.
k thx but i'm working with it now but i got some problems with it >.< when you come back please message me ;)
 
Hey man you still working on this? would like to help out.
 
NICE WORK MAN!!!!!!
hahehahe

Thank you very much! I thought it was too! That's why I posted it, looking at it now, I kinda feel like its a sloppy conversion... I plan on redoing everything in my signature to 1.1 when I get the free time, then it will be way better :D
 
Thank you very much! I thought it was too! That's why I posted it, looking at it now, I kinda feel like its a sloppy conversion... I plan on redoing everything in my signature to 1.1 when I get the free time, then it will be way better :D

It better be! -.-
 
LOL, seems everyone likes the modalwindows idea... I suppose I can make sure when I do my re-write it's for modalwindows, but just know those things aren't for me, I won't be using the system, because I have a whole different system I have been developing with libraries of code given to me that aren't mine to release, and other reasons... So yeah, busy with school and stuff, but when I get the free time, I will do this for you guys
 
Yo! When adding magic level, it goes BAzOOKA! from magic level 10 to magic level 109 when using 1 skill point! :D
 
Back
Top