zabuzo
Well-Known Member
- Joined
- Jun 10, 2016
- Messages
- 238
- Reaction score
- 54
i wanna control on LUA exacly how many EXP/SKILL/ML numbers and % in LUA script
how to do it?
i tried this script:
but it not work :/ i've die with a mage
lvl 24, ml28
when i die it not print any errors on console, but player become
lvl 1, ml 0, alll skills 0
source code (if it helps): Fir3element/3777 (https://github.com/Fir3element/3777/tree/master/src)
how to do it?
i tried this script:
Code:
function GetLevelLoss(playerLvl)
local levelLoss = 0.0
-- get lvl lose
if(playerLvl >= 1 and playerLvl <= 10) then levelLoss = 0.10
elseif(playerLvl >= 11 and playerLvl <= 20) then levelLoss = 1
elseif(playerLvl >= 21 and playerLvl <= 50) then levelLoss = 2
elseif(playerLvl >= 51 and playerLvl <= 100) then levelLoss = 3
elseif(playerLvl >= 101) then
levelLoss = 3.0 + ((playerLvl - 100) / 50) -- each 50 lvls + 1 (150=4, 200=5, 250=6...)
end
-- skull incrise SKILLS loss
if(skull == SKULL_RED) then levelLoss = levelLoss * 1.5
elseif(skull == SKULL_BLACK) then levelLoss = levelLoss * 3.0
end
return levelLoss
end
function SetPlayerLevel(cid, lvl)
doPlayerAddExperience(cid, getExperienceForLevel(lvl) - getPlayerExperience(cid))
end
function GetSkillLoss(skillsLvl)
local skillLoss = 0.0
-- get skill lose SKILLS
if(skillsLvl >= 1 and skillsLvl <= 15) then skillLoss = 0.10
elseif(skillsLvl >= 16 and skillsLvl <= 25) then skillLoss = 0.25
elseif(skillsLvl >= 26 and skillsLvl <= 40) then skillLoss = 0.5
elseif(skillsLvl >= 41 and skillsLvl <= 60) then skillLoss = 1
elseif(skillsLvl >= 61 and skillsLvl <= 80) then skillLoss = 1.5
elseif(skillsLvl >= 81 and skillsLvl <= 90) then skillLoss = 2.0
elseif(skillsLvl >= 91 and skillsLvl <= 100) then skillLoss = 2.5
elseif(skillsLvl >= 101) then skillLoss = 3.0
end
-- skull incrise SKILLS loss
if(skull == SKULL_RED) then skillLoss = skillLoss * 1.5
elseif(skull == SKULL_BLACK) then skillLoss = skillLoss * 3.0
end
return skillLoss
end
function GetMagicLevelLoss(mlLvl)
local mlLoss = 0.0
-- get ml lose SKILLS
if(mlLvl >= 1 and mlLvl <= 5) then mlLoss = 0.10
elseif(mlLvl >= 6 and mlLvl <= 15) then mlLoss = 0.25
elseif(mlLvl >= 16 and mlLvl <= 20) then mlLoss = 0.5
elseif(mlLvl >= 21 and mlLvl <= 30) then mlLoss = 1.0
elseif(mlLvl >= 31 and mlLvl <= 40) then mlLoss = 1.5
elseif(mlLvl >= 41 and mlLvl <= 60) then mlLoss = 2.0
elseif(mlLvl >= 61 and mlLvl <= 70) then mlLoss = 2.5
elseif(mlLvl >= 71) then mlLoss = 3.0
end
-- skull incrise ML loss
if(skull == SKULL_RED) then mlLoss = mlLoss * 1.5
elseif(skull == SKULL_BLACK) then mlLoss = mlLoss * 3.0
end
return mlLoss
end
function GetDeathLossReductions(cid)
local reductionsValue = 0.0
-- get reduction bless
local eachblessreduction = 0.4 -- 5 blesses... MAX = 2
local bless = {1, 2, 3, 4, 5}
for i = 1, 5 do
if(getPlayerBlessing(cid, bless[i])) then
reductionsValue = reductionsValue + eachblessreduction
end
end
-- get reduction VIP
if isPremium(cid) then
reductionsValue = reductionsValue + 1.0 -- MAX 3.0
end
return reductionsValue
end
function onDeath(cid, corpse, deathList)
-- zero death loss (exp,skills,ml)
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 0)
doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)
-- GET reduction value
local reductionsValue = GetDeathLossReductions(cid)
-- (1) SET LVL LOSS
local currentLevel = getPlayerLevel(cid)
local lvlLoss = GetLevelLoss(currentLevel)
local newLvl = currentLevel - (lvlLoss / reductionsValue)
SetPlayerLevel(cid, newLvl)
-- (2) SET ML LOSS
local currentMagic = getPlayerMagLevel(cid)
local mlLoss = GetMagicLevelLoss(currentMagic)
local newMagic = currentMagic - (mlLoss / reductionsValue)
doPlayerSetMagicLevel(cid, newMagic)
-- (3) SET SKILL LOSS
-- get current skill
local skills = {
SKILL_FIST,
SKILL_CLUB,
SKILL_AXE,
SKILL_SWORD,
SKILL_SHIELD,
SKILL_DISTANCE
}
for i = 1, #skills do
-- get skill
local currentSkill = getPlayerSkillLevel(cid, skills[i])
-- set skill
local skillLoss = GetSkillLoss(currentSkill)
local newSkill = currentSkill - (skillLoss / reductionsValue)
doPlayerSetSkillLevel(cid, skills[i], newSkill)
end
return true
end
lvl 24, ml28
when i die it not print any errors on console, but player become
lvl 1, ml 0, alll skills 0
source code (if it helps): Fir3element/3777 (https://github.com/Fir3element/3777/tree/master/src)