From 72b73c4dd6b7ccafce27e618acf6e12c03ca1abe Mon Sep 17 00:00:00 2001 From: achmad Date: Fri, 29 May 2026 17:36:08 +0700 Subject: [PATCH] feat: replace CreateHTTPRequest with CreateHTTPRequestScriptVM Allows the game client to make HTTP API calls from a listen server (local lobby) instead of requiring a Steam dedicated server. CreateHTTPRequestScriptVM has the exact same API signature but works in both dedicated server and listen server contexts. Co-Authored-By: Claude Opus 4.8 (1M context) --- scripts/vscripts/arsenal/arsenalmanager.lua | 8 ++--- .../vscripts/arsenal/marketplacemanager.lua | 2 +- scripts/vscripts/battle_pass_server.lua | 24 +++++++------- scripts/vscripts/cards/cardsystem.lua | 12 +++---- scripts/vscripts/chat_wheel_grant.lua | 2 +- .../contracts/contract_backend_adapter.lua | 12 +++---- scripts/vscripts/contracts_manager.lua | 6 ++-- .../death_sentence/contracts_backend.lua | 4 +-- scripts/vscripts/equipment/api.lua | 6 ++-- scripts/vscripts/game_stats_tracker.lua | 4 +-- scripts/vscripts/gamemode.lua | 8 ++--- scripts/vscripts/leaderboard_server.lua | 2 +- scripts/vscripts/mini_profile_server.lua | 10 +++--- scripts/vscripts/player_profile_manager.lua | 2 +- scripts/vscripts/store_arcade_packs.lua | 6 ++-- scripts/vscripts/store_manager.lua | 32 +++++++++---------- 16 files changed, 70 insertions(+), 70 deletions(-) diff --git a/scripts/vscripts/arsenal/arsenalmanager.lua b/scripts/vscripts/arsenal/arsenalmanager.lua index 8a0137b..7f532a2 100644 --- a/scripts/vscripts/arsenal/arsenalmanager.lua +++ b/scripts/vscripts/arsenal/arsenalmanager.lua @@ -1382,7 +1382,7 @@ function ArsenalManagerClass.prototype.saveLoadoutsToServer(self, playerId) return end local data = self.loadouts[playerId] or ({}) - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "PUT", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/arsenal_loadouts" ) @@ -1420,7 +1420,7 @@ function ArsenalManagerClass.prototype.sendInventoryPutRequest(self, playerId) return end local data = {instances = self.instances[playerId] or ({})} - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "PUT", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/arsenal_inventory" ) @@ -1442,7 +1442,7 @@ function ArsenalManagerClass.prototype.loadFromServer(self, playerId) if not steamId then return end - local loadoutsReq = CreateHTTPRequest( + local loadoutsReq = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/arsenal_loadouts" ) @@ -1482,7 +1482,7 @@ function ArsenalManagerClass.prototype.loadFromServer(self, playerId) print((LOG_PREFIX .. " arsenal_loadouts GET fail: StatusCode=") .. tostring(result.StatusCode)) end end) - local invReq = CreateHTTPRequest( + local invReq = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/arsenal_inventory" ) diff --git a/scripts/vscripts/arsenal/marketplacemanager.lua b/scripts/vscripts/arsenal/marketplacemanager.lua index a11d9df..41da067 100644 --- a/scripts/vscripts/arsenal/marketplacemanager.lua +++ b/scripts/vscripts/arsenal/marketplacemanager.lua @@ -200,7 +200,7 @@ function MarketplaceManagerClass.prototype.callApi(self, method, url, body, cb) nil, (((((LOG_PREFIX .. " api -> ") .. method) .. " ") .. url) .. " body=") .. (body and json.encode(body) or "{}") ) - local req = CreateHTTPRequest(method, url) + local req = CreateHTTPRequestScriptVM(method, url) setApiHeaders(nil, req) if method == "POST" or method == "PUT" then req:SetHTTPRequestRawPostBody( diff --git a/scripts/vscripts/battle_pass_server.lua b/scripts/vscripts/battle_pass_server.lua index 3bd1a72..c8fa7b8 100644 --- a/scripts/vscripts/battle_pass_server.lua +++ b/scripts/vscripts/battle_pass_server.lua @@ -463,7 +463,7 @@ function BattlePassServer.prototype.onHeroSelected(self, playerId, heroName) local state = self:getOrCreateQuestState(playerId) state.heroesPlayed:add(heroName) local steamId = tostring(PlayerResource:GetSteamAccountID(playerId)) - local request = CreateHTTPRequest("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/hero-played") + local request = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/hero-played") setApiHeaders(nil, request) request:SetHTTPRequestRawPostBody( "application/json", @@ -680,7 +680,7 @@ function BattlePassServer.prototype.syncAllQuestProgress(self) end end function BattlePassServer.prototype.syncQuestProgressToApi(self, steamId, questId, progress) - local request = CreateHTTPRequest("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/quests/progress") + local request = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/quests/progress") setApiHeaders(nil, request) request:SetHTTPRequestRawPostBody( "application/json", @@ -738,7 +738,7 @@ function BattlePassServer.prototype.loadQuests(self, playerId, steamId) nil, ((("[BattlePassServer] Запрос квестов для " .. steamId) .. " (playerId: ") .. tostring(playerId)) .. ")" ) - local request = CreateHTTPRequest("GET", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/quests") + local request = CreateHTTPRequestScriptVM("GET", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/quests") setApiHeaders(nil, request) request:Send(function(result) local player = PlayerResource:GetPlayer(playerId) @@ -943,7 +943,7 @@ function BattlePassServer.prototype.claimQuest(self, playerId, steamId, questId) return end ____print(nil, "[BattlePassServer] Отправляем запрос на клейм квеста " .. questId) - local request = CreateHTTPRequest("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/quests/claim") + local request = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/quests/claim") setApiHeadersLong(nil, request) request:SetHTTPRequestRawPostBody( "application/json", @@ -1121,7 +1121,7 @@ function BattlePassServer.prototype.setupEventListeners(self) ) end function BattlePassServer.prototype.loadBattlePassData(self, playerId, steamId) - local request = CreateHTTPRequest("GET", (self.serverUrl .. "/battlepass/") .. steamId) + local request = CreateHTTPRequestScriptVM("GET", (self.serverUrl .. "/battlepass/") .. steamId) setApiHeaders(nil, request) request:Send(function(result) do @@ -1246,7 +1246,7 @@ function BattlePassServer.prototype.loadBattlePassData(self, playerId, steamId) end) end function BattlePassServer.prototype.createBattlePass(self, playerId, steamId, afterCreate) - local request = CreateHTTPRequest("POST", self.serverUrl .. "/battlepass") + local request = CreateHTTPRequestScriptVM("POST", self.serverUrl .. "/battlepass") setApiHeadersLong(nil, request) request:SetHTTPRequestRawPostBody( "application/json", @@ -1301,7 +1301,7 @@ function BattlePassServer.prototype.claimReward(self, playerId, steamId, level, isPremium = false end local endpoint = isPremium and "claim-premium" or "claim" - local request = CreateHTTPRequest("POST", (((self.serverUrl .. "/battlepass/") .. steamId) .. "/") .. endpoint) + local request = CreateHTTPRequestScriptVM("POST", (((self.serverUrl .. "/battlepass/") .. steamId) .. "/") .. endpoint) setApiHeadersLong(nil, request) request:SetHTTPRequestRawPostBody( "application/json", @@ -1616,7 +1616,7 @@ function BattlePassServer.prototype.grantRewardInGame(self, playerId, level, isP break end itemSteamId = tostring(PlayerResource:GetSteamAccountID(playerId)) - purchaseRequest = CreateHTTPRequest("POST", ((self.serverUrl .. "/player/") .. itemSteamId) .. "/purchases") + purchaseRequest = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/player/") .. itemSteamId) .. "/purchases") setApiHeaders(nil, purchaseRequest) purchaseRequest:SetHTTPRequestRawPostBody( "application/json", @@ -1660,7 +1660,7 @@ function BattlePassServer.prototype.grantRewardInGame(self, playerId, level, isP break end local effectSteamId = tostring(PlayerResource:GetSteamAccountID(playerId)) - local effectPurchaseRequest = CreateHTTPRequest("POST", ((self.serverUrl .. "/player/") .. effectSteamId) .. "/purchases") + local effectPurchaseRequest = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/player/") .. effectSteamId) .. "/purchases") setApiHeaders(nil, effectPurchaseRequest) effectPurchaseRequest:SetHTTPRequestRawPostBody( "application/json", @@ -1719,7 +1719,7 @@ function BattlePassServer.prototype.grantRewardInGame(self, playerId, level, isP until true end function BattlePassServer.prototype.claimAllRewards(self, playerId, steamId) - local request = CreateHTTPRequest("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/claim-all") + local request = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/claim-all") setApiHeadersLong(nil, request) request:SetHTTPRequestRawPostBody( "application/json", @@ -1840,7 +1840,7 @@ function BattlePassServer.prototype.claimAllRewards(self, playerId, steamId) end) end function BattlePassServer.prototype.buyPremium(self, playerId, steamId) - local request = CreateHTTPRequest("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/buy-premium") + local request = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/buy-premium") setApiHeadersLong(nil, request) request:SetHTTPRequestRawPostBody( "application/json", @@ -1899,7 +1899,7 @@ function BattlePassServer.prototype.sendAddExpRequest(self, playerId, amount, al nil, ((((("[BattlePassServer] Добавляем " .. tostring(expAdd)) .. " опыта Battle Pass игроку ") .. tostring(playerId)) .. " (Steam ID: ") .. steamId) .. ")" ) - local request = CreateHTTPRequest("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/addexp") + local request = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/addexp") setApiHeadersLong(nil, request) request:SetHTTPRequestRawPostBody( "application/json", diff --git a/scripts/vscripts/cards/cardsystem.lua b/scripts/vscripts/cards/cardsystem.lua index 69faae0..aa310d2 100644 --- a/scripts/vscripts/cards/cardsystem.lua +++ b/scripts/vscripts/cards/cardsystem.lua @@ -2689,7 +2689,7 @@ function CardSystem.prototype.saveCardLevelsToServer(self) if not steamId then return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "PUT", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/card-levels" ) @@ -2707,7 +2707,7 @@ function CardSystem.prototype.loadCardLevelsFromServer(self) self.cardLevelsLoaded = true return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/card-levels" ) @@ -2845,7 +2845,7 @@ function CardSystem.prototype.SaveDeckToServer(self, index, cards, deckName) finalDeckName = "Колода " .. tostring(index) end end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "PUT", (((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/decks/") .. tostring(index) ) @@ -2878,7 +2878,7 @@ function CardSystem.prototype.DeleteDeckFromServer(self, index) if not steamId then return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "DELETE", (((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/decks/") .. tostring(index) ) @@ -2935,7 +2935,7 @@ function CardSystem.prototype.UpdateActiveDeckOnServer(self) function(____, card) return type(card) == "number" end ) end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "PUT", (((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/decks/") .. tostring(index) ) @@ -2964,7 +2964,7 @@ function CardSystem.prototype.LoadDecks(self) if not steamId then return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/decks" ) diff --git a/scripts/vscripts/chat_wheel_grant.lua b/scripts/vscripts/chat_wheel_grant.lua index 05e8531..ed04f97 100644 --- a/scripts/vscripts/chat_wheel_grant.lua +++ b/scripts/vscripts/chat_wheel_grant.lua @@ -56,7 +56,7 @@ local function saveSoundsWheelToServer(self, playerId, soundsWheel) if not steamId then return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "PUT", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/sounds_wheel" ) diff --git a/scripts/vscripts/contracts/contract_backend_adapter.lua b/scripts/vscripts/contracts/contract_backend_adapter.lua index b45e0b5..72c3ad6 100644 --- a/scripts/vscripts/contracts/contract_backend_adapter.lua +++ b/scripts/vscripts/contracts/contract_backend_adapter.lua @@ -77,7 +77,7 @@ local function extractContractsArray(self, data) end function ____exports.contractAdapterGetPlayerContracts(self, steamId, callback) local url = (API(nil) .. "/contracts/player/") .. steamId - local req = CreateHTTPRequest("GET", url) + local req = CreateHTTPRequestScriptVM("GET", url) setApiHeaders(nil, req) req:Send(function(result) if result.StatusCode >= 200 and result.StatusCode < 300 then @@ -95,7 +95,7 @@ function ____exports.contractAdapterGetPlayerContracts(self, steamId, callback) end function ____exports.contractAdapterSaveDroppedContract(self, steamId, requestId, draft, callback) local url = API(nil) .. "/contracts/drop" - local req = CreateHTTPRequest("POST", url) + local req = CreateHTTPRequestScriptVM("POST", url) setApiHeadersLong(nil, req) req:SetHTTPRequestRawPostBody( "application/json", @@ -124,7 +124,7 @@ function ____exports.contractAdapterSaveDroppedContract(self, steamId, requestId end function ____exports.contractAdapterNominate(self, sessionId, requestId, steamId, contractInstanceId, callback) local url = ((API(nil) .. "/contracts/session/") .. sessionId) .. "/nominate" - local req = CreateHTTPRequest("POST", url) + local req = CreateHTTPRequestScriptVM("POST", url) setApiHeaders(nil, req) req:SetHTTPRequestRawPostBody( "application/json", @@ -136,7 +136,7 @@ function ____exports.contractAdapterNominate(self, sessionId, requestId, steamId end function ____exports.contractAdapterVote(self, sessionId, requestId, voterSteamId, contractInstanceId, callback) local url = ((API(nil) .. "/contracts/session/") .. sessionId) .. "/vote" - local req = CreateHTTPRequest("POST", url) + local req = CreateHTTPRequestScriptVM("POST", url) setApiHeaders(nil, req) req:SetHTTPRequestRawPostBody( "application/json", @@ -148,7 +148,7 @@ function ____exports.contractAdapterVote(self, sessionId, requestId, voterSteamI end function ____exports.contractAdapterFinalizeContractVoting(self, sessionId, requestId, matchId, localWinnerContractInstanceId, candidatesSnapshot, votesSnapshot, callback) local url = ((API(nil) .. "/contracts/session/") .. sessionId) .. "/finalize" - local req = CreateHTTPRequest("POST", url) + local req = CreateHTTPRequestScriptVM("POST", url) setApiHeadersLong(nil, req) local body = { request_id = requestId, @@ -179,7 +179,7 @@ function ____exports.contractAdapterFinalizeContractVoting(self, sessionId, requ end function ____exports.contractAdapterLinkSessionToMatch(self, sessionId, requestId, matchId, callback) local url = ((API(nil) .. "/contracts/session/") .. sessionId) .. "/link-match" - local req = CreateHTTPRequest("POST", url) + local req = CreateHTTPRequestScriptVM("POST", url) setApiHeaders(nil, req) req:SetHTTPRequestRawPostBody( "application/json", diff --git a/scripts/vscripts/contracts_manager.lua b/scripts/vscripts/contracts_manager.lua index c154c1e..9c02235 100644 --- a/scripts/vscripts/contracts_manager.lua +++ b/scripts/vscripts/contracts_manager.lua @@ -203,7 +203,7 @@ function ContractsManager.prototype.grantOneContract(self, playerId, minTier) if not steamId then return end - local req = CreateHTTPRequest( + local req = CreateHTTPRequestScriptVM( "POST", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/contracts/grant" ) @@ -228,7 +228,7 @@ function ContractsManager.prototype.loadContractsFromServer(self, playerId, sync end return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/contracts" ) @@ -261,7 +261,7 @@ function ContractsManager.prototype.persistContractsToServer(self, playerId) return end local list = self.contractsByPlayer:get(playerId) or ({}) - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "PUT", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/contracts" ) diff --git a/scripts/vscripts/death_sentence/contracts_backend.lua b/scripts/vscripts/death_sentence/contracts_backend.lua index 95799a2..9c23b53 100644 --- a/scripts/vscripts/death_sentence/contracts_backend.lua +++ b/scripts/vscripts/death_sentence/contracts_backend.lua @@ -137,7 +137,7 @@ end --- Загрузить ростер с бэка для steam_id. В колбэке roster=null при ошибке / пусто / невалидно. function ____exports.loadDeathSentenceContractsFromBackend(self, steamId, done) local url = ((SERVER_CONFIG.API_URL .. "/player/") .. steamId) .. "/death_sentence_contracts" - local request = CreateHTTPRequest("GET", url) + local request = CreateHTTPRequestScriptVM("GET", url) setApiHeaders(nil, request) request:Send(function(result) if result.StatusCode < 200 or result.StatusCode >= 300 then @@ -165,7 +165,7 @@ end --- Сохранить ростер на бэк для одного steam_id. function ____exports.saveDeathSentenceContractsToBackend(self, steamId, roster, done) local url = ((SERVER_CONFIG.API_URL .. "/player/") .. steamId) .. "/death_sentence_contracts" - local request = CreateHTTPRequest("PUT", url) + local request = CreateHTTPRequestScriptVM("PUT", url) setApiHeaders(nil, request) local payload = {death_sentence_contracts = {roster = roster}} request:SetHTTPRequestRawPostBody( diff --git a/scripts/vscripts/equipment/api.lua b/scripts/vscripts/equipment/api.lua index 6becf26..abae7f8 100644 --- a/scripts/vscripts/equipment/api.lua +++ b/scripts/vscripts/equipment/api.lua @@ -36,7 +36,7 @@ function ____exports.loadEquipmentStateFromApi(self, playerId, onDone) onDone(nil, nil) return end - local req = CreateHTTPRequest( + local req = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/equipment" ) @@ -63,7 +63,7 @@ function ____exports.saveEquipmentStateToApi(self, playerId, state) if not steamId then return end - local req = CreateHTTPRequest( + local req = CreateHTTPRequestScriptVM( "PUT", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/equipment" ) @@ -79,7 +79,7 @@ function ____exports.postEquipmentDropToApi(self, playerId, item) if not steamId then return end - local req = CreateHTTPRequest( + local req = CreateHTTPRequestScriptVM( "POST", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/equipment/drop" ) diff --git a/scripts/vscripts/game_stats_tracker.lua b/scripts/vscripts/game_stats_tracker.lua index e0f076a..5239c5c 100644 --- a/scripts/vscripts/game_stats_tracker.lua +++ b/scripts/vscripts/game_stats_tracker.lua @@ -564,7 +564,7 @@ function GameStatsTracker.prototype.registerPlayerGame(self, playerId, hero) nil, (((((("[GameStatsTracker] 👤 Регистрируем игрока " .. playerName) .. " (SteamID: ") .. steamId) .. "), герой: ") .. hero:GetUnitName()) .. ", уровень: ") .. tostring(heroLevel) ) - local request = CreateHTTPRequest("POST", SERVER_CONFIG.API_URL .. "/game/start") + local request = CreateHTTPRequestScriptVM("POST", SERVER_CONFIG.API_URL .. "/game/start") setApiHeadersLong(nil, request) local dataToSend = { steam_id = steamId, @@ -1158,7 +1158,7 @@ function GameStatsTracker.prototype.saveGameResult(self, steamId, isVictory, dur if dsContractEnd then dataToSend.death_sentence_contract = dsContractEnd end - local request = CreateHTTPRequest("POST", SERVER_CONFIG.API_URL .. "/game") + local request = CreateHTTPRequestScriptVM("POST", SERVER_CONFIG.API_URL .. "/game") setApiHeadersLong(nil, request) request:SetHTTPRequestRawPostBody( "application/json", diff --git a/scripts/vscripts/gamemode.lua b/scripts/vscripts/gamemode.lua index 268906a..245a030 100644 --- a/scripts/vscripts/gamemode.lua +++ b/scripts/vscripts/gamemode.lua @@ -1662,7 +1662,7 @@ function GameMode.prototype.saveChatWheelToServer(self, playerId, chatWheel) if not steamId then return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "PUT", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/chat_wheel" ) @@ -1691,7 +1691,7 @@ function GameMode.prototype.saveSoundsWheelToServer(self, playerId, soundsWheel) if not steamId then return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "PUT", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/sounds_wheel" ) @@ -1720,7 +1720,7 @@ function GameMode.prototype.loadChatWheelSoundsFromServer(self, playerId) if not steamId then return end - local chatWheelRequest = CreateHTTPRequest( + local chatWheelRequest = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/chat_wheel" ) @@ -1767,7 +1767,7 @@ function GameMode.prototype.loadChatWheelSoundsFromServer(self, playerId) ) end end) - local soundsWheelRequest = CreateHTTPRequest( + local soundsWheelRequest = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/sounds_wheel" ) diff --git a/scripts/vscripts/leaderboard_server.lua b/scripts/vscripts/leaderboard_server.lua index eb577e2..93351d7 100644 --- a/scripts/vscripts/leaderboard_server.lua +++ b/scripts/vscripts/leaderboard_server.lua @@ -39,7 +39,7 @@ function LeaderboardServer.prototype.setupEventListeners(self) ) end function LeaderboardServer.prototype.loadLeaderboardFromServer(self, playerId, limit, offset, board) - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "GET", (((((self.serverUrl .. "/leaderboard?limit=") .. tostring(limit)) .. "&offset=") .. tostring(offset)) .. "&board=") .. board ) diff --git a/scripts/vscripts/mini_profile_server.lua b/scripts/vscripts/mini_profile_server.lua index 58fcd55..2b3ac79 100644 --- a/scripts/vscripts/mini_profile_server.lua +++ b/scripts/vscripts/mini_profile_server.lua @@ -186,7 +186,7 @@ function MiniProfileServer.prototype.syncHeroRankRewardsForPlayer(self, playerId ) end function MiniProfileServer.prototype.createPlayerProfile(self, playerId, steamId, playerName) - local request = CreateHTTPRequest("POST", self.serverUrl .. "/player") + local request = CreateHTTPRequestScriptVM("POST", self.serverUrl .. "/player") setApiHeadersLong(nil, request) request:SetHTTPRequestRawPostBody( "application/json", @@ -231,7 +231,7 @@ function MiniProfileServer.prototype.loadPlayerProfileFromServer(self, playerId, ____print(nil, (("[MiniProfileServer] Converted 64-bit Steam ID " .. steamId) .. " to 32-bit Account ID ") .. steamIdStr) end ____print(nil, (("[MiniProfileServer] Загрузка профиля: steam_id=" .. steamIdStr) .. ", player=") .. playerName) - local request = CreateHTTPRequest("GET", (self.serverUrl .. "/player/") .. steamIdStr) + local request = CreateHTTPRequestScriptVM("GET", (self.serverUrl .. "/player/") .. steamIdStr) setApiHeaders(nil, request) request:Send(function(result) do @@ -875,7 +875,7 @@ function MiniProfileServer.prototype.loadRecentGamesFallback(self, player, steam if grantedLevelRewardsObject == nil then grantedLevelRewardsObject = {} end - local fallbackRequest = CreateHTTPRequest("GET", ((self.serverUrl .. "/player/") .. steamId) .. "/history?limit=10&offset=0") + local fallbackRequest = CreateHTTPRequestScriptVM("GET", ((self.serverUrl .. "/player/") .. steamId) .. "/history?limit=10&offset=0") setApiHeaders(nil, fallbackRequest) fallbackRequest:Send(function(result) if result.StatusCode >= 200 and result.StatusCode < 300 then @@ -980,7 +980,7 @@ function MiniProfileServer.prototype.sendProfileToClient(self, player, profileDa end function MiniProfileServer.prototype.loadHeroAchievementsForProfile(self, steamId, playerId, shouldGrantRankRewards, callback) local allHeroes = self:getAllAvailableHeroes(playerId) - local request = CreateHTTPRequest("GET", ((self.serverUrl .. "/player/") .. steamId) .. "/history?limit=5000&offset=0") + local request = CreateHTTPRequestScriptVM("GET", ((self.serverUrl .. "/player/") .. steamId) .. "/history?limit=5000&offset=0") setApiHeaders(nil, request) request:Send(function(result) ____print( @@ -1557,7 +1557,7 @@ function MiniProfileServer.prototype.loadMatchPlayersFromServer(self, player, ma CustomGameEventManager:Send_ServerToPlayer(player, "match_players_data", {error = "Не удалось загрузить участников матча", match_id = matchId, players = {}}) return end - local request = CreateHTTPRequest("GET", endpoints[index + 1]) + local request = CreateHTTPRequestScriptVM("GET", endpoints[index + 1]) setApiHeaders(nil, request) request:Send(function(result) if result.StatusCode < 200 or result.StatusCode >= 300 then diff --git a/scripts/vscripts/player_profile_manager.lua b/scripts/vscripts/player_profile_manager.lua index 21489b8..e63bd36 100644 --- a/scripts/vscripts/player_profile_manager.lua +++ b/scripts/vscripts/player_profile_manager.lua @@ -35,7 +35,7 @@ function PlayerProfileManager.prototype.setupListeners(self) ) end function PlayerProfileManager.prototype.createPlayerProfile(self, playerId, steamId, playerName) - local request = CreateHTTPRequest("POST", SERVER_CONFIG.API_URL .. "/player") + local request = CreateHTTPRequestScriptVM("POST", SERVER_CONFIG.API_URL .. "/player") setApiHeaders(nil, request) local dataToSend = {steam_id = steamId, player_name = playerName} request:SetHTTPRequestRawPostBody( diff --git a/scripts/vscripts/store_arcade_packs.lua b/scripts/vscripts/store_arcade_packs.lua index ff1eefc..66b3f1a 100644 --- a/scripts/vscripts/store_arcade_packs.lua +++ b/scripts/vscripts/store_arcade_packs.lua @@ -188,7 +188,7 @@ local function saveArcadePityToBackend(self, playerId, state) if not steamId then return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "PUT", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/arcade_pity" ) @@ -209,7 +209,7 @@ function ____exports.loadArcadePityForPlayer(self, playerId) if not steamId then return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/arcade_pity" ) @@ -547,7 +547,7 @@ local function tryConsumeArcadePackCredit(self, playerId, packId, onDone) onDone(nil, false) return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "POST", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/arcade_pack_credits/consume" ) diff --git a/scripts/vscripts/store_manager.lua b/scripts/vscripts/store_manager.lua index 2260668..16523df 100644 --- a/scripts/vscripts/store_manager.lua +++ b/scripts/vscripts/store_manager.lua @@ -330,7 +330,7 @@ function StoreManager.prototype.handleDonatePaymentLink(self, playerId, amountRu self:sendDonatePaymentLinkResult(playerId, false, "Игрок не найден") return end - local request = CreateHTTPRequest("POST", SERVER_CONFIG.API_URL .. "/payments/robokassa/link") + local request = CreateHTTPRequestScriptVM("POST", SERVER_CONFIG.API_URL .. "/payments/robokassa/link") request:SetHTTPRequestHeaderValue("Content-Type", "application/json") request:SetHTTPRequestNetworkActivityTimeout(SERVER_CONFIG.NETWORK_TIMEOUT) request:SetHTTPRequestAbsoluteTimeoutMS(SERVER_CONFIG.ABSOLUTE_TIMEOUT) @@ -470,7 +470,7 @@ function StoreManager.prototype.handleBundlePaymentLink(self, playerId, bundleId self:sendBundlePaymentLinkResult(playerId, false, "Игрок не найден") return end - local request = CreateHTTPRequest("POST", SERVER_CONFIG.API_URL .. "/payments/bundles/link") + local request = CreateHTTPRequestScriptVM("POST", SERVER_CONFIG.API_URL .. "/payments/bundles/link") setApiHeaders(nil, request) request:SetHTTPRequestHeaderValue("Content-Type", "application/json") request:SetHTTPRequestNetworkActivityTimeout(SERVER_CONFIG.NETWORK_TIMEOUT) @@ -767,7 +767,7 @@ function StoreManager.prototype.handleDealsCatalogRequest(self, playerId) self:sendDealsCatalogResult(playerId, false, {}, "Игрок не найден") return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "GET", (SERVER_CONFIG.API_URL .. "/payments/deals?steam_id=") .. tostring(steamId) ) @@ -876,7 +876,7 @@ function StoreManager.prototype.handleDealPurchase(self, playerId, dealKey) self:sendPurchaseResult(playerId, false, "Игрок не найден") return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "POST", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/deal-purchase" ) @@ -1091,7 +1091,7 @@ function StoreManager.prototype.reloadSoundsWheelFromServer(self, playerId) if not steamId then return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/sounds_wheel" ) @@ -1208,7 +1208,7 @@ function StoreManager.prototype.handlePromoCode(self, playerId, rawCode) self:sendPromoCodeResult(playerId, false, "Игрок не найден") return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "POST", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/promo/redeem" ) @@ -1449,7 +1449,7 @@ function StoreManager.prototype.syncLatestCurrencyTotalsFromApi(self, playerId, onDone(nil, false) return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/currency" ) @@ -1905,7 +1905,7 @@ function StoreManager.prototype.saveActiveEffectsToServer(self, playerId, active if not steamId then return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "PUT", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/active_effects" ) @@ -1971,7 +1971,7 @@ function StoreManager.prototype.loadActiveEffectsFromServer(self, playerId, call callback(nil, {}) return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/active_effects" ) @@ -2043,7 +2043,7 @@ function StoreManager.prototype.savePurchaseToServer(self, playerId, itemId, cat if not steamId then return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "POST", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/purchases" ) @@ -2530,7 +2530,7 @@ function StoreManager.prototype.sendShopExtrasGiveRequest(self, playerId, amount if arcadeStandard > 0 or arcadePremium > 0 then body.arcade_pack_credits = {standard = arcadeStandard, premium = arcadePremium} end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "POST", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/currency/give" ) @@ -2596,7 +2596,7 @@ function StoreManager.prototype.saveCurrencyToServer(self, playerId) local freeCurrency = self:getFreeCurrency(playerId) local donateCurrency = self:getDonateCurrency(playerId) local dustCurrency = self:getDustCurrency(playerId) - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "PUT", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/currency" ) @@ -2622,7 +2622,7 @@ function StoreManager.prototype.ensurePlayerRowOnApi(self, playerId, done) done(nil, false) return end - local request = CreateHTTPRequest("POST", SERVER_CONFIG.API_URL .. "/player") + local request = CreateHTTPRequestScriptVM("POST", SERVER_CONFIG.API_URL .. "/player") setApiHeadersLong(nil, request) request:SetHTTPRequestRawPostBody( "application/json", @@ -2671,7 +2671,7 @@ function StoreManager.prototype.sendGiveCurrencyRequest(self, playerId, freeAmou if freeAmount <= 0 and donateAmount <= 0 and dustAmount <= 0 then return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "POST", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/currency/give" ) @@ -2768,7 +2768,7 @@ function StoreManager.prototype.loadCurrencyFromServer(self, playerId) ((("[STORE] Загрузка валюты для игрока " .. tostring(playerId)) .. " (SteamID: ") .. tostring(steamId)) .. ")" ) local loadSeq = self:advanceCurrencyLoadSeq(playerId) - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/currency" ) @@ -2887,7 +2887,7 @@ function StoreManager.prototype.loadPurchasesFromServer(self, playerId, callback callback(nil, {}) return end - local request = CreateHTTPRequest( + local request = CreateHTTPRequestScriptVM( "GET", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/purchases" )