diff --git a/src/hacks/Misc.cpp b/src/hacks/Misc.cpp index f8adb551..db828fe2 100644 --- a/src/hacks/Misc.cpp +++ b/src/hacks/Misc.cpp @@ -322,19 +322,25 @@ void CreateMove() { // Check if user settings allow anti-afk if (anti_afk) { + // If the timer exceeds 1 minute, jump and reset the timer - if ( g_GlobalVars->curtime - afkTimeIdle > 60 ) { + if (g_GlobalVars->curtime - 60 > afkTimeIdle) { + + // Send random commands + g_pUserCmd->sidemove = RandFloatRange(-450.0, 450.0); + g_pUserCmd->forwardmove = RandFloatRange(-450.0, 450.0); + g_pUserCmd->buttons = rand(); - // If player didnt jump, then we dont reset the timer - if (CE_INT(g_pLocalPlayer->entity, netvar.movetype) == MOVETYPE_FLY) + // After 1 second we reset the idletime + if (g_GlobalVars->curtime - 61 > afkTimeIdle) { + logging::Info("Finish idle"); + afkTimeIdle = g_GlobalVars->curtime; + } + } else { + // If the player uses a button, reset the timer + if (g_pUserCmd->buttons & IN_FORWARD || g_pUserCmd->buttons & IN_BACK || g_pUserCmd->buttons & IN_MOVELEFT || g_pUserCmd->buttons & IN_MOVERIGHT || g_pUserCmd->buttons & IN_JUMP || !LOCAL_E->m_bAlivePlayer) afkTimeIdle = g_GlobalVars->curtime; - - // Attemt to jump - g_pUserCmd->buttons = g_pUserCmd->buttons &~ IN_JUMP; } - // If the player uses a button, reset the timer - if ( g_pUserCmd->buttons & IN_FORWARD || g_pUserCmd->buttons & IN_BACK || g_pUserCmd->buttons & IN_MOVELEFT || g_pUserCmd->buttons & IN_MOVERIGHT || g_pUserCmd->buttons & IN_JUMP || !LOCAL_E->m_bAlivePlayer ) - afkTimeIdle = g_GlobalVars->curtime; } IF_GAME (IsTF2()) { diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index 9d3a0b20..12783e75 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -213,8 +213,83 @@ void Shutdown_hook(void* _this, const char* reason) { static CatVar resolver(CV_SWITCH, "resolver", "0", "Resolve angles"); +CatVar namesteal(CV_SWITCH, "name_stealer", "0", "Name Stealer", "Attemt to steal your teammates names. Usefull for avoiding kicks"); + +static std::string stolen_name; + +// Func to get a new entity to steal name from +bool StolenName(){ + + // Array to store potential namestealer targets with a bookkeeper to tell how full it is + int potential_targets[32]; + int potential_targets_length = 0; + + // Go through entities looking for potential targets + for (int i = 1; i < HIGHEST_ENTITY; i++) { + CachedEntity* ent = ENTITY(i); + + // Check if ent is a good target + if (!ent) continue; + if (ent == LOCAL_E) continue; + if (!ent->m_Type == ENTITY_PLAYER) continue; + if (ent->m_bEnemy) continue; + + // Check if name is current one + player_info_s info; + if (g_IEngine->GetPlayerInfo(ent->m_IDX, &info)) { + + // If our name is the same as current, than change it + if (std::string(info.name) == stolen_name) continue; + + // a ent without a name is no ent we need, contine for a different one + } else continue; + + // Save the ent to our array + potential_targets[potential_targets_length] = i; + potential_targets_length++; + if (potential_targets_length >= 32) break; + } + + // Get random number that we can use with our array + int target_random_num = floor(RandFloatRange(0, potential_targets_length - 0.1F)); + + // Get a idx from our random array position + int new_target = potential_targets[target_random_num]; + + // Checks to prevent crashes + if (!ENTITY(new_target) || potential_targets_length == 0) return false; + + // Grab username of user + player_info_s info; + if (g_IEngine->GetPlayerInfo(new_target, &info)) { + + // If our name is the same as current, than change it and return true + stolen_name = std::string(info.name); + return true; + } + + // Didnt get playerinfo + return false; +} + const char* GetFriendPersonaName_hook(ISteamFriends* _this, CSteamID steamID) { static const GetFriendPersonaName_t original = (GetFriendPersonaName_t)hooks::steamfriends.GetMethod(offsets::GetFriendPersonaName()); + + // Check User settings if namesteal is allowed + if (namesteal && steamID == g_ISteamUser->GetSteamID()) { + + // We dont want to steal names while not in-game as there are no targets to steal from + if (g_IEngine->IsInGame()) { + + // Check if we have a username to steal, func automaticly steals a name in it. + if (StolenName()) { + + // Return the name that has changed from the func above + return format(stolen_name, "\x0F").c_str(); + } + } + } + if ((force_name.convar->m_StringLength > 3) && steamID == g_ISteamUser->GetSteamID()) { return force_name_newlined; } diff --git a/tf-settings/menu.json b/tf-settings/menu.json index 9bf6924a..94ac78a4 100644 --- a/tf-settings/menu.json +++ b/tf-settings/menu.json @@ -407,6 +407,7 @@ "name", "fakelag", "disconnect_reason", + "name_stealer", "minigun_jump", "spycrab", "skinchanger",