-
-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created vip system functionality with some validations and improvements: • Adjusted store checking to sell VIP or premium; • Created configs and scripts; • Fixed and created validation to auto-loot flag enabled by each player. Features (Vip Accounts): • Gain more XP • Gain more loot • Gain more skill • Gain coins to be online • Gain tokens (customized) to be online • Toggle auto-loot exclusive • Reduce familiar cooldown time
- Loading branch information
1 parent
873f3ee
commit 88b08ad
Showing
37 changed files
with
741 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
local autoLoot = TalkAction("!autoloot") | ||
|
||
function autoLoot.onSay(player, words, param) | ||
if not configManager.getBoolean(configKeys.AUTOLOOT) then | ||
return false | ||
end | ||
if (configManager.getBoolean(configKeys.VIP_SYSTEM_ENABLED) and | ||
configManager.getBoolean(configKeys.VIP_AUTOLOOT_VIP_ONLY) and not player:isVip()) then | ||
player:sendCancelMessage("You need to be VIP to use this command!") | ||
return false | ||
end | ||
if param == "" then | ||
player:sendCancelMessage("You need to specify on/off param.") | ||
return false | ||
end | ||
if param == "on" then | ||
player:setStorageValue(STORAGEVALUE_AUTO_LOOT, 1) | ||
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully enabled your automatic looting!") | ||
elseif param == "off" then | ||
player:setStorageValue(STORAGEVALUE_AUTO_LOOT, 0) | ||
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully disabled your automatic looting!") | ||
end | ||
return true | ||
end | ||
|
||
autoLoot:separator(" ") | ||
autoLoot:register() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
local config = { | ||
activationMessage = 'You have received %s VIP days.', | ||
activationMessageType = MESSAGE_EVENT_ADVANCE, | ||
|
||
expirationMessage = 'Your VIP days ran out.', | ||
expirationMessageType = MESSAGE_STATUS_WARNING, | ||
|
||
outfits = {}, | ||
mounts = {}, | ||
} | ||
|
||
function Player.onRemoveVip(self) | ||
self:sendTextMessage(config.expirationMessageType, config.expirationMessage) | ||
|
||
for _, outfit in ipairs(config.outfits) do | ||
self:removeOutfit(outfit) | ||
end | ||
|
||
for _, mount in ipairs(config.mounts) do | ||
self:removeMount(mount) | ||
end | ||
|
||
local playerOutfit = self:getOutfit() | ||
if table.contains(config.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:setStorageValue(Storage.VipSystem.IsVip, 0) | ||
end | ||
|
||
function Player.onAddVip(self, days) | ||
self:sendTextMessage(config.activationMessageType, string.format(config.activationMessage, days)) | ||
|
||
for _, outfit in ipairs(config.outfits) do | ||
self:addOutfitAddon(outfit, 3) | ||
end | ||
|
||
for _, mount in ipairs(config.mounts) do | ||
self:removeMount(mount) | ||
end | ||
|
||
self:setStorageValue(Storage.VipSystem.IsVip, 1) | ||
end | ||
|
16 changes: 16 additions & 0 deletions
16
data-otservbr-global/scripts/creaturescripts/customs/vip.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
local playerLogin = CreatureEvent("VipLogin") | ||
|
||
function playerLogin.onLogin(player) | ||
if configManager.getBoolean(configKeys.VIP_SYSTEM_ENABLED) then | ||
local wasVip = player:getStorageValue(Storage.VipSystem.IsVip) == 1 | ||
if wasVip and not player:isVip() then player:onRemoveVip() end | ||
if not wasVip and player:isVip() then player:onAddVip(player:getVipDays()) end | ||
if player:isVip() then | ||
local days = player:getVipDays() | ||
player:sendTextMessage(MESSAGE_LOGIN, string.format('You have %s VIP day%s left.', (days == 0xFFFF and 'infinite amount of' or days), (days == 1 and '' or 's'))) | ||
end | ||
end | ||
return true | ||
end | ||
|
||
playerLogin:register() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
data-otservbr-global/scripts/globalevents/vip/online_coins.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
local config = { | ||
enabled = false, | ||
storage = Storage.VipSystem.OnlineCoinsGain, | ||
checkDuplicateIps = false, | ||
|
||
interval = 60 * 1000, | ||
|
||
-- per hour | system will calculate how many coins will be given and when | ||
-- put 0 in coinsPerHour.free to disable free from receiving coins | ||
coinsPerHour = { | ||
free = 1, | ||
vip = 5, | ||
}, | ||
|
||
-- system will distribute when the player accumulate x coins | ||
awardOn = 5, | ||
} | ||
|
||
local onlineCoinsEvent = GlobalEvent("GainCoinInterval") | ||
local runsPerHour = 3600 / (config.interval / 1000) | ||
|
||
local function coinsPerRun(coinsPerHour) | ||
return coinsPerHour / runsPerHour | ||
end | ||
|
||
function onlineCoinsEvent.onThink(interval) | ||
local players = Game.getPlayers() | ||
if #players == 0 then | ||
return true | ||
end | ||
|
||
local checkIp = {} | ||
for _, player in pairs(players) do | ||
if player:getAccountType() >= ACCOUNT_TYPE_GAMEMASTER then | ||
goto continue | ||
end | ||
|
||
local ip = player:getIp() | ||
if ip ~= 0 and (not config.checkDuplicateIps or not checkIp[ip]) then | ||
checkIp[ip] = true | ||
local remainder = math.max(0, player:getStorageValue(config.storage)) / 10000000 | ||
local coins = coinsPerRun(player:isVip() and config.coinsPerHour.vip or config.coinsPerHour.free) + remainder | ||
player:setStorageValue(config.storage, coins * 10000000) | ||
if coins >= config.awardOn then | ||
local coinsMath = math.floor(coins) | ||
player:addTibiaCoins(coinsMath, true) | ||
player:sendTextMessage(MESSAGE_STATUS_SMALL, string.format("Congratulations %s!\z You have received %d %s for being online.", player:getName(), coinsMath, "tibia coins")) | ||
player:setStorageValue(config.storage, (coins - coinsMath) * 10000000) | ||
end | ||
end | ||
|
||
:: continue :: | ||
end | ||
return true | ||
end | ||
|
||
if config.enabled then | ||
onlineCoinsEvent:interval(config.interval) | ||
onlineCoinsEvent:register() | ||
end |
Oops, something went wrong.