Tbol
Well-Known Member
- Joined
- Apr 7, 2019
- Messages
- 592
- Reaction score
- 64
Cant get it working i though i fixed it but noticed it does give particular reward after reaching certain level point, strange part wrote two code version and both works on 50% becase i have two rewards and in one code it gives one reward but it doesnt give another reward, than in another code version its opposite 
So in this code this part addExtraHealth, addExtraMana doesnt work for some reason it doesnt add up,but addToAvailablePoints, addToTotalPoints works just fine
Now in this code addExtraHealth, addExtraMana works just fine, but it has a issue if i use action script that gives for example 5000000exp it ignore the reward and doesnt give for example addToAvailablePoints, addToTotalPoints, but in first code it works fine, so im like stuck in a curse if i fix something another shit breaks

So in this code this part addExtraHealth, addExtraMana doesnt work for some reason it doesnt add up,but addToAvailablePoints, addToTotalPoints works just fine
LUA:
local config = {
vocations = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 101, 86, 81, 77, 75, 73, 71, 111, 108, 113, 115},
restoreHealth = true,
stages = {
[15] = {
addToAvailablePoints = 1,
addToTotalPoints = 1
},
[30] = {
addExtraHealth = 250,
addExtraMana = 250
}
}
}
function onAdvance(player, skill, oldLevel, newLevel)
if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
return true
end
for level = oldLevel + 1, newLevel do
local reward = config.stages[level]
if reward and isInArray(config.vocations, player:getVocation():getId()) and player:getStorageValue(Storage.LevelReward) < level then
if reward.addExtraHealth then
player:addHealth(reward.addExtraHealth)
end
if reward.addExtraMana then
player:addMana(reward.addExtraMana)
end
if reward.addToAvailablePoints then
Rewardpoint.addToAvailablePoints(player, reward.addToAvailablePoints)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("Hello! Youve gained %u points.", reward.addToAvailablePoints))
end
if reward.addToTotalPoints then
Rewardpoint.addToTotalPoints(player, reward.addToTotalPoints)
end
player:setStorageValue(Storage.LevelReward, level)
end
end
if config.restoreHealth then
player:addHealth(player:getMaxHealth())
player:addMana(player:getMaxMana())
end
return true
end
Now in this code addExtraHealth, addExtraMana works just fine, but it has a issue if i use action script that gives for example 5000000exp it ignore the reward and doesnt give for example addToAvailablePoints, addToTotalPoints, but in first code it works fine, so im like stuck in a curse if i fix something another shit breaks
LUA:
local config = {
vocations = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 101, 86, 81, 77, 75, 73, 71, 111, 108, 113, 115},
restoreHealth = true,
stages = {
[15] = {
addToAvailablePoints = 1,
addToTotalPoints = 1
},
[30] = {
addExtraHealth = 250,
addExtraMana = 250
}
}
}
function onAdvance(player, skill, oldLevel, newLevel)
if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
return true
end
local reward = config.stages[newLevel]
if reward and isInArray(config.vocations, player:getVocation():getId()) and player:getStorageValue(Storage.LevelReward) < newLevel then
player:takeReward(reward)
player:setStorageValue(Storage.LevelReward, newLevel)
player:save()
-- Add technique points if defined in the reward configuration
if reward.addToAvailablePoints then
Techniques.addToAvailablePoints(player, reward.addToAvailablePoints)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("Hello! You've gained %u Points.", reward.addToAvailablePoints))
end
if reward.addToTotalPoints then
Techniques.addToTotalPoints(player, reward.addToTotalPoints)
end
end
-- Restore health and mana if configured
if config.restoreHealth then
player:addHealth(player:getMaxHealth())
player:addMana(player:getMaxMana())
end
return true
end