Skip to content

Commit

Permalink
Don't try to load player names if none are set.
Browse files Browse the repository at this point in the history
  • Loading branch information
splewis committed Apr 1, 2018
1 parent 71baf68 commit c545dd2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions scripting/get5/teamlogic.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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) {
Expand Down

0 comments on commit c545dd2

Please sign in to comment.