Hey everybody, I have a script I am working on to remove club and magic level when using a item
The club skill downgrades just fine with no issues, but the magic level doesn't....I kind of played around with manaspent and it reduces the levels but it is not going to be the same values across the board?
So... how could we make it decrease by 15 flat value?
Here is the debug log
Before - Current Magic Level Skill: 200
Debug - Player Info: "playerid" Noob 200
Warning: Current skill level is nil.
After - New Magic Level Skill: 185
But it does not decrease the magic level to 185.. it stays at 20
Any help appreciated!
Lua:
local decreaseSkillLevels = 15
local currentClubSkill = player:getSkillLevel(SKILL_CLUB) or 0
local currentMagicLevelSkill = player:getBaseMagicLevel() or 0
print("Before - Current Magic Level Skill:", currentMagicLevelSkill)
print("Debug - Player Info:", player:getId(), player:getName(), player:getBaseMagicLevel())
-- Decrease Club Skill
local decreaseClubLevel = math.min(decreaseSkillLevels, currentClubSkill)
player:addSkillLevel(SKILL_CLUB, -decreaseClubLevel)
-- Decrease Magic Level
local decreaseMagicLevel = math.min(decreaseSkillLevels, currentMagicLevelSkill)
player:addSkillLevel(SKILL_MAGLEVEL, -decreaseMagicLevel)
local newMagicLevelSkill = math.max(0, currentMagicLevelSkill - decreaseSkillLevels)
print("After - New Magic Level Skill:", newMagicLevelSkill)
The club skill downgrades just fine with no issues, but the magic level doesn't....I kind of played around with manaspent and it reduces the levels but it is not going to be the same values across the board?
So... how could we make it decrease by 15 flat value?
Here is the debug log
Before - Current Magic Level Skill: 200
Debug - Player Info: "playerid" Noob 200
Warning: Current skill level is nil.
After - New Magic Level Skill: 185
But it does not decrease the magic level to 185.. it stays at 20
Any help appreciated!