• 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 [TFS 1.3] Talkaction Auto Bless ifVip() with on/off toggle.

Awesomedudei

Revolutionot.com
Joined
Jan 20, 2010
Messages
444
Solutions
1
Reaction score
202
Location
Sweden
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.

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
 
Lua:
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"))

Sorry for spaces instead of tabs, but written on phone, put this in talkaction.
Then edit your script to check

Code:
if player:getStorageValue(9999) == 1 then
 
Last edited:
Back
Top