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) <noreply@anthropic.com>
This commit is contained in:
achmad
2026-05-29 17:36:08 +07:00
parent 49b790349f
commit 72b73c4dd6
16 changed files with 70 additions and 70 deletions
+4 -4
View File
@@ -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"
)
@@ -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(
+12 -12
View File
@@ -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",
+6 -6
View File
@@ -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"
)
+1 -1
View File
@@ -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"
)
@@ -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",
+3 -3
View File
@@ -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"
)
@@ -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(
+3 -3
View File
@@ -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"
)
+2 -2
View File
@@ -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",
+4 -4
View File
@@ -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"
)
+1 -1
View File
@@ -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
)
+5 -5
View File
@@ -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
+1 -1
View File
@@ -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(
+3 -3
View File
@@ -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"
)
+16 -16
View File
@@ -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"
)