Awesomedudei
Revolutionot.com
I have this creaturescript that automatically gives you blessings onLogin if you're Vip.
But i would like to instead of forcing players with VIP to get bless a way to enable/disable it for them.
But i would like to instead of forcing players with VIP to get bless a way to enable/disable it for them.
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