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

Points system! HELP

wikutag

SoulBound 8.6 100% custom
Joined
Dec 27, 2012
Messages
305
Reaction score
0
Location
United states Kentucky
My points system is not giving my player magic levels? but everything else works i dont understand

HTML:
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 = 50, vl = 5, nm = "Hit Points"}, -- 2 Points to gain 10 hp
  ["energy"] = {np = 30, vl = 3, nm = "Mana Points"},
  ["magic"] = {np = 30, vl = 1, nm = "Magic Level"},
  ["shielding"] = {np = 30, 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

Like u say !points ,add magic, 5 and it does nothing but take ur points

bump
 
Last edited by a moderator:
no it just pops up -# of points than your ml goes up but it dont do it 100% it only goes up to 99% than if your ml 120 than you have to work for it or w/e but it should go +1 magic level instead of 0% up to 99%

Anyone help?
 
Last edited by a moderator:
Code:
[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
Can anyone add it? heres the code for that part I just dunno how to add
 
Last edited:
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

  function doPlayerAddMagLevel(cid, amount)
    for i = 1, amount do
        doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)) / getConfigInfo('rateMagic'))
    end
    return true
end
 
  local skillids = {
  ["shielding"] = 5,
  ["sword"] = 2,
  ["axe"] = 3,
  ["club"] = 1,
  ["distance"] = 4
  }

  local attributes = {
  ["health"] = {np = 50, vl = 5, nm = "Hit Points"}, -- 2 Points to gain 10 hp
  ["energy"] = {np = 30, vl = 3, nm = "Mana Points"},
  ["magic"] = {np = 30, vl = 1, nm = "Magic Level"},
  ["shielding"] = {np = 30, 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 (p2[2] == "magic") then
  setCreatureMaxMana(cid, getCreatureMaxMana(cid) + attributes[p2[2]].vl * tonumber(p2[3]))
  doPlayerAddMagLevel(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

Try that and see if it works...
 
It works but it keeps taking points when your 99% and doesn't level you up..
vfja06.png


Heres thecreaturescript if needed
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
 
Do you get any console errors? Do you have "rateMagic" in your config.lua?

And what do you mean it works but it doesn't, adds mana all the way up to 99%, but not passed?
 
Ok do you have "rateMagic" in your config.lua? What is your server version, if need be do you have the talkaction /addskill command? if so may need to see it's lua file to figure out how to add magic points for your server...
 
Last edited:
I need to know the function you use for adding magic levels on your server, because the one I gave you isn't working... So if you have the Talkaction/command "/addskill" on your server then I would need to see it to see how its done, check if you have skill.lua or addskill.lua in your talkactions/scripts/ folder...
 
Change
Code:
for i = 1, amount do
      doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)) / getConfigInfo('rateMagic'))
end
To
Code:
for i = 1, amount do
     doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)), false)
end
 
Back
Top