fixed names, maybe fixed random kicks

This commit is contained in:
jenz 2024-06-29 15:11:24 +02:00
parent 840be3fbc8
commit 50f4f0c7bc

View File

@ -36,11 +36,11 @@ public void OnPluginStart()
g_iServerPort = GetConVarInt(FindConVar("hostport"));
if (g_iServerPort == server_ports[0])
{
CreateTimer(15.0, update_info_over_txt, _, TIMER_REPEAT);
CreateTimer(5.0, update_info_over_txt, _, TIMER_REPEAT);
}
else if (g_iServerPort == server_ports[1])
{
CreateTimer(GetRandomFloat(5.0, 25.0), read_info_over_txt);
CreateTimer(GetRandomFloat(1.0, 5.0), read_info_over_txt);
}
}
@ -71,6 +71,10 @@ public Action read_info_over_txt(Handle timer, any data)
while(!IsEndOfFile(fileHandle) && ReadFileLine(fileHandle, lineBuffer, sizeof(lineBuffer)))
{
TrimString(lineBuffer);
if (strlen(lineBuffer) == 0)
{
continue;
}
if (count == 0) //mapname
{
char mapname[256];
@ -94,6 +98,11 @@ public Action read_info_over_txt(Handle timer, any data)
char[][] sPart = new char[3][256];
ExplodeString(lineBuffer, " ", sPart, 3, 256);
int ClientUserID = StringToInt(sPart[0]);
char fixedName[128];
//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]);
bool does_client_user_id_exist = false;
for (int i = 0; i <= MaxClients; i++)
@ -106,13 +115,16 @@ 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)
{
//User ID is new, so lets create the FakeClient.
int iIndex = CreateFakeClient(sPart[2]);
int iIndex = CreateFakeClient(fixedName);
if(iIndex < 1 || iIndex > MaxClients)
break;
continue;
Format(g_cClientNewName[iIndex], sizeof(g_cClientNewName[]), fixedName);
SetEntityFlags(iIndex, FL_CLIENT);
DispatchKeyValue(iIndex, "classname", "player");
@ -134,12 +146,11 @@ 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], sPart[2]))
if (!StrEqual(g_cClientNewName[i], fixedName))
{
CreateTimer(GetRandomFloat(1.0, 55.0), update_client_name, GetClientSerial(i));
Format(g_cClientNewName[i], sizeof(g_cClientNewName[]), fixedName);
CreateTimer(GetRandomFloat(1.0, 25.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;