sucibob
Member
- Joined
- Mar 28, 2017
- Messages
- 128
- Reaction score
- 13
I found this script:
But there is a big problem on that, the rates not change by vocation
So knights for example always have a high magic level rate
I tried to fix but with no success, is anyone more with more experience could help me to put to work?
SCRIPTS:
data\creaturescripts\scripts\stagesconfig.lua
data\creaturescripts\scripts\skillstageslogin.lua
data\creaturescripts\scripts\skillstagesadvance.lua
ERRORS:
when i try to login with a rooker (vocation 0):
CreatureEvent - Skills & magic level stages
If boters on your server make mlvl/skill 100 at night and you cant catch them it should be useful. You can 'limit' mlvl/skill to dont let cheaters get 100-120 mlvl/skill, but normal players can easy get 60-80 skill. In game it show rate from config.lua * rate from stages Skill (sword) stages...
otland.net
But there is a big problem on that, the rates not change by vocation
So knights for example always have a high magic level rate
I tried to fix but with no success, is anyone more with more experience could help me to put to work?
SCRIPTS:
data\creaturescripts\scripts\stagesconfig.lua
Code:
-- Skill Stages Mages --
skillConfigM = {skill = getConfigValue('rateSkill'), magiclevel = getConfigValue('rateMagic')}
skillStagesM = {}
skillStagesM[SKILL_FIST] = {{0,0}}
skillStagesM[SKILL_CLUB] = {{0,0.5}}
skillStagesM[SKILL_SWORD] = {{0,0.5}}
skillStagesM[SKILL_AXE] = {{0,0.5}}
skillStagesM[SKILL_DISTANCE] = {{0,0.5}}
skillStagesM[SKILL_SHIELD] = {{0,3},{15,2},{25,1}}
--skillStagesM[SKILL_FISHING] = {{0,5},{60,4},{80,3},{100,2},{110,1}}
skillStagesM[SKILL__MAGLEVEL] = {{0,1.0},{20,2.0},{30,3.0},{40,1.5},{50,1},{60,0.5}}
-- Skill Stages Paladin --
skillConfigR = {skill = getConfigValue('rateSkill'), magiclevel = getConfigValue('rateMagic')}
skillStagesR = {}
skillStagesR[SKILL_FIST] = {{0,0}}
skillStagesR[SKILL_CLUB] = {{0,0.5}}
skillStagesR[SKILL_SWORD] = {{0,0.5}}
skillStagesR[SKILL_AXE] = {{0,0.5}}
skillStagesR[SKILL_DISTANCE] = {{0,3},{4,2},{9,1},{15,0.5}}
skillStagesR[SKILL_SHIELD] = {{0,3},{40,1},{60,0.5}}
--skillStagesR[SKILL_FISHING] = {{0,5},{60,4},{80,3},{100,2},{110,1}}
skillStagesR[SKILL__MAGLEVEL] = {{0,3},{4,2},{9,1},{15,0.5}}
-- Skill Stages Knight --
skillConfigW = {skill = getConfigValue('rateSkill'), magiclevel = getConfigValue('rateMagic')}
skillStagesW = {}
skillStagesW[SKILL_FIST] = {{0,0}}
skillStagesW[SKILL_CLUB] = {{0,3},{40,2},{60,1},{80,0.5}}
skillStagesW[SKILL_SWORD] = {{0,3},{40,2},{60,1},{80,0.5}}
skillStagesW[SKILL_AXE] = {{0,3},{40,2},{60,1},{80,0.5}}
skillStagesW[SKILL_DISTANCE] = {{0,0.5}}
skillStagesW[SKILL_SHIELD] = {{0,3},{40,2},{60,1},{80,0.5}}
--skillStagesW[SKILL_FISHING] = {{0,5},{60,4},{80,3},{100,2},{110,1}}
skillStagesW[SKILL__MAGLEVEL] = {{0,3},{4,2},{6,1},{9,0.5}}
-- Skill Stages Rooker (None) --
skillConfigN = {skill = getConfigValue('rateSkill'), magiclevel = getConfigValue('rateMagic')}
skillStagesN = {}
skillStagesN[SKILL_FIST] = {{0,0}}
skillStagesN[SKILL_CLUB] = {{0,5},{10,4},{15,3},{20,2},{25,1},{30,0.5}}
skillStagesN[SKILL_SWORD] = {{0,5},{10,4},{15,3},{20,2},{25,1},{30,0.5}}
skillStagesN[SKILL_AXE] = {{0,5},{10,4},{15,3},{20,2},{25,1},{30,0.5}}
skillStagesN[SKILL_DISTANCE] = {{0,5},{10,4},{15,3},{20,2},{25,1},{30,0.5}}
skillStagesN[SKILL_SHIELD] = {{0,5},{10,4},{15,3},{20,2},{25,1},{30,0.5}}
--skillStagesW[SKILL_FISHING] = {{0,5},{60,4},{80,3},{100,2},{110,1}}
skillStagesN[SKILL__MAGLEVEL] = {{0,0}}
showInfoOnAdvance = true -- send player message about skill rate change
showInfoOnLogin = true -- send player message about skill rates when he login
function getPlayerSkillRatesText(cid)
local skillInfo = getPlayerRates(cid)
if isMage(cid) then
return "YOUR RATES: [ Magic Level: " .. skillInfo[SKILL__MAGLEVEL] * skillConfigM.magiclevel .. "x || Fist: " .. skillInfo[SKILL_FIST] * skillConfigM.skill .. "x | Club: " .. skillInfo[SKILL_CLUB] * skillConfigM.skill .. "x | Sword: " .. skillInfo[SKILL_SWORD] * skillConfigM.skill .. "x | Axe: " .. skillInfo[SKILL_AXE] * skillConfigM.skill .. "x | Distance: " .. skillInfo[SKILL_DISTANCE] * skillConfigM.skill .. " | Shielding: " .. skillInfo[SKILL_SHIELD] * skillConfigM.skill .. "x | Fishing: " .. skillInfo[SKILL_FISHING] * skillConfigM.skill .. "x ]"
elseif isRanger(cid) then
return "YOUR RATES: [ Magic Level: " .. skillInfo[SKILL__MAGLEVEL] * skillConfigR.magiclevel .. "x || Fist: " .. skillInfo[SKILL_FIST] * skillConfigR.skill .. "x | Club: " .. skillInfo[SKILL_CLUB] * skillConfigR.skill .. "x | Sword: " .. skillInfo[SKILL_SWORD] * skillConfigR.skill .. "x | Axe: " .. skillInfo[SKILL_AXE] * skillConfigR.skill .. "x | Distance: " .. skillInfo[SKILL_DISTANCE] * skillConfigR.skill .. " | Shielding: " .. skillInfo[SKILL_SHIELD] * skillConfigR.skill .. "x | Fishing: " .. skillInfo[SKILL_FISHING] * skillConfigR.skill .. "x ]"
elseif isWarrior(cid) then
return "YOUR RATES: [ Magic Level: " .. skillInfo[SKILL__MAGLEVEL] * skillConfigW.magiclevel .. "x || Fist: " .. skillInfo[SKILL_FIST] * skillConfigW.skill .. "x | Club: " .. skillInfo[SKILL_CLUB] * skillConfigW.skill .. "x | Sword: " .. skillInfo[SKILL_SWORD] * skillConfigW.skill .. "x | Axe: " .. skillInfo[SKILL_AXE] * skillConfigW.skill .. "x | Distance: " .. skillInfo[SKILL_DISTANCE] * skillConfigW.skill .. " | Shielding: " .. skillInfo[SKILL_SHIELD] * skillConfigW.skill .. "x | Fishing: " .. skillInfo[SKILL_FISHING] * skillConfigW.skill .. "x ]"
elseif isRooker(cid) then
return "YOUR RATES: [ Magic Level: " .. skillInfo[SKILL__MAGLEVEL] * skillConfigN.magiclevel .. "x || Fist: " .. skillInfo[SKILL_FIST] * skillConfigN.skill .. "x | Club: " .. skillInfo[SKILL_CLUB] * skillConfigN.skill .. "x | Sword: " .. skillInfo[SKILL_SWORD] * skillConfigN.skill .. "x | Axe: " .. skillInfo[SKILL_AXE] * skillConfigN.skill .. "x | Distance: " .. skillInfo[SKILL_DISTANCE] * skillConfigN.skill .. " | Shielding: " .. skillInfo[SKILL_SHIELD] * skillConfigN.skill .. "x | Fishing: " .. skillInfo[SKILL_FISHING] * skillConfigN.skill .. "x ]"
end
end
data\creaturescripts\scripts\skillstageslogin.lua
Code:
dofile(getDataDir() .. "creaturescripts/scripts/stagesconfig.lua")
function onLogin(cid)
local voc = getPlayerVocation(cid)
-- Mage --
if isMage(cid) then
for skill, skillStageM in pairs(skillStagesM) do
if(skill >= 0 and skill <= 6) then
nowSkill = getPlayerSkillLevel(cid, skill)
else
nowSkill = getPlayerMagLevel(cid, true)
end
end
for i, skillRateInfoM in pairs(skillStageM) do
if(nowSkill >= skillRateInfoM[1]) then
skillRateM = skillRateInfoM[2]
else
break
end
end
doPlayerSetRate(cid, skill, skillRateM)
-- Paladin --
elseif isRanger(cid) then
for skill, skillStageP in pairs(skillStagesR) do
if(skill >= 0 and skill <= 6) then
nowSkill = getPlayerSkillLevel(cid, skill)
else
nowSkill = getPlayerMagLevel(cid, true)
end
end
for i, skillRateInfoP in pairs(skillStageP) do
if(nowSkill >= skillRateInfoP[1]) then
skillRateP = skillRateInfoP[2]
else
break
end
end
doPlayerSetRate(cid, skill, skillRateP)
-- Knight --
elseif isKnight(cid) then
for skill, skillStageK in pairs(skillStagesW) do
if(skill >= 0 and skill <= 6) then
nowSkill = getPlayerSkillLevel(cid, skill)
else
nowSkill = getPlayerMagLevel(cid, true)
end
end
for i, skillRateInfoK in pairs(skillStageK) do
if(nowSkill >= skillRateInfoK[1]) then
skillRateK = skillRateInfoK[2]
else
break
end
end
doPlayerSetRate(cid, skill, skillRateK)
elseif isRooker(cid) then
for skill, skillStageN in pairs(skillStageN) do
if(skill >= 0 and skill <= 6) then
nowSkill = getPlayerSkillLevel(cid, skill)
else
nowSkill = getPlayerMagLevel(cid, true)
end
end
for i, skillRateInfoW in pairs(skillStageN) do
if(nowSkill >= skillRateInfoW[1]) then
skillRateW = skillRateInfoW[2]
else
break
end
end
doPlayerSetRate(cid, skill, skillRateW)
end
if(showInfoOnLogin) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, getPlayerSkillRatesText(cid))
end
registerCreatureEvent(cid, "SkillStagesAdvance")
return TRUE
end
data\creaturescripts\scripts\skillstagesadvance.lua
Code:
dofile(getDataDir() .. "creaturescripts/scripts/stagesconfig.lua")
function onAdvance(cid, skill, oldLevel, newLevel)
-- Mage --
if isMage(cid) then
if(skillStagesM[skill] ~= nil) then
local skillRateM = 1
local oldRatesM = getPlayerRates(cid)
for i, skillRateInfoM in pairs(skillStagesM[skill]) do
if(newLevel >= skillRateInfoM[1]) then
skillRateM = skillRateInfoM[2]
else
break
end
end
doPlayerSetRate(cid, skill, skillRateM)
if(showInfoOnAdvance and skillRateM ~= oldRatesM[skill]) then
if(skill >= 0 and skill <= 6) then
configRateM = skillConfigM.skill
else
configRateM = skillConfigM.magiclevel
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerNewSkillRatesText(cid))
end
-- Paladin --
elseif isRanger(cid) then
if(skillStagesR[skill] ~= nil) then
local skillRateP = 1
local oldRatesP = getPlayerRates(cid)
for i, skillRateInfoP in pairs(skillStagesR[skill]) do
if(newLevel >= skillRateInfoP[1]) then
skillRateP = skillRateInfoP[2]
else
break
end
end
end
doPlayerSetRate(cid, skill, skillRateP)
if(showInfoOnAdvance and skillRateP ~= oldRatesP[skill]) then
if(skill >= 0 and skill <= 6) then
configRateP = skillConfigR.skill
else
configRateP = skillConfigR.magiclevel
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerNewSkillRatesText(cid))
-- Knight --
elseif isWarrior(cid) then
if(skillStagesW[skill] ~= nil) then
local skillRateW = 1
local oldRatesK = getPlayerRates(cid)
for i, skillRateInfoW in pairs(skillStagesW[skill]) do
if(newLevel >= skillRateInfoW[1]) then
skillRateW = skillRateInfoW[2]
else
break
end
end
doPlayerSetRate(cid, skill, skillRateW)
if(showInfoOnAdvance and skillRateW ~= oldRatesK[skill]) then
if(skill >= 0 and skill <= 6) then
configRateK = skillConfigW.skill
else
configRateK = skillConfigW.magiclevel
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerNewSkillRatesText(cid))
end
end
-- ROOKERS --
elseif isRooker(cid) then
if(skillStagesN[skill] ~= nil) then
local skillRateW = 1
local oldRatesK = getPlayerRates(cid)
for i, skillRateInfoW in pairs(skillStagesN[skill]) do
if(newLevel >= skillRateInfoW[1]) then
skillRateW = skillRateInfoW[2]
else
break
end
end
doPlayerSetRate(cid, skill, skillRateW)
if(showInfoOnAdvance and skillRateW ~= oldRatesK[skill]) then
if(skill >= 0 and skill <= 6) then
configRateK = skillConfigN.skill
else
configRateK = skillConfigN.magiclevel
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerNewSkillRatesText(cid))
end
end
return true
end
ERRORS:
when i try to login with a rooker (vocation 0):
Code:
[18:48:23.749] Mical has logged in.
[18:48:23.749] [Error - CreatureScript Interface]
[18:48:23.749] data/creaturescripts/scripts/skillstageslogin.lua:onLogin
[18:48:23.749] Description:
[18:48:23.749] data/creaturescripts/scripts/skillstageslogin.lua:57: bad argument #1 to 'pairs' (table expected, got nil)
[18:48:23.749] stack traceback:
[18:48:23.749] [C]: in function 'pairs'
[18:48:23.749] data/creaturescripts/scripts/skillstageslogin.lua:57: in function <data/creaturescripts/scripts/skillstageslogin.lua:3>
[18:48:23.815] Mical has logged out.