• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.X Skills/ML/LVL loss LUA

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:
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
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)
 
idk a lot but after searching i found on sources the skill / ml loss




but idk what to do with this information :/
maybe it help someone to help us

is anyone know what is wrong?
is it easy to do this stuff on sources?
 
You mean to edit loss formula in C++ OR to add call from C++ to LUA to get values?

I don't know what u mean call C++ to LUA to get values
I would like to have a "stages" skill/lvl/ml loss more controlled

Code:
    elseif(playerLvl >= 21 and playerLvl <= 50) then levelLoss = 2
    elseif(playerLvl >= 51 and playerLvl <= 100) then levelLoss = 3

Lvl 21-50 when die loss 2 levels
Lvl 51-100 when die loss 3 levels


I tried to do it on LUA because i thought i could manage to make it work, but i couldn't
Idk how to edit the sources, but if this is the way i would like to know how to do it there
 
I found a problem, skulll == should be getCreatureSkullType(cid)

I've change, but the problem still happen

When you die, your EXP set to 0
ml,sword,axe,club,dist set to 0 too

script for now:
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(getCreatureSkullType(cid) == SKULL_RED) then levelLoss = levelLoss * 1.5
    elseif(getCreatureSkullType(cid) == 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(getCreatureSkullType(cid) == SKULL_RED) then skillLoss = skillLoss * 1.5
    elseif(getCreatureSkullType(cid) == 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(getCreatureSkullType(cid) == SKULL_RED) then mlLoss = mlLoss * 1.5
    elseif(getCreatureSkullType(cid) == 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

just this errors on console:
Code:
[12:7:43.437] [Error - CreatureScript Interface] 
[12:7:43.437] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.437] Description: 
[12:7:43.437] (luaGetCreatureSkullType) Creature not found

[12:7:43.437] [Error - CreatureScript Interface] 
[12:7:43.437] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.437] Description: 
[12:7:43.437] (luaGetCreatureSkullType) Creature not found

[12:7:43.437] [Error - CreatureScript Interface] 
[12:7:43.438] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.438] Description: 
[12:7:43.438] (luaGetCreatureSkullType) Creature not found

[12:7:43.438] [Error - CreatureScript Interface] 
[12:7:43.438] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.438] Description: 
[12:7:43.438] (luaGetCreatureSkullType) Creature not found

[12:7:43.487] [Error - CreatureScript Interface] 
[12:7:43.487] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.487] Description: 
[12:7:43.487] (luaGetCreatureSkullType) Creature not found

[12:7:43.487] [Error - CreatureScript Interface] 
[12:7:43.487] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.487] Description: 
[12:7:43.487] (luaGetCreatureSkullType) Creature not found

[12:7:43.529] [Error - CreatureScript Interface] 
[12:7:43.529] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.529] Description: 
[12:7:43.529] (luaGetCreatureSkullType) Creature not found

[12:7:43.529] [Error - CreatureScript Interface] 
[12:7:43.529] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.529] Description: 
[12:7:43.529] (luaGetCreatureSkullType) Creature not found

[12:7:43.571] [Error - CreatureScript Interface] 
[12:7:43.571] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.571] Description: 
[12:7:43.571] (luaGetCreatureSkullType) Creature not found

[12:7:43.571] [Error - CreatureScript Interface] 
[12:7:43.571] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.571] Description: 
[12:7:43.571] (luaGetCreatureSkullType) Creature not found

[12:7:43.613] [Error - CreatureScript Interface] 
[12:7:43.613] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.613] Description: 
[12:7:43.613] (luaGetCreatureSkullType) Creature not found

[12:7:43.613] [Error - CreatureScript Interface] 
[12:7:43.613] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.613] Description: 
[12:7:43.613] (luaGetCreatureSkullType) Creature not found

[12:7:43.654] [Error - CreatureScript Interface] 
[12:7:43.654] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.654] Description: 
[12:7:43.654] (luaGetCreatureSkullType) Creature not found

[12:7:43.654] [Error - CreatureScript Interface] 
[12:7:43.654] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.654] Description: 
[12:7:43.654] (luaGetCreatureSkullType) Creature not found

[12:7:43.696] [Error - CreatureScript Interface] 
[12:7:43.696] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.696] Description: 
[12:7:43.696] (luaGetCreatureSkullType) Creature not found

[12:7:43.696] [Error - CreatureScript Interface] 
[12:7:43.696] data/creaturescripts/scripts/death_loss_lua.lua:onDeath
[12:7:43.696] Description: 
[12:7:43.696] (luaGetCreatureSkullType) Creature not found

pls someone help!
 
Last edited:
I fix the errors on console, but when players die it still setting sword,axe,club,ml skill to 0 and exp to 0 too

Code:
function GetLevelLoss(cid, 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(getCreatureSkullType(cid) == SKULL_RED) then levelLoss = levelLoss * 1.5
    elseif(getCreatureSkullType(cid) == SKULL_BLACK) then levelLoss = levelLoss * 3.0
    end
    return levelLoss
end
function SetPlayerLevel(cid, lvl)
    doPlayerAddExperience(cid, getExperienceForLevel(lvl) - getPlayerExperience(cid))
end

function GetSkillLoss(cid, 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(getCreatureSkullType(cid) == SKULL_RED) then skillLoss = skillLoss * 1.5
    elseif(getCreatureSkullType(cid) == SKULL_BLACK) then skillLoss = skillLoss * 3.0
    end
    return skillLoss
end

function GetMagicLevelLoss(cid, 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(getCreatureSkullType(cid) == SKULL_RED) then mlLoss = mlLoss * 1.5
    elseif(getCreatureSkullType(cid) == 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(cid, currentLevel)
    local newLvl = currentLevel - (lvlLoss / reductionsValue)
    SetPlayerLevel(cid, newLvl)

    -- (2) SET ML LOSS
    local currentMagic = getPlayerMagLevel(cid)
    local mlLoss = GetMagicLevelLoss(cid, 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(cid, currentSkill)
        local newSkill = currentSkill - (skillLoss / reductionsValue)
        doPlayerSetSkillLevel(cid, skills[i], newSkill)
    end

    return true
end
 
It would be amazing to use together with ping functions to protect players when die lagged
 
It would be amazing to use together with ping functions to protect players when die lagged

i wanna use a lot stuff like that...
is it possible to do deathloss on lua guys?
 
I think it can be a good idea...

I tried to go in your way instead of mine:

Code:
function GetLevelLoss(cid, playerLvl)
    local levelLoss = 0
    -- get lvl lose
    if(playerLvl >= 1 and playerLvl <= 50) then levelLoss = 2
    elseif(playerLvl >= 51 and playerLvl <= 100) then levelLoss = 3
    elseif(playerLvl >= 101 and playerLvl <= 200) then levelLoss = 4
    elseif(playerLvl >= 201) then
        levelLoss = 5
    end
    -- skull incrise SKILLS loss
    if(getCreatureSkullType(cid) == SKULL_RED) then levelLoss = levelLoss * 2
    elseif(getCreatureSkullType(cid) == SKULL_BLACK) then levelLoss = levelLoss * 3
    end
    return levelLoss
end

function GetSkillLoss(cid, skillsLvl)
    local skillLoss = 0
    -- get skill lose SKILLS
    if(skillsLvl >= 1 and skillsLvl <= 40) then skillLoss = 2
    elseif(skillsLvl >= 41 and skillsLvl <= 70) then skillLoss = 3
    elseif(skillsLvl >= 71 and skillsLvl <= 100) then skillLoss = 4
    elseif(skillsLvl >= 101) then skillLoss = 5
    end
    -- skull incrise SKILLS loss
    if(getCreatureSkullType(cid) == SKULL_RED) then skillLoss = skillLoss * 2
    elseif(getCreatureSkullType(cid) == SKULL_BLACK) then skillLoss = skillLoss * 3
    end
    return skillLoss
end

function GetMagicLevelLoss(cid, mlLvl)
    local mlLoss = 0
    -- get ml lose SKILLS
    if(mlLvl >= 1 and mlLvl <= 20) then mlLoss = 2
    elseif(mlLvl >= 21 and mlLvl <= 50) then mlLoss = 3
    elseif(mlLvl >= 51 and mlLvl <= 80) then mlLoss = 4
    elseif(mlLvl >= 81) then mlLoss = 5
    end
    -- skull incrise ML loss
    if(getCreatureSkullType(cid) == SKULL_RED) then mlLoss = mlLoss * 2
    elseif(getCreatureSkullType(cid) == SKULL_BLACK) then mlLoss = mlLoss * 3
    end
    return mlLoss
end

function GetDeathLossReductions(cid)
    local reductionsValue = 0.0
    -- get reduction bless
    local eachblessreduction = 0.2 -- 5 blesses... MAX = 1.0
    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 1.0 + 1.0 = (2.0)
    end
    -- arredondar pq a parada é int
    reductionsValue = math.floor(reductionsValue)
    return reductionsValue
end

function onPrepareDeath(cid, deathList)
    -- zero death loss (exp,skills,ml) [LAGGED]
    doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 0)
    doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
    doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)

    -- GET reductions
    local reductionsValue = GetDeathLossReductions(cid)

    -- SET LVL LOSS
    local currentLevel = getPlayerLevel(cid)
    local lvlLoss = GetMagicLevelLoss(cid, currentLevel)
    if reductionsValue > lvlLoss then
        lvlLoss = 1
    end
    doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, lvlLoss)

    -- SET ML LOSS
    local currentMagic = getPlayerMagLevel(cid)
    local mlLoss = GetMagicLevelLoss(cid, currentMagic)
    if reductionsValue > mlLoss then
        mlLoss = 1
    end
    doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, mlLoss)

    -- SET SKILL LOSS
    local skills = {
        SKILL_FIST,
        SKILL_CLUB,
        SKILL_AXE,
        SKILL_SWORD,
        SKILL_SHIELD,
        SKILL_DISTANCE
    }
    for i = 1, #skills do
        local currentSkill = getPlayerSkillLevel(cid, skills[i])
        local skillLoss = GetSkillLoss(cid, currentSkill)
        if reductionsValue > skillLoss then
            skillLoss = 1
        end
        doPlayerSetLossPercent(cid, i, skillLoss)
    end

    return true
end

but i'm not losing anything when i die...

why? what do i doing wrong?
 

Similar threads

Back
Top