From de2dbcb9c5b871d2d151eb50bf8a0072a3810aa7 Mon Sep 17 00:00:00 2001 From: jenz Date: Sun, 12 Mar 2023 19:42:12 +0100 Subject: [PATCH] handling rare case where cprint tries to send message to disconnected player --- .../scripting/mapchooser_extended.sp | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mapchooser_extended/scripting/mapchooser_extended.sp b/mapchooser_extended/scripting/mapchooser_extended.sp index 800b00b3..c5876edd 100755 --- a/mapchooser_extended/scripting/mapchooser_extended.sp +++ b/mapchooser_extended/scripting/mapchooser_extended.sp @@ -1019,7 +1019,7 @@ public Handle get_most_nominated_maps() int nominate_count_for_particular_map = 0; sm.GetValue(map_iteration, nominate_count_for_particular_map); nominate_count_for_particular_map++; - //if i is 0 its admin nominated map that must come into the vote + //if i is 0 its admin nominated map that most come into the vote if(!i) { nominate_count_for_particular_map = 999; @@ -2588,8 +2588,11 @@ void CheckMapRestrictions(bool time = false, bool players = false) if(TimeRestriction) { remove = true; - - CPrintToChat(client, "[MCE] %t", "Nomination Removed Time Error", map); + + if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client)) + { + CPrintToChat(client, "[MCE] %t", "Nomination Removed Time Error", map); + } } } @@ -2600,10 +2603,13 @@ void CheckMapRestrictions(bool time = false, bool players = false) { remove = true; - if(PlayerRestriction < 0) - CPrintToChat(client, "[MCE] %t", "Nomination Removed MinPlayers Error", map); - else - CPrintToChat(client, "[MCE] %t", "Nomination Removed MaxPlayers Error", map); + if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client)) + { + if(PlayerRestriction < 0) + CPrintToChat(client, "[MCE] %t", "Nomination Removed MinPlayers Error", map); + else + CPrintToChat(client, "[MCE] %t", "Nomination Removed MaxPlayers Error", map); + } } }