Guest User

Untitled

a guest
Nov 17th, 2020
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. if (emptyServerTimer <= (emptyServerTimerMaxTime - 10.0f))
  2. {
  3. #if UE_SERVER
  4. IPlayFabCommonModuleInterface::Get().SetDeveloperSecretKey(FString("key"));
  5.  
  6. PlayFabServerPtr serverAPI = IPlayFabModuleInterface::Get().GetServerAPI();
  7.  
  8.  
  9. if (gateIsOpen == true)
  10. {
  11.  
  12. UE_LOG(LogTemp, Warning, TEXT("INSIDE END GATE"));
  13. int matchValue = GetGameState<AProjectArenaGameState>()->Team1MMR - GetGameState<AProjectArenaGameState>()->Team2MMR;
  14. int matchAbsoluteValue = FMath::Abs(matchValue);
  15.  
  16.  
  17. if (matchIsValid == true && isRankedMatch == true)//if no problem was encountered with requests and check the match is valid, also if the match is ranked
  18. {
  19. for (int x = 0; x < playersInfo.Num(); x++)
  20. {
  21. if (playersInfo[x].entityID != FString(""))
  22. {
  23. UE_LOG(LogTemp, Warning, TEXT("winner team: %s"), *GetGameState<AProjectArenaGameState>()->winnerTeam);
  24. UE_LOG(LogTemp, Warning, TEXT("player team: %s"), *playersInfo[x].team);
  25. UE_LOG(LogTemp, Warning, TEXT("player mmr: %d"), playersInfo[x].MMR);
  26.  
  27. if (playersInfo[x].team == GetGameState<AProjectArenaGameState>()->winnerTeam)
  28. {
  29. UE_LOG(LogTemp, Warning, TEXT("POSITIVE MMR!!"));
  30.  
  31. PlayFab::ServerModels::FUpdatePlayerStatisticsRequest statisticRequest;
  32. TArray<PlayFab::ServerModels::FStatisticUpdate> statisticsArray;
  33. PlayFab::ServerModels::FStatisticUpdate statistic;
  34.  
  35. statistic.StatisticName = FString("MatchMakingRating");
  36. int32 mmrValueToAdjust = ((matchAbsoluteValue ^ 2) / 100) + 5;
  37. UE_LOG(LogTemp, Warning, TEXT("MMR: %d"), mmrValueToAdjust);
  38. statistic.Value = mmrValueToAdjust;
  39.  
  40. statisticsArray.Add(statistic);
  41.  
  42. statisticRequest.Statistics = statisticsArray;
  43. statisticRequest.PlayFabId = playersInfo[x].playfabID;
  44. serverAPI->UpdatePlayerStatistics(statisticRequest, PlayFab::UPlayFabServerAPI::FUpdatePlayerStatisticsDelegate::CreateUObject(this, &AArenaGameMode::OnStatisticUpdateSuccess), PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &AArenaGameMode::OnStatisticUpdateFailed));
  45. UE_LOG(LogTemp, Warning, TEXT("actual request sent"));
  46. }
  47. else
  48. {
  49. UE_LOG(LogTemp, Warning, TEXT("NEGATIVE MMR!!"));
  50. PlayFab::ServerModels::FUpdatePlayerStatisticsRequest statisticRequest;
  51. TArray<PlayFab::ServerModels::FStatisticUpdate> statisticsArray;
  52. PlayFab::ServerModels::FStatisticUpdate statistic;
  53.  
  54. statistic.StatisticName = FString("MatchMakingRating");
  55. int32 mmrValueToAdjust = (((matchAbsoluteValue*-1) ^ 2) / 100) - 5;
  56. UE_LOG(LogTemp, Warning, TEXT("MMR: %d"), mmrValueToAdjust);
  57. statistic.Value = mmrValueToAdjust;
  58.  
  59. statisticsArray.Add(statistic);
  60.  
  61. statisticRequest.Statistics = statisticsArray;
  62. statisticRequest.PlayFabId = playersInfo[x].playfabID;
  63. serverAPI->UpdatePlayerStatistics(statisticRequest, PlayFab::UPlayFabServerAPI::FUpdatePlayerStatisticsDelegate::CreateUObject(this, &AArenaGameMode::OnStatisticUpdateSuccess), PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &AArenaGameMode::OnStatisticUpdateFailed));
  64. UE_LOG(LogTemp, Warning, TEXT("actual request sent"));
  65. }
  66. }
  67. }
  68. }
  69. gateIsOpen = false;
  70. }
  71. }
  72. #endif
  73. break;
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment