I want Blessings to protect people from losing level to 100%
Everything with my scripts is working except that they lose 3 levels on dying.
Config.lua
Creaturescripts/scripts/blessings.lua
Talkactions/Scripts/blessings.lua
Everything with my scripts is working except that they lose 3 levels on dying.
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