commented out name changing

This commit is contained in:
jenz 2024-07-27 17:31:17 +02:00
parent 7c7bffa006
commit 35375b7067

View File

@ -3,7 +3,7 @@
#include <sourcemod>
#include <sdktools>
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;