• 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 !blessings to protect 100% from level loss

Thaiwor

New Member
Joined
Mar 18, 2015
Messages
19
Reaction score
0
Hi OtLand, can anyone help me make blessings protect u 100% from losing levels?


Config.lua
Code:
    -- Blessings
    -- NOTE: blessingReduction* regards items/containers loss.
    -- eachBlessReduction is how much each bless reduces the experience/magic/skills loss.
    blessingOnlyPremium = true
    blessingReductionBase = 15
    blessingReductionDecreament = 5
    eachBlessReduction = 8
    blessings = true


Creaturescripts/scripts/blessings.lua

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 = 0 -- % 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 = 0 -- % 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 = 0 -- % of skills a player will lose when dying WITH blessings
    },
    [3] = { -- Container Loss
        lossPercent = 10, -- % 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,1,2,3,4 do
        doPlayerSetLossPercent(cid, i, ((getCreatureStorage(cid, blessingStorageValue) > 0 and blessConfig[i].blessPercent*0) or blessConfig[i].lossPercent*10))
    end
    return true







Talkactions/Scripts/blessings.lua
Code:
  function onSay(cid, words, param, channel)
        if getPlayerBlessing(cid, 5) == FALSE then
                if getPlayerMoney(cid) >= 100000 then
                        for i = 1,5 do
                                doPlayerAddBlessing(cid, i)
                        end
                        doSendMagicEffect(getCreaturePosition(cid), 39)
                        doPlayerRemoveMoney(cid, 100000)
                        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
                        doPlayerSendTextMessage(cid, 22, "You have been blessed by the gods!")
                else
                        doPlayerSendCancel(cid, "Sorry, but you dont have 10cc")
                        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
                end
        else
                doPlayerSendCancel(cid, "You have already been blessed.")
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        end
return true
end
 
well, considering the creaturescript uses a storage value to set the loss percent, just add
Code:
setPlayerStorageValue(cid, 12345, 1)
somewhere around this line in the talkaction:
Code:
doPlayerRemoveMoney(cid, 100000)

Can't see why that wouldn't work, but hey, who knows.
 
Back
Top