• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Drop Exp when die

dunnish

New Member
Joined
Jun 18, 2009
Messages
277
Solutions
1
Reaction score
3
When players are Die on my server they loss like 5-10 lvls every death.
anyone know what i should update?

i have try to update.
Code:
UPDATE players SET loss_experience = 1, loss_mana = 1, loss_skills = 1, loss_items = 1;
and its dossnt work.

i want when a players dies they should lose like 20% exp just.
 
Code:
function onLogin(cid)
    registerCreatureEvent(cid, "GuildMotd")
    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "Idle")
    registerCreatureEvent(cid, "AdvanceEffect")
    doPlayerFeed(cid, 9999)
    return true
end

i tested to add
Code:
local loss = getConfigValue('deathLostPercent')

    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

but it didnt work :/
 
Last edited by a moderator:
Your multiplying a whole number if you want a percentage you have to use decimals
For instance lets say the experience they loose is 10 xp, you multiply that by 10 and instead of loosing 10 xp they loose 100 xp
If you wanted them to loose just 10% of the experience then you would need to multiply by 0.10
10 * 0.10 = 1
 
tested with
Code:
local loss = getConfigValue('deathLostPercent')

    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10 * 0.10 = 1)
    end
but this didnt work.
 
I think doPlayerSetLossPercent is 0-1000 so setting it to 500 should mean 50% of experience is lost for example.
 
tested with
Code:
local loss = getConfigValue('deathLostPercent')

    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10 * 0.10 = 1)
    end
but this didnt work.
I didn't say to copy my example and place it in as code, I am trying to help you understand how to get a percentage.
 
nothing of this is working.

thx for trying atleast

Try debuging it:
Code:
    if(loss ~= nil) then
        print("LossPercent set")
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 0.1)
    end

Also check the value of "deathLostPercent" in the config.lua.
 
i got deathLostPercent = 1
in config.lua.

where should i find the text its trying to print?
could not find any in my tfs.
 
im getting this

f9f39df03f50df7f924c746472b92c04.png


sorry but i feel a bit noob :)
im going to sleep so will read tomorrow again.
thx for helping.
 
Ok your script from top to bottom.
player logs in
set loss variable to the config value for deathLostPercent (you have this set to 1) P.S. this should be moved outside of the function
check that loss is not nil (you have it set to 1 so it is not nil)
print message to confirm it is working (in your console we can see it works)
set the players loss percent to loss*0.1 P.S. this should not be loss*0.1 it should be loss*10 (as i stated before, the values for doPlayerSetLossPercent are 0-1000)
register shit
feed player shit
finish~

Once you fix the things I said, the question is how much experience do you want a player to lose?
If you want them to lose 0 levels on death, set the config value to 0
If you want them to lose all their levels on death, set the config value to 100
If you want them to lose half of their experience on death, set the config value to 50
If you want them to lose a set amount of LEVELS (not experience) remove this entire script and make a new onDeath script to remove x levels.
 
Back
Top