Skip to content

Commit

Permalink
Reward Exercise: Created config to manage receive reward exercise wea…
Browse files Browse the repository at this point in the history
…pon.
  • Loading branch information
elsongabriel committed Oct 5, 2023
1 parent aaf0e91 commit a060c21
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 10 deletions.
2 changes: 2 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ onlyPremiumAccount = false
-- NOTE: buyAolCommandFee will add fee when player buy aol by command (!aol), active changing value more than 0 (fee value. ex: 1 = 1gp aol will be 50001)
-- NOTE: buyBlessCommandFee will add fee when player buy bless by command (!bless), active changing value between 1 and 100 (fee percent. ex: 3 = 3%, 30 = 30%)
-- NOTE: teleportPlayerToVocationRoom will enable oressa to teleport player to his/her room vocation
-- NOTE: toggleReceiveReward = true, will enable players to choose one of reward exercise weapon by command !reward
weatherRain = false
thunderEffect = false
allConsoleLog = false
Expand All @@ -200,6 +201,7 @@ toggleTravelsFree = false
buyAolCommandFee = 0
buyBlessCommandFee = 0
teleportPlayerToVocationRoom = true
toggleReceiveReward = false

-- Teleport summon
-- Set to true will never remove the summon
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
local winReward = CreatureEvent("WinReward")

function winReward.onLogin(player)
if configManager.getBoolean(configKeys.TOGGLE_RECEIVE_REWARD) then
-- check user won exercise weapon and send message
if not table.contains({ TOWNS_LIST.DAWNPORT, TOWNS_LIST.DAWNPORT_TUTORIAL }, player:getTown():getId()) then
if player:getStorageValue(tonumber(Storage.PlayerWeaponReward)) ~= 1 then
player:sendTextMessage(MESSAGE_LOGIN, "You can receive an exercise weapon using command !reward")
end
end
end
return true
end

winReward:register()
7 changes: 0 additions & 7 deletions data-otservbr-global/scripts/creaturescripts/others/login.lua
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,6 @@ function playerLogin.onLogin(player)
onExerciseTraining[player:getId()] = nil
player:setTraining(false)
end

-- check user won exercise weapon and send message
if not table.contains({ TOWNS_LIST.DAWNPORT, TOWNS_LIST.DAWNPORT_TUTORIAL }, player:getTown():getId()) then
if player:getStorageValue(tonumber(Storage.PlayerWeaponReward)) ~= 1 then
player:sendTextMessage(MESSAGE_LOGIN, "You can receive an exercise weapon using command !reward")
end
end
return true
end

Expand Down
9 changes: 6 additions & 3 deletions data/scripts/talkactions/player/reward.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ local config = {
}

local function sendExerciseRewardModal(player)
local window = ModalWindow {
local window = ModalWindow({
title = "Exercise Reward",
message = 'choose a item'
}
message = "choose a item",
})
for _, it in pairs(config.items) do
local iType = ItemType(it.id)
if iType then
Expand Down Expand Up @@ -49,6 +49,9 @@ end

local exerciseRewardModal = TalkAction("!reward")
function exerciseRewardModal.onSay(player, words, param)
if not configManager.getBoolean(configKeys.TOGGLE_RECEIVE_REWARD) then
return true
end
if player:getStorageValue(config.storage) > 0 then
player:sendTextMessage(MESSAGE_LOOK, "You already received your exercise weapon reward!")
return true
Expand Down
2 changes: 2 additions & 0 deletions src/config/config_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ enum booleanConfig_t {
TOGGLE_MOUNT_IN_PZ,
TOGGLE_HOUSE_TRANSFER_ON_SERVER_RESTART,

TOGGLE_RECEIVE_REWARD,

LAST_BOOLEAN_CONFIG
};

Expand Down
2 changes: 2 additions & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ bool ConfigManager::load() {

boolean[TOGGLE_HOUSE_TRANSFER_ON_SERVER_RESTART] = getGlobalBoolean(L, "togglehouseTransferOnRestart", false);

boolean[TOGGLE_RECEIVE_REWARD] = getGlobalBoolean(L, "toggleReceiveReward", false);

loaded = true;
lua_close(L);
return true;
Expand Down
2 changes: 2 additions & 0 deletions src/lua/functions/core/game/config_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ void ConfigFunctions::init(lua_State* L) {
registerEnumIn(L, "configKeys", VIP_FAMILIAR_TIME_COOLDOWN_REDUCTION);

registerEnumIn(L, "configKeys", TOGGLE_HOUSE_TRANSFER_ON_SERVER_RESTART);

registerEnumIn(L, "configKeys", TOGGLE_RECEIVE_REWARD);
#undef registerEnumIn
}

Expand Down

0 comments on commit a060c21

Please sign in to comment.