Advertisement
Guest User

Untitled

a guest
Apr 4th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1.  
  2. int function Player_GetMaxMatchmakingDelay( entity player )
  3. {
  4. int leaveCount = player.GetPersistentVarAsInt( PERSISTENCE_LEAVECOUNT_VAR )
  5.  
  6. if ( leaveCount == 0 )
  7. return 0
  8.  
  9. int durationStep = MatchmakingPenalty_GetDurationMin()
  10.  
  11. int duration = int( Graph( leaveCount, 1, MatchmakingPenalty_GetThresholdMax(), MatchmakingPenalty_GetDurationMin(), MatchmakingPenalty_GetDurationMax() ) )
  12.  
  13. return minint( int( ceil( duration / durationStep ) * durationStep ), MatchmakingPenalty_GetDurationMax() )
  14. }
  15.  
  16.  
  17. int function Player_GetRemainingMatchmakingDelay( entity player )
  18. {
  19. //
  20. #if(UI)
  21. if ( player == null )
  22. return 0
  23. #endif
  24.  
  25. int lastLeaveTime = player.GetPersistentVarAsInt( PERSISTENCE_LAST_LEAVE_TIME )
  26.  
  27. return maxint( Player_GetMaxMatchmakingDelay( player ) - (GetCurrentTimeForPersistence() - lastLeaveTime), 0 )
  28. }
  29.  
  30.  
  31. int function Player_NextAvailableMatchmakingTime( entity player )
  32. {
  33. #if(UI)
  34. if ( player == null )
  35. return 0
  36. #endif
  37.  
  38. int lastLeaveTime = player.GetPersistentVarAsInt( PERSISTENCE_LAST_LEAVE_TIME )
  39. if ( GetCurrentTimeForPersistence() - lastLeaveTime < Player_GetMaxMatchmakingDelay( player ) )
  40. {
  41. return Player_GetRemainingMatchmakingDelay( player )
  42. }
  43.  
  44. return 0
  45. }
  46.  
  47.  
  48. int function MatchmakingPenalty_GetThresholdMax()
  49. {
  50. return GetCurrentPlaylistVarInt( "matchmaking_penalty_threshold_max", 5 )
  51. }
  52.  
  53.  
  54. int function MatchmakingPenalty_GetDurationMin()
  55. {
  56. return GetCurrentPlaylistVarInt( "matchmaking_penalty_duration_min", SECONDS_PER_MINUTE * 5 )
  57. }
  58.  
  59.  
  60. int function MatchmakingPenalty_GetDurationMax()
  61. {
  62. return GetCurrentPlaylistVarInt( "matchmaking_penalty_duration_max", SECONDS_PER_MINUTE * 30 )
  63. }
  64.  
  65.  
  66. int function MatchmakingPenalty_GetGraceTimeout()
  67. {
  68. return GetCurrentPlaylistVarInt( "matchmaking_penalty_grace_timeout", SECONDS_PER_DAY * 2 )
  69. }
  70.  
  71.  
  72. int function GetCurrentTimeForPersistence()
  73. {
  74. //
  75. return GetUnixTimestamp() + DAILY_RESET_TIME_ZONE_OFFSET * SECONDS_PER_HOUR
  76. }
  77.  
  78. void function MatchmakingPenalty_DumpStatus( entity inputPlayer = null )
  79. {
  80. #if(UI)
  81. printt( "Matchmaking Penalty:", GetPlayerName() )
  82. printt( "\tLast Leave Time:", GetCurrentTimeForPersistence() - GetPersistentVarAsInt( PERSISTENCE_LAST_LEAVE_TIME ) )
  83. printt( "\tRemaining Time:", Player_GetRemainingMatchmakingDelay( GetUIPlayer() ) )
  84. printt( "\tPenalty Count: ", GetPersistentVarAsInt( PERSISTENCE_LEAVECOUNT_VAR ) )
  85. #else
  86. array<entity> players = (inputPlayer == null) ? GetPlayerArray() : [inputPlayer]
  87. foreach ( player in players )
  88. {
  89. printt( "Matchmaking Penalty:", player.GetPlayerName() )
  90. printt( "\tLast Leave Time:", GetCurrentTimeForPersistence() - player.GetPersistentVarAsInt( PERSISTENCE_LAST_LEAVE_TIME ) )
  91. printt( "\tRemaining Time:", Player_GetRemainingMatchmakingDelay( player ) )
  92. printt( "\tPenalty Count: ", player.GetPersistentVarAsInt( PERSISTENCE_LEAVECOUNT_VAR ) )
  93. }
  94. #endif
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement