- Joined
- Dec 26, 2013
- Messages
- 2,124
- Solutions
- 14
- Reaction score
- 1,518
- Location
- USA
- GitHub
- Codinablack
Greetings Otland.
Here I come to you today in regards of a script I have been working on to enhance skill points. More of an advanced skill points system altogether. Anyways I seem to be stuck. I want the script to add points in groups, table groups by vocations. Anyways, I can't seem to get it to add the points.
NOTE: All variables not defined in script are defined in my global.lua
I was mistakenly using a loop before, "for index, vocation in ipairs(Mages) do" and it did successfully add points, but of course it added 20 points because that's how many values I have in that table, so yeah that was totally the wrong way to do...
Still having trouble with these tables apparently, I would be very appreciative of any help I could get please.
Here I come to you today in regards of a script I have been working on to enhance skill points. More of an advanced skill points system altogether. Anyways I seem to be stuck. I want the script to add points in groups, table groups by vocations. Anyways, I can't seem to get it to add the points.
NOTE: All variables not defined in script are defined in my global.lua
Code:
local Mages = {MAGE, WARLOCK, SORCEROR, MEDIUM, WITCHDOCTOR, ELEMENTALIST, PYROMANCER, HYDROMANCER, GEOMANCER, AEROMANCER, SCHOLAR, PHILOSOPHER, SAGE, CONJURER, SUMMONER, PROSELYTE, CLERIC, BISHOP, DRUID, ACOLYTE}
local Rangers = {NEOPHYTE, ARCHER, KNAVE, THIEF, BANDIT, ROGUE, MARSKMAN, SNIPER}
local Assault = {SQUIRE, KNIGHT, HOLY_KNIGHT, DARK_KNIGHT, BARON, WARRIOR, MONK, LEGENDARY_FIGHTER, TYRO, SOLDIER, MERCENARY}
local Defense = {SENTRY, SENTINEL, GUARDIAN, ENGINEER, TECHNICIAN, SMITH, CHEMIST}
function onAdvance(cid, skill, oldlevel, newlevel)
local player = Player(cid)
local vocation = player:getVocation()
if (skill == 8) then
if player:getStorageValue(ATTRIBUTE_LEVEL) < newlevel then
if player:getStorageValue(ATTRIBUTE_POINTS) < 0 then
player:setStorageValue(ATTRIBUTE_POINTS, 0)
player:setStorageValue(ATTRIBUTE_LEVEL, 0)
player:setStorageValue(VITALITY, 0)
player:setStorageValue(DEXTERITY, 0)
player:setStorageValue(INTELLIGENCE, 0)
player:setStorageValue(STRENGTH, 0)
end
end
if isInArray(Mages, vocation) then
player:setStorageValue(VITALITY, (player:getStorageValue(VITALITY) + ((newlevel - oldlevel) * 1)))
player:setStorageValue(DEXTERITY, (player:getStorageValue(DEXTERITY) + ((newlevel - oldlevel) * 1)))
player:setStorageValue(INTELLIGENCE, (player:getStorageValue(INTELLIGENCE) + ((newlevel - oldlevel) * 1)))
player:setStorageValue(STRENGTH, (player:getStorageValue(STRENGTH) + ((newlevel - oldlevel) * 1)))
end
player:setStorageValue(ATTRIBUTE_LEVEL, newlevel)
doCreatureSay(cid, '+ Attribute Points!', TALKTYPE_ORANGE_1)
end
return true
end
I was mistakenly using a loop before, "for index, vocation in ipairs(Mages) do" and it did successfully add points, but of course it added 20 points because that's how many values I have in that table, so yeah that was totally the wrong way to do...
Still having trouble with these tables apparently, I would be very appreciative of any help I could get please.