I expressed myself wrong. I tried to make the code above the idea is if the LoyaltyStatus is greater than X it will add 5% more skills but it didn't work
function Player.getLoyaltyPoints(self)
local loyaltyPoints = 0
local resultId = db.storeQuery('SELECT `loyalty_points` FROM `accounts` WHERE `id` = '..self:getAccountId())
if resultId ~= false then
loyaltyPoints = result.getNumber(resultId, 'loyalty_points')
result.free(resultId)
end
return loyaltyPoints
end
local Config = {
Setup = {
[{1, 2}] = { -- vocation 1,2 id
[{0, 200}] = { -- 0 to 200 loyalty
{skillPercent = 150, skillId = 1}; -- 50% magic
{skillPercent = 110, skillId = 5}...
tries = tries * configManager.getNumber(configKeys.RATE_MAGIC)
if self:getStorageValue(your_storage_here) > then
tries = tries * configManager.getNumber(configKeys.RATE_MAGIC) * 2
end
tries = tries * configManager.getNumber(configKeys.RATE_SKILL)
if self:getStorageValue(your_storage_here) > then
tries = tries * configManager.getNumber(configKeys.RATE_SKILL) * 2
end
You'll need to edit Player:OnGainSkillTries function inside player.lua
Below:
Lua:tries = tries * configManager.getNumber(configKeys.RATE_MAGIC)
add:
Lua:if self:getStorageValue(your_storage_here) > then tries = tries * configManager.getNumber(configKeys.RATE_MAGIC) * 2 end
and below:
Lua:tries = tries * configManager.getNumber(configKeys.RATE_SKILL)
add:
Lua:if self:getStorageValue(your_storage_here) > then tries = tries * configManager.getNumber(configKeys.RATE_SKILL) * 2 end
Not tested.
local loyalty_condition = Condition(CONDITION_ATTRIBUTES)
loyalty_condition:setParameter(CONDITION_PARAM_TICKS, -1)
loyalty_condition:setParameter(CONDITION_PARAM_SUBID, 10)
loyalty_condition:setParameter(CONDITION_PARAM_SKILL_MELEEPERCENT, 115)
local parameters = {
CONDITION_PARAM_STAT_MAGICPOINTSPERCENT, CONDITION_PARAM_SKILL_MELEEPERCENT, CONDITION_PARAM_SKILL_FISTPERCENT,
CONDITION_PARAM_SKILL_DISTANCEPERCENT, CONDITION_PARAM_SKILL_SHIELDPERCENT, CONDITION_PARAM_SKILL_FISHINGPERCENT
}
local loyalty = CreatureEvent("loyalty")
function loyalty.onLogin(player)
local resultId = db.storeQuery('SELECT `loyalty_points` from `accounts` where `id`='..getAccountNumberByPlayerName(getPlayerName(player)))
local LoyaltyStatus = result.getNumber(resultId, 'loyalty_points')
if LoyaltyStatus >= 360 then
for key, attr_key in pairs(parameters) do
loyalty_condition:setParameter(attr_key, 1.05) --- 5% +
end
end
if LoyaltyStatus >= 720 then
for key, attr_key in pairs(parameters) do
loyalty_condition:setParameter(attr_key, 1.10) ----- 10%
end
end
player:addCondition(loyalty_condition)
return true
end
loyalty:register()
I expressed myself wrong. I tried to make the code above the idea is if the LoyaltyStatus is greater than X it will add 5% more skills but it didn't work
function Player.getLoyaltyPoints(self)
local loyaltyPoints = 0
local resultId = db.storeQuery('SELECT `loyalty_points` FROM `accounts` WHERE `id` = '..self:getAccountId())
if resultId ~= false then
loyaltyPoints = result.getNumber(resultId, 'loyalty_points')
result.free(resultId)
end
return loyaltyPoints
end
local Config = {
Setup = {
[{1, 2}] = { -- vocation 1,2 id
[{0, 200}] = { -- 0 to 200 loyalty
{skillPercent = 150, skillId = 1}; -- 50% magic
{skillPercent = 110, skillId = 5}; -- 10% shield
-- skillIds
-- 1: magic - 2: melee - 3: fist - 4: dist - 5: shield - 6: fishing
}
}
};
Parameters = {
CONDITION_PARAM_STAT_MAGICPOINTSPERCENT, CONDITION_PARAM_SKILL_MELEEPERCENT, CONDITION_PARAM_SKILL_FISTPERCENT,
CONDITION_PARAM_SKILL_DISTANCEPERCENT, CONDITION_PARAM_SKILL_SHIELDPERCENT, CONDITION_PARAM_SKILL_FISHINGPERCENT
};
}
local condition = {}
for i = 1, #Config.Parameters do
condition[i] = Condition(CONDITION_ATTRIBUTES)
condition[i]:setParameter(CONDITION_PARAM_TICKS, -1)
end
local loyalty = CreatureEvent("loyalty")
function loyalty.onLogin(player)
local points = player:getLoyaltyPoints()
for k, v in pairs(Config.Setup) do
if isInArray(k, player:getVocation():getId()) then
for i, j in pairs(v) do
for x = 1, #j do
if points >= i[1] and points <= i[2] then
condition[j[x].skillId]:setParameter(CONDITION_PARAM_SUBID, 100 + j[x].skillId)
condition[j[x].skillId]:setParameter(Config.Parameters[j[x].skillId], j[x].skillPercent)
player:addCondition(condition[j[x].skillId])
end
end
end
end
end
return true
end
what I didn't understand is that putting for example 5% of skills is giving +3 of magic level for example the right thing would be to put 5% on the value of "skill_club_tries" for exampleLua:function Player.getLoyaltyPoints(self) local loyaltyPoints = 0 local resultId = db.storeQuery('SELECT `loyalty_points` FROM `accounts` WHERE `id` = '..self:getAccountId()) if resultId ~= false then loyaltyPoints = result.getNumber(resultId, 'loyalty_points') result.free(resultId) end return loyaltyPoints end local Config = { Setup = { [{1, 2}] = { -- vocation 1,2 id [{0, 200}] = { -- 0 to 200 loyalty {skillPercent = 150, skillId = 1}; -- 50% magic {skillPercent = 110, skillId = 5}; -- 10% shield -- skillIds -- 1: magic - 2: melee - 3: fist - 4: dist - 5: shield - 6: fishing } } }; Parameters = { CONDITION_PARAM_STAT_MAGICPOINTSPERCENT, CONDITION_PARAM_SKILL_MELEEPERCENT, CONDITION_PARAM_SKILL_FISTPERCENT, CONDITION_PARAM_SKILL_DISTANCEPERCENT, CONDITION_PARAM_SKILL_SHIELDPERCENT, CONDITION_PARAM_SKILL_FISHINGPERCENT }; } local condition = {} for i = 1, #Config.Parameters do condition[i] = Condition(CONDITION_ATTRIBUTES) condition[i]:setParameter(CONDITION_PARAM_TICKS, -1) end local loyalty = CreatureEvent("loyalty") function loyalty.onLogin(player) local points = player:getLoyaltyPoints() for k, v in pairs(Config.Setup) do if isInArray(k, player:getVocation():getId()) then for i, j in pairs(v) do for x = 1, #j do if points >= i[1] and points <= i[2] then condition[j[x].skillId]:setParameter(CONDITION_PARAM_SUBID, 100 + j[x].skillId) condition[j[x].skillId]:setParameter(Config.Parameters[j[x].skillId], j[x].skillPercent) player:addCondition(condition[j[x].skillId]) end end end end end return true end
You must configure the config according to your needswhat I didn't understand is that putting for example 5% of skills is giving +3 of magic level for example the right thing would be to put 5% on the value of "skill_club_tries" for example
Setup = {
[{1, 2, 5, 6}] = { -- this is for sorcerers, druids
[{0, 200}] = {
{skillPercent = 105, skillId = 1};
{skillPercent = 110, skillId = 5};
}
-- this will give +5% magic and +10% shield
};
[{7, 8}] = { -- this is for knights
[{0, 200}] = {
{skillPercent = 105, skillId = 2};
}
-- this will give +5% skills
}
};
-- skillIds: 1: magic - 2: melee - 3: fist - 4: dist - 5: shield - 6: fishing
[{7, 8}] = { -- this is for knights
[{0, 200}] = { -- 0 to 200 lotalty points
{skillPercent = 105, skillId = 2};
};
-- this will give +5% skills
[{200, 400}] = { -- 200 to 400 lotalty points
{skillPercent = 110, skillId = 2};
};
-- this will give +10% skills
[{400, 600}] = { -- 400 to 600 lotalty points
{skillPercent = 115, skillId = 2};
{skillPercent = 105, skillId = 4};
{skillPercent = 125, skillId = 5};
}
-- this will give +15% skills, +5% fist, +25% shield
}