Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move vip system to data #2432

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion data-otservbr-global/lib/others/load.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
dofile(DATA_DIRECTORY .. "/lib/others/dawnport.lua")
dofile(DATA_DIRECTORY .. "/lib/others/vip_system.lua")
67 changes: 0 additions & 67 deletions data-otservbr-global/lib/others/vip_system.lua

This file was deleted.

1 change: 1 addition & 0 deletions data/libs/systems/load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ dofile(CORE_DIRECTORY .. "/libs/systems/hazard.lua")
dofile(CORE_DIRECTORY .. "/libs/systems/hireling.lua")
dofile(CORE_DIRECTORY .. "/libs/systems/raids.lua")
dofile(CORE_DIRECTORY .. "/libs/systems/reward_boss.lua")
dofile(CORE_DIRECTORY .. "/libs/systems/vip.lua")
dofile(CORE_DIRECTORY .. "/libs/systems/zones.lua")
62 changes: 62 additions & 0 deletions data/libs/systems/vip.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
-- Bonus mount and outfits
local outfits = {}
local mounts = {}

function Player.onRemoveVip(self)
elsongabriel marked this conversation as resolved.
Show resolved Hide resolved
self:sendTextMessage(MESSAGE_ADMINISTRATOR, "Your VIP days ran out.")

for _, outfit in ipairs(outfits) do
self:removeOutfit(outfit)
end

for _, mount in ipairs(mounts) do
self:removeMount(mount)
end

local playerOutfit = self:getOutfit()
if table.contains(outfits, self:getOutfit().lookType) then
if self:getSex() == PLAYERSEX_FEMALE then
playerOutfit.lookType = 136
else
playerOutfit.lookType = 128
end

playerOutfit.lookAddons = 0
self:setOutfit(playerOutfit)
end

self:kv():scoped("account"):remove("vip-system")
end

function Player.onAddVip(self, days, silent)
if not silent then
self:sendTextMessage(MESSAGE_ADMINISTRATOR, "You have received " .. days .. " VIP days.")
end

for _, outfit in ipairs(outfits) do
self:addOutfitAddon(outfit, 3)
end

for _, mount in ipairs(mounts) do
self:addMount(mount)
end

self:kv():scoped("account"):set("vip-system", true)
end

function CheckPremiumAndPrint(player, msgType)
local msg = ""

Check warning on line 48 in data/libs/systems/vip.lua

View workflow job for this annotation

GitHub Actions / luacheck

[luacheck] reported by reviewdog 🐶 value assigned to variable 'msg' is unused Raw Output: data/libs/systems/vip.lua:48:8: value assigned to variable 'msg' is unused

if player:getVipDays() == 0xFFFF then
msg = "You have infinite amount of VIP days left."
else
local playerVipTime = player:getVipTime()
if playerVipTime < os.time() then
msg = "You do not have VIP on your account."
else
msg = "You have " .. getFormattedTimeRemaining(playerVipTime) .. " of VIP time left."
end
end

player:sendTextMessage(MESSAGE_ADMINISTRATOR, msg)
end
Loading