• 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!

Lua !bless makes people level 1 when they die

Rickolajten

Member
Joined
Jul 21, 2008
Messages
175
Reaction score
16
I did search and found some threads, tried everything and nothing worked.. so i'm curious what could be the cause of this.

I have tried setting all _loss in my database to 100, trying different scripts etc.. experimenting in my config, nothing works.

Everytime someone writes !bless and gets the bless, then goes and die he go from lvl 200 to 1, or 400 to 1.. level doesnt matter.

Using TFS 0.3.6

bless.lua

Code:
  local bless =  {1, 2, 3, 4, 5}
local cost = 50000
function onSay(cid, words, param)
    for i = 1, table.maxn(bless) do
        if(getPlayerBlessing(cid, bless[i])) then
            doPlayerSendCancel(cid, "You have already all blessings.")
            return TRUE
        end
    end

    if(doPlayerRemoveMoney(cid, cost) == TRUE) then
        for i = 1, table.maxn(bless) do
            doPlayerAddBlessing(cid, bless[i])
        end
        doCreatureSay(cid, "You are now blessed by the Five Gods!" ,19)
        doSendMagicEffect(getPlayerPosition(cid), 49)
    else
        doPlayerSendCancel(cid, "You don\'t have enough money.")
    end
    return TRUE
end


from talkactions.xml

Code:
<talkaction words="!bless" script="bless.lua"/>


from config

Code:
blessingOnlyPremium = false
    blessingReductionBase = 30
    blessingReductionDecreament = 5
    eachBlessReduction = 8

from creaturescripts.xml

Code:
function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
 
Last edited:
Hm I was expecting a typo in that part but it seems not, I have never used the standard bless system in the config however if you are looking for an easy work-around.

In config.lua you could set
Code:
deathLostPercent = nil
That will remove your current deathloss.

You should have a prepareDeath creatureevent, in that you could use
Code:
 doPlayerSetLossPercent
and
Code:
getPlayerBlessing

Basically making your own deathloss system. Note that this is a work-around and if someone knows how to properly use the standard deathloss located in the config that would be the better option.
 
Hm I was expecting a typo in that part but it seems not, I have never used the standard bless system in the config however if you are looking for an easy work-around.

In config.lua you could set
Code:
deathLostPercent = nil
That will remove your current deathloss.

You should have a prepareDeath creatureevent, in that you could use
Code:
 doPlayerSetLossPercent
and
Code:
getPlayerBlessing

Basically making your own deathloss system. Note that this is a work-around and if someone knows how to properly use the standard deathloss located in the config that would be the better option.

I love the fact that you actually took some time off and wrote this to me, unfortunately i'm not skilled enough to translate this into action yet, would you please point me in the right direction?

I got the part where i am supposed to change the deathlostpercent to nil, but how do i simply write a preparedeath creatureevent and what do i write where? If it helps, imagine yourself explaining this to a 3 year old toddler. :)
 
Well first things first, I noticed you are using a script that gives all 5 blessings at the same time. My question is, will players ever be able to purchase single blessings or will they always get all 5 at the same time?
I ask this because if players will always receive full blessings then we can skip the original blessing system all together and simply use a storage value to check if the player is blessed or not.

Secondly, check in your data folder for another folder called creaturescripts.
Inside that folder you should see a file called "creaturescripts.xml" open it
Inside that file you should see a list of events, the one you are looking for looks like this:
Code:
type="preparedeath"
If you find that check what file its using to handle the script, it should look something like this:
Code:
value="preparedeath.lua"
This will be the file name you are looking for, go back to your creaturescripts folder.
Inside you should find another folder called "scripts"
Locate the file that handles your prepare death (the file name you found earlier, in my example it was called preparedeath.lua)
Open that file and copy the contents here on the forum so I can read it.


P.S.
If anyone reading this knows how to fix the original bless system please jump in at any time before I have this man use a makeshift blessing system.
 
Well first things first, I noticed you are using a script that gives all 5 blessings at the same time. My question is, will players ever be able to purchase single blessings or will they always get all 5 at the same time?
I ask this because if players will always receive full blessings then we can skip the original blessing system all together and simply use a storage value to check if the player is blessed or not.

Secondly, check in your data folder for another folder called creaturescripts.
Inside that folder you should see a file called "creaturescripts.xml" open it
Inside that file you should see a list of events, the one you are looking for looks like this:
Code:
type="preparedeath"
If you find that check what file its using to handle the script, it should look something like this:
Code:
value="preparedeath.lua"
This will be the file name you are looking for, go back to your creaturescripts folder.
Inside you should find another folder called "scripts"
Locate the file that handles your prepare death (the file name you found earlier, in my example it was called preparedeath.lua)
Open that file and copy the contents here on the forum so I can read it.


P.S.
If anyone reading this knows how to fix the original bless system please jump in at any time before I have this man use a makeshift blessing system.

Sorry for the late response.

This is my creaturescripts.xml

Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
    <event type="login" name="PlayerLogin" event="script" value="login.lua"/>
    <event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/>
    <event type="receivemail" name="Mail" event="script" value="mail.lua"/>
    <event type="reportbug" name="SaveReportBug" script="reportbug.lua"/>
    <event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>
    <event type="login" name="FirstItems" script="firstitems.lua"/>
    <event type="kill" name="FragReward" script="fragreward.lua"/>
    <event type="logout" name="demonOakLogout" event="script" value="demonOakLogout.lua"/>
    <event type="death" name="demonOakDeath" event="script" value="demonOakDeath.lua"/>
    <event type="think" name="Idle" event="script" value="idle.lua"/>
    <event type="kill" name="MonsterPortal" event="script" value="portals.lua"/>
    <event type="kill" name="TopFrags" event="script" value="topfrags.lua"/>
    <event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/>
    <event type="advance" name="advanced" script="advanced.lua"/> 
    <event type="advance" name="advance" script="advance.lua"/> 
    <event type="death" name="Azerus" event="script" value="azerus.lua"/>
    <event type="outfit" name="Addons" event="script" value="addons.lua"/>
    <event type="login" name="AddonLogin" event="script" value="addons.lua"/>
    <event type="think" name="Criredric" event="script" value="criredric.lua"/> 
</creaturescripts>

No such file.


It's ok to buy all the blessings at the same time since its not a serious server in that meaning, im pretty sure the players appreciate having all blessings at the same time. :)

How to proceed my mentor?
 
Hey sorry I was away. Hope this helps, I tried to make the comments as clear as I could. Any questions/problems just ask :)

In creaturescripts.xml add:
Code:
<event type="preparedeath" name="blessings" event="script" value="blessings.lua"/>

Go to scripts folder

In login.lua

Add (near similar lines)
Code:
registerCreatureEvent(cid, "blessings")

Create new file named blessings.lua

Copy this into the file:
Code:
local blessingStorageValue = 12345 -- The storage value you will use to store a players blessings
local blessConfig = {
    [0] = { -- Experience Loss
        lossPercent = 10, -- % of experience a player will lose when dying WITHOUT blessings
        blessPercent = 5 -- % of experience a player will lose when dying WITH blessings
    },
    [1] = { -- Magic Level Loss
        lossPercent = 10, -- % of magic level a player will lose when dying WITHOUT blessings
        blessPercent = 5 -- % of magic level a player will lose when dying WITH blessings
    },
    [2] = { -- Skill Loss
        lossPercent = 10, -- % of skills a player will lose when dying WITHOUT blessings
        blessPercent = 5 -- % of skills a player will lose when dying WITH blessings
    },
    [3] = { -- Container Loss
        lossPercent = 100, -- % chance to lose backpack WITHOUT blessings
        blessPercent = 0 -- % chance to lose backpack WITH blessings
    },
    [4] = { -- Equipment Loss
        lossPercent = 10, -- % chance to lose each individual item equipped on a player WITHOUT blessings
        blessPercent = 0 -- % chance to lose each individual item equipped on a player WITH blessings
    }
}
function onPrepareDeath(cid, deathList)
    for i = 0, 4 do
        doPlayerSetLossPercent(cid, i, ((getCreatureStorage(cid, blessingStorageValue) > 0 and blessConfig[i].blessPercent*10) or blessConfig[i].lossPercent*10))
    end
    return true
end
Note that the config for this script might be a bit annoying to set up the first time around because I have set it up in a way that allows you to set the exact % values for each individual loss type. I wasn't sure how you wanted it in your server so this was the safest way to do it. Because of this, I tried to explain what each thing does in the comments as best I could. Hope you don't mind :)


In your bless.lua (talkaction) you will need to change the way it works, like so:
Code:
local config = {
    blessStorage = 12345, -- The storage value you will use to store a players blessings
    blessCost = 50000 -- The price of blessings
}
function onSay(cid, words, param)
    if(getCreatureStorage(cid, config.blessStorage) <= 0) then
        if(doPlayerRemoveMoney(cid, config.blessCost)) then
            doCreatureSetStorage(cid, config.blessStorage, 1)
            doCreatureSay(cid, "You are now blessed by the Five Gods!", 19)
            doSendMagicEffect(getPlayerPosition(cid), 49)
        else
            doPlayerSendCancel(cid, "You need ".. config.blessCost .."gp to buy blessings.")
        end
    else
        doPlayerSendCancel(cid, "You are already blessed.")
    end
    return true
end
 
Hey sorry I was away. Hope this helps, I tried to make the comments as clear as I could. Any questions/problems just ask :)

In creaturescripts.xml add:
Code:
<event type="preparedeath" name="blessings" event="script" value="blessings.lua"/>

Go to scripts folder

In login.lua

Add (near similar lines)
Code:
registerCreatureEvent(cid, "blessings")

Create new file named blessings.lua

Copy this into the file:
Code:
local blessingStorageValue = 12345 -- The storage value you will use to store a players blessings
local blessConfig = {
    [0] = { -- Experience Loss
        lossPercent = 10, -- % of experience a player will lose when dying WITHOUT blessings
        blessPercent = 5 -- % of experience a player will lose when dying WITH blessings
    },
    [1] = { -- Magic Level Loss
        lossPercent = 10, -- % of magic level a player will lose when dying WITHOUT blessings
        blessPercent = 5 -- % of magic level a player will lose when dying WITH blessings
    },
    [2] = { -- Skill Loss
        lossPercent = 10, -- % of skills a player will lose when dying WITHOUT blessings
        blessPercent = 5 -- % of skills a player will lose when dying WITH blessings
    },
    [3] = { -- Container Loss
        lossPercent = 100, -- % chance to lose backpack WITHOUT blessings
        blessPercent = 0 -- % chance to lose backpack WITH blessings
    },
    [4] = { -- Equipment Loss
        lossPercent = 10, -- % chance to lose each individual item equipped on a player WITHOUT blessings
        blessPercent = 0 -- % chance to lose each individual item equipped on a player WITH blessings
    }
}
function onPrepareDeath(cid, deathList)
    for i = 0, 4 do
        doPlayerSetLossPercent(cid, i, ((getCreatureStorage(cid, blessingStorageValue) > 0 and blessConfig[i].blessPercent*10) or blessConfig[i].lossPercent*10))
    end
    return true
end
Note that the config for this script might be a bit annoying to set up the first time around because I have set it up in a way that allows you to set the exact % values for each individual loss type. I wasn't sure how you wanted it in your server so this was the safest way to do it. Because of this, I tried to explain what each thing does in the comments as best I could. Hope you don't mind :)


In your bless.lua (talkaction) you will need to change the way it works, like so:
Code:
local config = {
    blessStorage = 12345, -- The storage value you will use to store a players blessings
    blessCost = 50000 -- The price of blessings
}
function onSay(cid, words, param)
    if(getCreatureStorage(cid, config.blessStorage) <= 0) then
        if(doPlayerRemoveMoney(cid, config.blessCost)) then
            doCreatureSetStorage(cid, config.blessStorage, 1)
            doCreatureSay(cid, "You are now blessed by the Five Gods!", 19)
            doSendMagicEffect(getPlayerPosition(cid), 49)
        else
            doPlayerSendCancel(cid, "You need ".. config.blessCost .."gp to buy blessings.")
        end
    else
        doPlayerSendCancel(cid, "You are already blessed.")
    end
    return true
end


I'm truley amazed, it worked.. the char didn't go to level 1. I got one issue though, i'm still losing the backpack (and possibly a random item every once and then?) nontheless, THANKS!
 
Hello! I did everything in this thread, but some people goes down to level 1. and blessings don't removes after death, anyone who know's how to fix it?
 
This is only script which works for me. Thnk you guys a lot. I have only one little problem when I buy !bless once, i am blessed all time in game, its like forever bless. How to change when I die then I need to buy again !bless. :) PEaCe! :D
Do u Fix ???>. Bump
 
Back
Top