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

Points system.

MadMOOK

Hoo
Joined
Apr 20, 2011
Messages
802
Reaction score
43
Credits to an unknown Guest on blacktibia forums lol.
I translated it with google translate lol
::UPDATED!! 100% working!!
Tested on 0.3.7 8.60..


Thanks Ninja :)


You gain a level and depending on your vocation you get x amount of points, you say !points and u can add them to hp,mana,magic, and any one of the skills.. you configure points per level, points cost for each hp/mana/skill and also how much gain per point..

Here we go..

Creaturescripts/scripts/login.lua
Code:
registerCreatureEvent (cid, "PointSystem")
Creaturescripts/scripts/pointSystem.lua
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
Creaturescripts.xml
Code:
<event type= " advance " name= "PointSystem" event= "script" value= "PointsSystem.lua"/>
Talkactions.xml
Code:
<talkaction words="!points" event="script" value="PointsSystem.lua"/>
Talkactions/scripts/pointSystem.lua
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 = {
  ["health"] = {np = 2, vl = 5, nm = "Hit Points"}, -- 2 Points to gain 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, "~*~*~ Add Attributes ~*~*~\n\nPoints Available: ".. getPlayerStorageValue(cid, 14574) .."\nLevel Points: ".. 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] == "health") 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 .. " points".. add .. " ~ " .. v.vl .. " ".. v.nm .. "\n"
  end
  doPlayerPopupFYI(cid, "~*~*~ Add Attributes ~*~*~\n\nPoints needed for skill:\n\n".. msgx .. "\nExample of Use: ".. words .." add,health, 5\n\nPoints available: ".. getPlayerStorageValue(cid, 14574))
  end

  return true
end
 
Last edited:
maybe it does, but i did not see it here :p Im proud of myself.. I dont know much about scripting but I fixed a broken line on it myself lol :)
 
Keep in mind with this script that if you have any items that are +to any skills, this system gives more than 1 point....
Also if you use mocks slot system, and your equipted with an item that has CAS or Mag% it gives WAAY to much!
 
ah ok im using moks slot system and item upgrade but il try make it work :)! ty for telling me!
 
I also JUST NOW noticed... if i put equiptment on with hp% on mocks system and take it off... some of the hp stays.. I think i will remove the hp part from the script
 
hey man madmook can you make so it gives normal hp not % hp?
Code:
Adds 100 hp
<attribute key="maxHitPoints" value="100"/>

Adds 20% of someones hp
<attribute key="maxHitPointsPercent" value="120"/>
 
it gives more then 5hp it gives in % i :/ or somthing wrone when you buy more then once hp
 
it will give more hp if you have items with hp% in slot system on character. I took the hp and mana out of the slot system script because of that. I want this points system over the hp and mana part of the slot system.
 
Credits to an unknown Guest on blacktibia forums lol.
I translated it with google translate lol
::UPDATED!! 100% working!!
Tested on 0.3.7 8.60..


Thanks Ninja :)


You gain a level and depending on your vocation you get x amount of points, you say !points and u can add them to hp,mana,magic, and any one of the skills.. you configure points per level, points cost for each hp/mana/skill and also how much gain per point..

Here we go..

Creaturescripts/scripts/login.lua
Code:
registerCreatureEvent (cid, "PointSystem")
Creaturescripts/scripts/pointSystem.lua
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
Creaturescripts.xml
Code:
<event type= " advance " name= "PointSystem" event= "script" value= "PointsSystem.lua"/>
Talkactions.xml
Code:
<talkaction words="!points" event="script" value="PointsSystem.lua"/>
Talkactions/scripts/pointSystem.lua
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 = {
  ["health"] = {np = 2, vl = 5, nm = "Hit Points"}, -- 2 Points to gain 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, "~*~*~ Add Attributes ~*~*~\n\nPoints Available: ".. getPlayerStorageValue(cid, 14574) .."\nLevel Points: ".. 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] == "health") 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 .. " points".. add .. " ~ " .. v.vl .. " ".. v.nm .. "\n"
  end
  doPlayerPopupFYI(cid, "~*~*~ Add Attributes ~*~*~\n\nPoints needed for skill:\n\n".. msgx .. "\nExample of Use: ".. words .." add,health, 5\n\nPoints available: ".. getPlayerStorageValue(cid, 14574))
  end

  return true
end
magic level doesn't work >.< but rest are working fine btw i need to change points each level like +1 not 5
 
Add ["magic"] = 0, to top of that list
Code:
        local skillids = {
                ["shielding"] = 5,
                ["sword"] = 2,
                ["axe"] = 3,
                ["club"] = 1,
                ["distance"] = 4
                }
you are too late :D i made it before but there is one problem only and this is when i make high amount of upgrade like add,skill,20+ its makes bug on server i need to make highest upgrade each time is 10 only
 
Ok, here is the talkaction to give someone points using the system you attached in your first post:
Code:
function onSay(cid, words, param)
if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param. Correct use /addPoints nameOfPlayer, points.")
return true
end

local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough params. Correct use /addPoints nameOfPlayer, points.")
return true
end

pid = getPlayerByNameWildcard(t[1])
if isCreature(pid) then
local points = getPlayerStorageValue(pid, 14574)
if points == -1 then points = 0 end
points = points + t[2]
doPlayerSetStorageValue(pid, 14574, points)
doCreatureSay(pid, "Yay! I now have "..points.." points!", 1)
end
return true
end

To use this, you will need to add it to talkactions.xml, and you can name it whatever you want (I named it addPoints in the params above).

Now for an item you use and gain points...
Code:
local pointsEarned = 10 -- Put how many points this item gives here

function onUse(cid, item, fromPosition, itemEx, toPosition)
local points = getPlayerStorageValue(cid, 14574)
if points == -1 then points = 0 end
points = points + pointsEarned
doPlayerSetStorageValue(cid, 14574, points)
doCreatureSay(cid, "Yay! I now have "..points.." points!", 1)
return true
end

To use this, add it to actions.xml and set it to an itemid.
 
Last edited:
Back
Top