Hello everyone, I heartily need some help, namely I need an auto-bless script which will enable the player to turn on / turn off function. If a player falls and has to turn on the command, it automatically after death, when he logs in, buys him blessings - cash from the bank.
I found something like this:
And @Nekiro answered in this post something like this:
For any help rep++ 10.98 1.4.2
I found something like this:
Lua:
local blessings = {1, 2, 3, 4, 5}
function getCost(level)
if level <= 150 then
return 10000 * 2 -- 2cc 1 - 150 lvl
elseif level <= 200 then
return 10000 * 5 -- 5cc 150 - 200 lvl
elseif level >= 300 then
return 10000 * 20 -- 20cc - 300+ lvl
else
return ((level - 20) * 100 * 5) -- based on level 200-300
end
end
function onLogin(player)
if not player:hasBlessing(#blessings) and player:isVip() then
local cost = getCost(player:getLevel())
local moneyCount = player:getMoney()
local bankCount = player:getBankBalance()
if cost > moneyCount + bankCount then
player:sendCancelMessage("You need " .. cost .. " gold coins to buy all blessings.")
return true
end
player:removeMoney(math.min(cost, moneyCount))
if cost > moneyCount then
player:setBankBalance(bankCount - math.max(cost - moneyCount, 0))
if moneyCount == 0 then
player:sendTextMessage(
MESSAGE_INFO_DESCR,
("Paid %d gold from bank account. Your account balance is now %d gold."):format(cost, player:getBankBalance())
)
else
player:sendTextMessage(
MESSAGE_INFO_DESCR,
("Paid %d from inventory and %d gold from bank account. Your account balance is now %d gold."):format(
moneyCount,
cost - moneyCount,
player:getBankBalance()
)
)
end
end
for b = 1, #blessings do
player:addBlessing(b, 1)
end
player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been blessed by the gods!")
end
return true
end
And @Nekiro answered in this post something like this:
if not player:isVip() then
return true
end
-- switch the value
player:setStorageValue(9999, player:getStorageValue(9999) == -1 and 1 or -1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Automatic blessing buying is turned " .. (player:getStorageValue(9999) == 1 and "on" or "off"))
if player:getStorageValue(9999) == 1 then
For any help rep++ 10.98 1.4.2