-- Register premium scroll action
local premiumScroll = Action()
premiumScroll:id(5546)
function premiumScroll.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local currentTime = os.time()
local currentPremiumTime = math.max(0, player:getPremiumEndsAt() - currentTime)
local days = 30
local secondsToAdd = days * 24 * 60 * 60
player:setPremiumEndsAt(currentTime + (currentPremiumTime + secondsToAdd))
-- Inform the player about the premium upgrade
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have been upgraded to premium account for 30 days!")
player:getPosition():sendMagicEffect(84)
-- Remove the premium scroll from the player's inventory
item:remove(1)
return true
end
premiumScroll:register()
-- Register premium scroll action
local weeklypremiumScroll = Action()
weeklypremiumScroll:id(5545)
function weeklypremiumScroll.onUse(player, item, fromPosition, target, toPosition, isHotkey)
-- local premiumDays = 7 -- Number of days to add as premium
-- Calculate the timestamp for the premium end time (in seconds)
-- local SECONDS_IN_DAY = 24 * 60 * 60
local timestamp = os.time() + (premiumDays * SECONDS_IN_DAY)
local currentTime = os.time()
local currentPremiumTime = math.max(0, player:getPremiumEndsAt() - currentTime)
local days = 7
local secondsToAdd = days * 24 * 60 * 60
player:setPremiumEndsAt(currentTime + (currentPremiumTime + secondsToAdd))
-- Set the premium end time for the player
-- player:setPremiumEndsAt(timestamp)
-- Inform the player about the premium upgrade
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have been upgraded to premium account for 7 days!")
player:getPosition():sendMagicEffect(80)
-- Remove the premium scroll from the player's inventory
item:remove(1)
return true
end
weeklypremiumScroll:register()