From 35375b7067eebdc62fed10919ab097ed15b2a4e5 Mon Sep 17 00:00:00 2001 From: jenz Date: Sat, 27 Jul 2024 17:31:17 +0200 Subject: [PATCH] commented out name changing --- .../scripting/simulate_ze_server.sp | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/simulate_ze_server/scripting/simulate_ze_server.sp b/simulate_ze_server/scripting/simulate_ze_server.sp index 44ecd69b..e60ddeca 100644 --- a/simulate_ze_server/scripting/simulate_ze_server.sp +++ b/simulate_ze_server/scripting/simulate_ze_server.sp @@ -3,7 +3,7 @@ #include #include -int server_ports[2] = {27015, 27075}; //server ports: ze server, simulated server. +int server_ports[2] = {27015, 27078}; //server ports: ze server, simulated server. int g_iServerPort; int g_iClientIndexUserIDMapping[MAXPLAYERS + 1]; bool g_bCooldownMapChange = false; @@ -42,7 +42,7 @@ public void OnPluginStart() } else if (g_iServerPort == server_ports[1]) { - CreateTimer(GetRandomFloat(1.0, 5.0), read_info_over_txt); + CreateTimer(GetRandomFloat(2.0, 5.0), read_info_over_txt); } } @@ -55,7 +55,15 @@ public Action update_client_name(Handle hTimer, int Serial) } if (IsValidClient(client)) { - SetClientName(client, g_cClientNewName[client]); + char letters[26] = "abcdefghijklmnopqrstuvwxyz\0"; + int iRandom = GetRandomInt(0, 25); + char random_char_begin = letters[iRandom]; + int iRandom_end = GetRandomInt(0, 25); + char random_char_end = letters[iRandom_end]; + char final_name[MAX_NAME_LENGTH * 2]; + Format(final_name, sizeof(final_name), "%s%s%s", random_char_begin, g_cClientNewName[client], random_char_end); + SetClientName(client, final_name); + Format(g_cClientNewName[client], sizeof(g_cClientNewName[]), final_name); } return Plugin_Handled; } @@ -92,7 +100,7 @@ public Action read_info_over_txt(Handle timer, any data) char cmd[256]; Format(cmd, sizeof(cmd), "sv_mapname_override %s", lineBuffer); ServerCommand(cmd); - ServerCommand("mp_timelimit 9000000"); //avoid map switches. also handled server hibernation with https://forums.alliedmods.net/showthread.php?t=331283 + //handled server hibernation with https://forums.alliedmods.net/showthread.php?t=331283 } else if (count == 1) //hostname { @@ -109,6 +117,7 @@ public Action read_info_over_txt(Handle timer, any data) int ClientUserID = StringToInt(sPart[0]); char fixedName[128]; + char final_name[MAX_NAME_LENGTH * 2]; //take everything after the frag. thats a white space + the entire name. int index_after_frag = StrContains(lineBuffer, sPart[1], false) + 1 + strlen(sPart[1]); //skipping the whitespace after frag strcopy(fixedName, sizeof(fixedName), lineBuffer[index_after_frag]); @@ -127,13 +136,20 @@ public Action read_info_over_txt(Handle timer, any data) //create one new fakeclient if not existing already if (!does_client_user_id_exist && !already_created_fakeClient) { + char letters[26] = "abcdefghijklmnopqrstuvwxyz\0"; + int iRandom = GetRandomInt(0, 25); + char random_char_begin = letters[iRandom]; + int iRandom_end = GetRandomInt(0, 25); + char random_char_end = letters[iRandom_end]; + Format(final_name, sizeof(final_name), "%s%s%s", random_char_begin, fixedName, random_char_end); + //User ID is new, so lets create the FakeClient. - int iIndex = CreateFakeClient(fixedName); + int iIndex = CreateFakeClient(final_name); if(iIndex < 1 || iIndex > MaxClients) continue; - Format(g_cClientNewName[iIndex], sizeof(g_cClientNewName[]), fixedName); + Format(g_cClientNewName[iIndex], sizeof(g_cClientNewName[]), final_name); SetEntityFlags(iIndex, FL_CLIENT); DispatchKeyValue(iIndex, "classname", "player"); @@ -155,11 +171,13 @@ public Action read_info_over_txt(Handle timer, any data) int clientFrag = StringToInt(sPart[1]); SetEntProp(i, Prop_Data, "m_iFrags", clientFrag); + /* if (!StrEqual(g_cClientNewName[i], fixedName)) { Format(g_cClientNewName[i], sizeof(g_cClientNewName[]), fixedName); - CreateTimer(GetRandomFloat(1.0, 25.0), update_client_name, GetClientSerial(i)); + CreateTimer(GetRandomFloat(1.0, 5.0), update_client_name, GetClientSerial(i)); } + */ //indicating that the client still exists right now. current_ClientUserID_iteration[i] = ClientUserID; break; @@ -194,10 +212,11 @@ public Action read_info_over_txt(Handle timer, any data) } } } - CreateTimer(GetRandomFloat(1.0, 5.0), read_info_over_txt); + CreateTimer(GetRandomFloat(2.0, 5.0), read_info_over_txt); return Plugin_Handled; } + public void OnMapEnd() { g_bCooldownMapChange = true;