• 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 how to define X many skills/lvls loss when player death

zabuzo

Well-Known Member
Joined
Jun 10, 2016
Messages
238
Reaction score
54
how to make this rulles:
Code:
local totalblessreduction = 0.0
local eachblessreduction = 0.3 -- 5 blesses * eachblessreduction = 1.5
for i = 1, 5 do
    if(getPlayerBlessing(cid, bless[i])) then
        totalblessreduction += eachblessreduction
    end
end



if(skills >= 1 && skills <= 40) skillslose = 0.5
elseif(skills >= 41 && skills <= 60) skillslose = 1
elseif(skills >= 61 && skills <= 80) skillslose = 1.5
elseif(skills >= 81 && skills <= 90) skillslose = 2.0
elseif(skills >= 91 && skills <= 100) skillslose = 2.5
elseif(skills >= 101) skillslose = 3.0
elseif(skull == SKULL_RED) skillslose *= 1.5
elseif(skull == SKULL_BLACK) skillslose *= 3.0
skillslose -= totalblessreduction




if(ml >= 1 && ml <= 20) mllose = 0.5
elseif(ml >= 21 && ml <= 30) mllose = 1.0
elseif(ml >= 31 && ml <= 40) mllose = 1.5
elseif(ml >= 41 && ml <= 60) mllose = 2.0
elseif(ml >= 61 && ml <= 70) mllose = 2.5
elseif(ml >= 71) mllose = 3.0
elseif(skull == SKULL_RED) mllose *= 1.5
elseif(skull == SKULL_BLACK) mllose *= 3.0
mllose -= totalblessreduction
to define a X lvls/skills lose in Y skills like on this block /\


it can be done on LUA or it needs or is better with sources changes?

the only thing about skill loss and ml loss i found on sources are: (Fir3element/3777 (https://github.com/Fir3element/3777/blob/aef29d0ac94140c5d095cb1f55a34035e42746b3/src/player.cpp#L2321) AND Fir3element/3777 (https://github.com/Fir3element/3777/blob/aef29d0ac94140c5d095cb1f55a34035e42746b3/src/player.cpp#L2297))
 
I don't have much experience in tfs 0.4, but I believe you can do this by putting something like (in death function):
Example for maglvl:

Use this to get the current magic level:
Lua:
getPlayerMagLevel

And put a variable that you must configure before (I'll use mllose as an example):
Lua:
getPlayerMagLevel(cid) - mllose

But remember, you should change the sources after doing anything like that, so you don't have duplicate information. (Lose the skill through sources and by lua script)
 
U guys mean something like this?
Code:
 function onDeath(cid, corpse, deathList)
    -- zerar perdas
    doPlayerSetLossSkill(cid, 0)

    -- get reduction bless
    local totalblessreduction = 0.0
    local eachblessreduction = 0.3 -- 5 blesses * eachblessreduction = 1.5
    for i = 1, 5 do
        if(getPlayerBlessing(cid, bless[i])) then
            totalblessreduction += eachblessreduction
        end
    end
    -- get reduction VIP
    if isPremium(cid) then
        totalblessreduction += 0.5 -- podendo chegar a 2.0
    end

    -- get skill lose SKILLS
    if(skills >= 1 && skills <= 15) skillslose = 0.10
    elseif(skills >= 16 && skills <= 25) skillslose = 0.25
    elseif(skills >= 26 && skills <= 40) skillslose = 0.5
    elseif(skills >= 41 && skills <= 60) skillslose = 1
    elseif(skills >= 61 && skills <= 80) skillslose = 1.5
    elseif(skills >= 81 && skills <= 90) skillslose = 2.0
    elseif(skills >= 91 && skills <= 100) skillslose = 2.5
    elseif(skills >= 101) skillslose = 3.0
    -- get skill lose SKULLS
    if(skull == SKULL_RED) skillslose *= 1.5
    elseif(skull == SKULL_BLACK) skillslose *= 3.0
    
    -- get ml lose SKILLS
    if(ml >= 1 && ml <= 5) mllose = 0.10
    elseif(ml >= 6 && ml <= 15) mllose = 0.25
    elseif(ml >= 16 && ml <= 20) mllose = 0.5
    elseif(ml >= 21 && ml <= 30) mllose = 1.0
    elseif(ml >= 31 && ml <= 40) mllose = 1.5
    elseif(ml >= 41 && ml <= 60) mllose = 2.0
    elseif(ml >= 61 && ml <= 70) mllose = 2.5
    elseif(ml >= 71) mllose = 3.0
    -- get ml lose SKULLS
    if(skull == SKULL_RED) mllose *= 1.5
    elseif(skull == SKULL_BLACK) mllose *= 3.0


    -- set reduction
    skillslose -= totalblessreduction
    mllose -= totalblessreduction

    -- GET SKILLS
    local currentMagic = getPlayerMagLevel(cid, true)

    local currentSkill[]
    for i = 1, #skills do
        local currentSkill[i] = getPlayerSkillLevel(cid, skills[i])
    end

    -- SET SKILLS
    local newMagic = currentMagic-mllose
    doPlayerSetMagicLevel(cid, newMagic)
    for i = 1, #skills do
        newSkill[i] = currentSkill[i] - skillslose
        doPlayerSetSkillLevel(cid, skills[i], newSkill[i])
    end

    return TRUE
end

It shouldn't work with 0.XXX numbers :(
And its not fair always remove a int from skill/ml
 
This is very poorly written and I believe that you will not be able to do what you want with it. There is a lot of strange thing about it.
Like:
Lua:
doPlayerSetLossSkill(cid, 0) -- Will run without loss skills?
_______________________________________________________________________________________________________________________________________________________________

Configs without closing parameters (&& As far as I know it's PHP):
Lua:
    if(skills >= 1 && skills <= 15) skillslose = 0.10
    elseif(skills >= 16 && skills <= 25) skillslose = 0.25
    elseif(skills >= 26 && skills <= 40) skillslose = 0.5
    elseif(skills >= 41 && skills <= 60) skillslose = 1
    elseif(skills >= 61 && skills <= 80) skillslose = 1.5
    elseif(skills >= 81 && skills <= 90) skillslose = 2.0
    elseif(skills >= 91 && skills <= 100) skillslose = 2.5
    elseif(skills >= 101) skillslose = 3.0

The correct would be:
Lua:
    if(skills >= 1 and skills <= 15) then
        skillslose = 0.10
    elseif(skills >= 16 and skills <= 25) then
        skillslose = 0.25
    elseif(skills >= 26 and skills <= 40) then
        skillslose = 0.5
    elseif(skills >= 41 and skills <= 60) then
        skillslose = 1
    elseif(skills >= 61 and skills <= 80) then
        skillslose = 1.5
    elseif(skills >= 81 and skills <= 90) then
        skillslose = 2.0
    elseif(skills >= 91 and skills <= 100) then
        skillslose = 2.5
    elseif(skills >= 101) then
        skillslose = 3.0
    end

And others script construction issues ...

Btw, I strongly recommend that you look for a new script or try to create it yourself.
 
This is very poorly written and I believe that you will not be able to do what you want with it. There is a lot of strange thing about it.
Like:
Lua:
doPlayerSetLossSkill(cid, 0) -- Will run without loss skills?
_______________________________________________________________________________________________________________________________________________________________

Configs without closing parameters (&& As far as I know it's PHP):
Lua:
    if(skills >= 1 && skills <= 15) skillslose = 0.10
    elseif(skills >= 16 && skills <= 25) skillslose = 0.25
    elseif(skills >= 26 && skills <= 40) skillslose = 0.5
    elseif(skills >= 41 && skills <= 60) skillslose = 1
    elseif(skills >= 61 && skills <= 80) skillslose = 1.5
    elseif(skills >= 81 && skills <= 90) skillslose = 2.0
    elseif(skills >= 91 && skills <= 100) skillslose = 2.5
    elseif(skills >= 101) skillslose = 3.0

The correct would be:
Lua:
    if(skills >= 1 and skills <= 15) then
        skillslose = 0.10
    elseif(skills >= 16 and skills <= 25) then
        skillslose = 0.25
    elseif(skills >= 26 and skills <= 40) then
        skillslose = 0.5
    elseif(skills >= 41 and skills <= 60) then
        skillslose = 1
    elseif(skills >= 61 and skills <= 80) then
        skillslose = 1.5
    elseif(skills >= 81 and skills <= 90) then
        skillslose = 2.0
    elseif(skills >= 91 and skills <= 100) then
        skillslose = 2.5
    elseif(skills >= 101) then
        skillslose = 3.0
    end

And others script construction issues ...

Btw, I strongly recommend that you look for a new script or try to create it yourself.

doPlayerSetLossSkill
sets skills loss to 0, lvl/skills

i tried to do it by myserlf, but idk, thats why i make the topic :(

Code:
function onDeath(cid, corpse, deathList)
    -- 0 no drop skills and level for source default
    doPlayerSetLossSkill(cid, 0)

    -- get reduction bless
    local totalblessreduction = 0.0
    local eachblessreduction = 0.3 -- 5 blesses * eachblessreduction -> MAX= 1.5
    for i = 1, 5 do
        if(getPlayerBlessing(cid, bless[i])) then
            totalblessreduction += eachblessreduction
        end
    end
    -- get reduction VIP
    if isPremium(cid) then
        totalblessreduction += 0.5 -- MAX= 2.0
    end

    -- get skill lose SKILLS
    if(skills >= 1 and skills <= 15) skillslose = 0.10
    elseif(skills >= 16 and skills <= 25) skillslose = 0.25
    elseif(skills >= 26 and skills <= 40) skillslose = 0.5
    elseif(skills >= 41 and skills <= 60) skillslose = 1
    elseif(skills >= 61 and skills <= 80) skillslose = 1.5
    elseif(skills >= 81 and skills <= 90) skillslose = 2.0
    elseif(skills >= 91 and skills <= 100) skillslose = 2.5
    elseif(skills >= 101) skillslose = 3.0
    -- get skill lose SKULLS
    if(skull == SKULL_RED) skillslose *= 1.5
    elseif(skull == SKULL_BLACK) skillslose *= 3.0
   
    -- get ml lose SKILLS
    if(ml >= 1 and ml <= 5) mllose = 0.10
    elseif(ml >= 6 and ml <= 15) mllose = 0.25
    elseif(ml >= 16 and ml <= 20) mllose = 0.5
    elseif(ml >= 21 and ml <= 30) mllose = 1.0
    elseif(ml >= 31 and ml <= 40) mllose = 1.5
    elseif(ml >= 41 and ml <= 60) mllose = 2.0
    elseif(ml >= 61 and ml <= 70) mllose = 2.5
    elseif(ml >= 71) mllose = 3.0
    -- get ml lose SKULLS
    if(skull == SKULL_RED) mllose *= 1.5
    elseif(skull == SKULL_BLACK) mllose *= 3.0


    -- set reduction
    skillslose -= totalblessreduction
    mllose -= totalblessreduction

    -- GET SKILLS
    local currentMagic = getPlayerMagLevel(cid, true)

    local currentSkill[]
    for i = 1, #skills do
        local currentSkill[i] = getPlayerSkillLevel(cid, skills[i])
    end

    -- SET SKILLS
    local newMagic = currentMagic-mllose
    doPlayerSetMagicLevel(cid, newMagic)
    for i = 1, #skills do
        newSkill[i] = currentSkill[i] - skillslose
        doPlayerSetSkillLevel(cid, skills[i], newSkill[i])
    end

    return TRUE
end

is any one know how to deal with 0.X numbers? and also with 1.X, 2.X... (float numbers)
Its not fair to always remove a int number from skill/ml
 
i would like to use this so much but somehow we need to convert this skillslose to skillTries
i also would add it for level (experience)
it would be amazing to have more control to exp/skill/ml loss on death especially make it work on lua :)
if someone experient got time pls post here
it can be useful for so many people
 
i tried to put it to run, but not work :(


i tried to die with a mage
lvl 24, ml28, skills 0

when i die no errors was printed on console, but player become
lvl 1
ml 0


full script 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(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

help pls
 
Back
Top