config = {
infoOnAdvance = true, -- send player message about skill rate change
infoOnLogin = true, -- send player message about skill rates when he login
msgColor = MESSAGE_STATUS_CONSOLE_ORANGE
}
SERVER_RATE_SR = getConfigValue('rateSkill')
SERVER_RATE_ML = getConfigValue('rateMagic')
CUSTOM_RATE_STAGES = {
-- Skill Stages Mage --
MAGE = {
[SKILL_FIST] = {{ 0, 1.0 }},
[SKILL_CLUB] = {{ 0, 1.0 }},
[SKILL_SWORD] = {{ 0, 1.0 }},
[SKILL_AXE] = {{ 0, 1.0 }},
[SKILL_DISTANCE] = {{ 0, 1.0 }},
[SKILL_SHIELD] = {{ 0, 3.0 },{ 15, 2.0 },{ 30, 1.0 }},
[SKILL__MAGLEVEL] = {{ 0, 3.0 },{ 15, 2.0 },{ 30, 1.0 }},
},
-- Skill Stages Paladin --
ARCHER = {
[SKILL_FIST] = {{ 0, 1.0 }},
[SKILL_CLUB] = {{ 0, 1.0 }},
[SKILL_SWORD] = {{ 0, 1.0 }},
[SKILL_AXE] = {{ 0, 1.0 }},
[SKILL_DISTANCE] = {{ 0, 3.0 },{ 40, 2.0 },{ 60, 1.0 }},
[SKILL_SHIELD] = {{ 0, 3.0 },{ 40, 2.0 },{ 60, 1.0 }},
[SKILL__MAGLEVEL] = {{ 0, 3.0 },{ 4, 2.0 },{ 9, 1.0 }},
},
-- Skill Stages Knight --
KNIGHT = {
[SKILL_FIST] = {{ 0, 1.0 }},
[SKILL_CLUB] = {{ 0, 3.0 },{ 40, 2.0 },{ 60, 1.0 }},
[SKILL_SWORD] = {{ 0, 0.9 },{ 40, 2.0 },{ 60, 1.0 }},
[SKILL_AXE] = {{ 0, 3.0 },{ 40, 2.0 },{ 60, 1.0 }},
[SKILL_DISTANCE] = {{ 0, 1.0 }},
[SKILL_SHIELD] = {{ 0, 3.0 },{ 40, 2.0 },{ 60, 1.0 }},
[SKILL__MAGLEVEL] = {{ 0, 3.0 },{ 4, 2.0 },{ 6, 1.0 }},
},
--SKILL_FISHING = {{0,5},{60,4},{80,3},{100,2},{110,1}}
}
function getPlayerSkillRatesText(cid)
local skillInfo = getPlayerRates(cid)
local packed = {
(skillInfo[SKILL__MAGLEVEL] * SERVER_RATE_ML),
(skillInfo[SKILL_FIST] * SERVER_RATE_SR),
(skillInfo[SKILL_CLUB] * SERVER_RATE_SR),
(skillInfo[SKILL_SWORD] * SERVER_RATE_SR),
(skillInfo[SKILL_AXE] * SERVER_RATE_SR),
(skillInfo[SKILL_DISTANCE] * SERVER_RATE_SR),
(skillInfo[SKILL_SHIELD] * SERVER_RATE_SR),
(skillInfo[SKILL_FISHING] * SERVER_RATE_SR)
}
local message = string.format("YOUR RATES: [ Magic Level: %sx || Fist: %sx | Club: %sx | Sword: %sx | Axe: %sx | Distance: %s | Shielding: %sx | Fishing: %sx ]", unpack(packed))
return message
end
function updatePlayerRates(cid, evented)
local oldRates = getPlayerRates(cid)
local function doRatings(class)
local classStages = CUSTOM_RATE_STAGES[class]
for skill, stages in pairs(classStages) do
local skillLevel = 0
if(skill >= 0 and skill <= 6) then
skillLevel = getPlayerSkillLevel(cid, skill)
else
-- if out of range, presume magic
skillLevel = getPlayerMagLevel(cid, true)
end
local skillRate = 1
-- gotta check cuz some are empty in the defaults like fishing
if(classStages[skill] ~= nil) then
for i, skillStage in pairs(stages) do
if(skillLevel >= skillStage[1]) then
skillRate = skillStage[2]
else
break
end
end
-- print("doPlayerSetRate -> [".. skill .."] [".. skillRate .."]")
print(skillRate)
doPlayerSetRate(cid, skill, skillRate)
end
end
return getPlayerRates(cid)
end
if (type(evented) == "string") then
doPlayerSendTextMessage(cid, config.msgColor, evented)
end
doRatings( getClass(cid) )
-- return oldRates, doRatings( getClass(cid), training)
return true
end