Hello, I have this script which adds skills/magic level if you use points that you get from leveling up, however I want to add max skill/maglvl but I cannot do it (I'm noob with Lua) here's my actual script, hope someone can help me.
This lines seem to not work:
Code:
local config = {
maxskilllevel = 150,
maxmaglevel = 150
}
local VocPoints = {
[1] = 3,
[2] = 3,
[3] = 3,
[4] = 3,
[5] = 3,
[6] = 3,
[7] = 3,
[8] = 3,
[9] = 3,
}
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,
["one-handed"] = 2,
["dual"] = 3,
["two-handed"] = 1,
["sneaking"] = 6,
["distance"] = 4
}
local attributes = {
["health"] = {np = 1, vl = 10, nm = "Hit Points"},
["mana"] = {np = 1, vl = 10, nm = "Mana Points"},
["magic"] = {np = 1, vl = 1, nm = "Magic Level"},
["shielding"] = {np = 1, vl = 1, nm = "Shielding Skill"},
["one-handed"] = {np = 1, vl = 1, nm = "One-Handed Skill"},
["dual"] = {np = 1, vl = 1, nm = "Dual Skill"},
["two-handed"] = {np = 1, vl = 1, nm = "Two-Handed Skill"},
["distance"] = {np = 1, vl = 1, nm = "Distance Skill"},
["sneaking"] = {np = 1, vl = 1, nm = "Sneaking Skill"},
}
if (param == "check") then
doPlayerPopupFYI(cid, "Skill Points\n\nAvailable points: ".. getPlayerStorageValue(cid, 14574) .."\npoints per level: ".. 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!")
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] == "mana") 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
doPlayerAddMagLevel(cid, getPlayerMagLevel(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
elseif (p2[2] == "magic") then
if (getPlayerMagLevel(cid) >= config.maxmaglevel) then
doPlayerSendCancel(cid, "This skill cannot go any higher!")
end
elseif (skillids[p2[2]]) then
if (getPlayerSkillLevel(cid) >= config.maxskilllevel) then
doPlayerSendCancel(cid, "This skill cannot go any higher!")
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, "Skill Points\n\nSkills:\n\n".. msgx .. "\nExample: ".. words .." add, health, 5\n\nAvailable Points: ".. getPlayerStorageValue(cid, 14574))
end
return true
end
This lines seem to not work:
Code:
elseif (p2[2] == "magic") then
if (getPlayerMagLevel(cid) >= config.maxmaglevel) then
doPlayerSendCancel(cid, "This skill cannot go any higher!")
end
elseif (skillids[p2[2]]) then
if (getPlayerSkillLevel(cid) >= config.maxskilllevel) then
doPlayerSendCancel(cid, "This skill cannot go any higher!")
end
Last edited: