From 39c4606b3e1eeb0675be284776a1ec07b18db2aa Mon Sep 17 00:00:00 2001 From: jenz Date: Sat, 29 Jun 2024 02:57:20 +0200 Subject: [PATCH] adding random delay to name update --- .../scripting/simulate_ze_server.sp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/simulate_ze_server/scripting/simulate_ze_server.sp b/simulate_ze_server/scripting/simulate_ze_server.sp index 2c4b94f2..d0c43234 100644 --- a/simulate_ze_server/scripting/simulate_ze_server.sp +++ b/simulate_ze_server/scripting/simulate_ze_server.sp @@ -7,6 +7,8 @@ int server_ports[2] = {27015, 27075}; //server ports: ze server, simulated serve int g_iServerPort; int g_iClientIndexUserIDMapping[MAXPLAYERS + 1]; +char g_cClientNewName[MAXPLAYERS + 1][128]; + //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -42,6 +44,20 @@ public void OnPluginStart() } } +public Action update_client_name(Handle hTimer, int Serial) +{ + int client; + if ((client = GetClientFromSerial(Serial)) == 0) + { + return Plugin_Handled; + } + if (IsValidClient(client)) + { + SetClientName(client, g_cClientNewName[client]); + } + return Plugin_Handled; +} + public Action read_info_over_txt(Handle timer, any data) { new Handle:fileHandle = OpenFile("/addons/sourcemod/logs/simulate.txt", "r"); @@ -117,7 +133,12 @@ public Action read_info_over_txt(Handle timer, any data) { int clientFrag = StringToInt(sPart[1]); SetEntProp(i, Prop_Data, "m_iFrags", clientFrag); - SetClientName(i, sPart[2]); + + if (!StrEqual(g_cClientNewName[i], sPart[2])) + { + CreateTimer(GetRandomFloat(1.0, 55.0), update_client_name, GetClientSerial(i)); + } + Format(g_cClientNewName[i], sizeof(g_cClientNewName[]), sPart[2]); //indicating that the client still exists right now. current_ClientUserID_iteration[i] = ClientUserID; break;