From c545dd2b414021bca443a81834512d5e289e30e5 Mon Sep 17 00:00:00 2001 From: Sean Lewis Date: Sun, 1 Apr 2018 01:18:25 -0700 Subject: [PATCH] Don't try to load player names if none are set. --- scripting/get5/teamlogic.sp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripting/get5/teamlogic.sp b/scripting/get5/teamlogic.sp index 3f0a74bba..6b761c2dd 100644 --- a/scripting/get5/teamlogic.sp +++ b/scripting/get5/teamlogic.sp @@ -375,6 +375,7 @@ public bool RemovePlayerFromTeams(const char[] auth) { public void LoadPlayerNames() { KeyValues namesKv = new KeyValues("Names"); + int numNames = 0; LOOP_TEAMS(team) { char id[AUTH_LENGTH + 1]; char name[MAX_NAME_LENGTH + 1]; @@ -384,16 +385,22 @@ public void LoadPlayerNames() { if (g_PlayerNames.GetString(id, name, sizeof(name)) && !StrEqual(name, "") && !StrEqual(name, KEYVALUE_STRING_PLACEHOLDER)) { namesKv.SetString(id, name); + numNames++; } } } - char nameFile[] = "get5_names.txt"; - DeleteFile(nameFile); - namesKv.ExportToFile(nameFile); - delete namesKv; + if (numNames > 0) { + char nameFile[] = "get5_names.txt"; + DeleteFile(nameFile); + if (namesKv.ExportToFile(nameFile)) { + ServerCommand("sv_load_forced_client_names_file %s", nameFile); + } else { + LogError("Failed to write names keyvalue file to %s", nameFile); + } + } - ServerCommand("sv_load_forced_client_names_file %s", nameFile); + delete namesKv; } public void SwapScrimTeamStatus(int client) {