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?
data\creaturescripts\scripts\ file stagesconfig.lua
In data\creaturescripts\scripts\ file skillstagesadvance.lua:
In data\creaturescripts\scripts\ file skillstageslogin.lua:
In data/creaturescripts/creaturescripts.xml
On player login i got this error, what is it?
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
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?
data\creaturescripts\scripts\ file 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)
return "YOUR RATES: [ Magic Level: " .. skillInfo[SKILL__MAGLEVEL] * skillConfig.magiclevel .. "x || Fist: " .. skillInfo[SKILL_FIST] * skillConfig.skill .. "x | Club: " .. skillInfo[SKILL_CLUB] * skillConfig.skill .. "x | Sword: " .. skillInfo[SKILL_SWORD] * skillConfig.skill .. "x | Axe: " .. skillInfo[SKILL_AXE] * skillConfig.skill .. "x | Distance: " .. skillInfo[SKILL_DISTANCE] * skillConfig.skill .. " | Shielding: " .. skillInfo[SKILL_SHIELD] * skillConfig.skill .. "x | Fishing: " .. skillInfo[SKILL_FISHING] * skillConfig.skill .. "x ]"
end
In data\creaturescripts\scripts\ file skillstagesadvance.lua:
Code:
dofile(getDataDir() .. "creaturescripts/scripts/stagesconfig.lua")
function isMage(cid)
local voc = getPlayerVocation(cid)
if voc == 1 or voc == 2 or voc == 5 or voc == 6 or voc == 9 or voc == 10 or voc == 13 or voc == 14 then
return true
else
return false
end
end
function isRanger(cid)
local voc = getPlayerVocation(cid)
if voc == 3 or voc == 7 or voc == 11 or voc == 15 then
return true
else
return false
end
end
function isWarrior(cid)
local voc = getPlayerVocation(cid)
if voc == 4 or voc == 8 or voc == 12 or voc == 6 or voc == 16 then
return true
else
return false
end
end
function isRooker(cid)
local voc = getPlayerVocation(cid)
if voc == 0 or voc == 17 or voc == 18 or voc == 19 or voc == 20 then
return true
else
return false
end
end
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
In data\creaturescripts\scripts\ file skillstageslogin.lua:
Code:
dofile(getDataDir() .. "creaturescripts/scripts/stagesconfig.lua")
function isMage(cid)
local voc = getPlayerVocation(cid)
if voc == 1 or voc == 2 or voc == 5 or voc == 6 or voc == 9 or voc == 10 or voc == 13 or voc == 14 then
return true
else
return false
end
end
function isRanger(cid)
local voc = getPlayerVocation(cid)
if voc == 3 or voc == 7 or voc == 11 or voc == 15 then
return true
else
return false
end
end
function isWarrior(cid)
local voc = getPlayerVocation(cid)
if voc == 4 or voc == 8 or voc == 12 or voc == 6 or voc == 16 then
return true
else
return false
end
end
function isRooker(cid)
local voc = getPlayerVocation(cid)
if voc == 0 or voc == 17 or voc == 18 or voc == 19 or voc == 20 then
return true
else
return false
end
end
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
In data/creaturescripts/creaturescripts.xml
Code:
<event type="login" name="SkillStagesLogin" event="script" value="skillstageslogin.lua"/>
<event type="advance" name="SkillStagesAdvance" event="script" value="skillstagesadvance.lua"/>
On player login i got this error, what is it?
Code:
[13:48:52.213] [Error - CreatureScript Interface]
[13:48:52.213] data/creaturescripts/scripts/skillstageslogin.lua:onLogin
[13:48:52.213] Description:
[13:48:52.213] data/creaturescripts/scripts/stagesconfig.lua:56: attempt to index global 'skillConfig' (a nil value)
[13:48:52.213] stack traceback:
[13:48:52.213] data/creaturescripts/scripts/stagesconfig.lua:56: in function 'getPlayerSkillRatesText'
[13:48:52.213] data/creaturescripts/scripts/skillstageslogin.lua:112: in function <data/creaturescripts/scripts/skillstageslogin.lua:39>