Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (emptyServerTimer <= (emptyServerTimerMaxTime - 10.0f))
- {
- #if UE_SERVER
- IPlayFabCommonModuleInterface::Get().SetDeveloperSecretKey(FString("key"));
- PlayFabServerPtr serverAPI = IPlayFabModuleInterface::Get().GetServerAPI();
- if (gateIsOpen == true)
- {
- UE_LOG(LogTemp, Warning, TEXT("INSIDE END GATE"));
- int matchValue = GetGameState<AProjectArenaGameState>()->Team1MMR - GetGameState<AProjectArenaGameState>()->Team2MMR;
- int matchAbsoluteValue = FMath::Abs(matchValue);
- if (matchIsValid == true && isRankedMatch == true)//if no problem was encountered with requests and check the match is valid, also if the match is ranked
- {
- for (int x = 0; x < playersInfo.Num(); x++)
- {
- if (playersInfo[x].entityID != FString(""))
- {
- UE_LOG(LogTemp, Warning, TEXT("winner team: %s"), *GetGameState<AProjectArenaGameState>()->winnerTeam);
- UE_LOG(LogTemp, Warning, TEXT("player team: %s"), *playersInfo[x].team);
- UE_LOG(LogTemp, Warning, TEXT("player mmr: %d"), playersInfo[x].MMR);
- if (playersInfo[x].team == GetGameState<AProjectArenaGameState>()->winnerTeam)
- {
- UE_LOG(LogTemp, Warning, TEXT("POSITIVE MMR!!"));
- PlayFab::ServerModels::FUpdatePlayerStatisticsRequest statisticRequest;
- TArray<PlayFab::ServerModels::FStatisticUpdate> statisticsArray;
- PlayFab::ServerModels::FStatisticUpdate statistic;
- statistic.StatisticName = FString("MatchMakingRating");
- int32 mmrValueToAdjust = ((matchAbsoluteValue ^ 2) / 100) + 5;
- UE_LOG(LogTemp, Warning, TEXT("MMR: %d"), mmrValueToAdjust);
- statistic.Value = mmrValueToAdjust;
- statisticsArray.Add(statistic);
- statisticRequest.Statistics = statisticsArray;
- statisticRequest.PlayFabId = playersInfo[x].playfabID;
- serverAPI->UpdatePlayerStatistics(statisticRequest, PlayFab::UPlayFabServerAPI::FUpdatePlayerStatisticsDelegate::CreateUObject(this, &AArenaGameMode::OnStatisticUpdateSuccess), PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &AArenaGameMode::OnStatisticUpdateFailed));
- UE_LOG(LogTemp, Warning, TEXT("actual request sent"));
- }
- else
- {
- UE_LOG(LogTemp, Warning, TEXT("NEGATIVE MMR!!"));
- PlayFab::ServerModels::FUpdatePlayerStatisticsRequest statisticRequest;
- TArray<PlayFab::ServerModels::FStatisticUpdate> statisticsArray;
- PlayFab::ServerModels::FStatisticUpdate statistic;
- statistic.StatisticName = FString("MatchMakingRating");
- int32 mmrValueToAdjust = (((matchAbsoluteValue*-1) ^ 2) / 100) - 5;
- UE_LOG(LogTemp, Warning, TEXT("MMR: %d"), mmrValueToAdjust);
- statistic.Value = mmrValueToAdjust;
- statisticsArray.Add(statistic);
- statisticRequest.Statistics = statisticsArray;
- statisticRequest.PlayFabId = playersInfo[x].playfabID;
- serverAPI->UpdatePlayerStatistics(statisticRequest, PlayFab::UPlayFabServerAPI::FUpdatePlayerStatisticsDelegate::CreateUObject(this, &AArenaGameMode::OnStatisticUpdateSuccess), PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &AArenaGameMode::OnStatisticUpdateFailed));
- UE_LOG(LogTemp, Warning, TEXT("actual request sent"));
- }
- }
- }
- }
- gateIsOpen = false;
- }
- }
- #endif
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment