@@ -883,18 +883,20 @@ const onMatchEnd = async (match: Match) => {
883
883
884
884
await say ( match , 'MATCH IS FINISHED' ) ;
885
885
886
- // tell players what will happen next
887
886
const seconds = Math . round ( Settings . MATCH_END_ACTION_DELAY / 1000 ) ;
887
+ const delayInSeconds = Math . max ( seconds , await getMapEndDelayInSeconds ( match , seconds ) ) ;
888
+
889
+ // tell players what will happen next
888
890
switch ( match . data . matchEndAction ) {
889
891
case 'KICK_ALL' :
890
- await say ( match , `IN ${ seconds } SECONDS ALL PLAYERS GET KICKED` ) ;
892
+ await say ( match , `IN ${ delayInSeconds } SECONDS ALL PLAYERS GET KICKED` ) ;
891
893
break ;
892
894
case 'QUIT_SERVER' :
893
- await say ( match , `IN ${ seconds } SECONDS THE SERVER SHUTS DOWN` ) ;
895
+ await say ( match , `IN ${ delayInSeconds } SECONDS THE SERVER SHUTS DOWN` ) ;
894
896
break ;
895
897
}
896
898
897
- await sleep ( Settings . MATCH_END_ACTION_DELAY ) ;
899
+ await sleep ( delayInSeconds * 1000 ) ;
898
900
899
901
switch ( match . data . matchEndAction ) {
900
902
case 'KICK_ALL' :
@@ -972,6 +974,25 @@ const loopMatch = async (match: Match) => {
972
974
} ) ;
973
975
} ;
974
976
977
+ /**
978
+ * Returns the number of seconds it should delay actions after a map ends (before changelevel or match end actions)
979
+ * @param match Match
980
+ * @param fallback
981
+ */
982
+ export const getMapEndDelayInSeconds = async ( match : Match , fallback : number ) : Promise < number > => {
983
+ let delayInSeconds : number | undefined ;
984
+ const cVar = await getConfigVar ( match , 'mp_match_restart_delay' ) ;
985
+ if ( / ^ \d + $ / . test ( cVar ) ) {
986
+ delayInSeconds = parseInt ( cVar ) ;
987
+ } else {
988
+ match . log ( 'Config var mp_match_restart_delay cannot be parsed to number: ' + cVar ) ;
989
+ }
990
+ if ( ! delayInSeconds || isNaN ( delayInSeconds ) ) {
991
+ delayInSeconds = fallback ;
992
+ }
993
+ return delayInSeconds ;
994
+ } ;
995
+
975
996
export const update = async ( match : Match , dto : IMatchUpdateDto ) => {
976
997
if ( dto . state ) {
977
998
match . data . state = dto . state ;
0 commit comments