What's new

Welcome to HvH Forum!

SignUp Now! Download Free HvH CS2/CS:GO Cheats, CFG, LUA/JS Scripts, And More!


SignUp Now!

Source Code Alias Identifier

Newbie HvHer
User ID
13277
Messages
6
Reactions
2
Level
4
This is a simple alias identifier made in the supremacy sdk. yes i am aware that i COULD be using an unordered_map, but i dont wanna.

cpp file:
void Alias::IdentifyAlias() {

    std::ifstream in{ file };
    if (!in.is_open() || in.fail()) {
        in.close();
        return;
    }

    nlohmann::json jsonData;
    try {
        in >> jsonData;
    }
    catch (const std::exception& e) {
        return;
    }

    if (!alias_list->empty() && previously_populated_alias_list) {
        alias_list->clear();
    }

    for (const auto& item : jsonData) {
        std::string name = item["name"];

        for (const auto& steam64 : item["steam64"]) {
            alias_list->emplace_back(std::make_pair(steam64.get<unsigned long long>(), name));
        }
    }

    previously_populated_alias_list = true;
}

void Alias::AddEntryToJsonFile(unsigned long long steam64, const std::string& name) {

    std::ifstream in(file);
    if (!in.is_open() || in.fail()) {
        in.close();
        return;
    }

    nlohmann::json jsonData;
    try {
        in >> jsonData;
    }
    catch (const std::exception& e) {
        in.close();
        return;
    }

    // logic to check if player already exists within the json file data
    bool name_exists = false;
    bool steam64_exists = false;

    for (auto& item : jsonData) {

        // if the steamid already exists, update the name
        for (int i = 0; i < item["steam64"].size(); i++) {
            if (item["steam64"][i] == steam64) {
                steam64_exists = true;
                item["name"] = name;
                break;
            }
        }

        // if the name already exists, add the steam64 to the array
        if (item["name"] == name && !steam64_exists) {
            item["steam64"].push_back(steam64);
            name_exists = true;
            break;
        }
    }

    // if the player is not in the json data, add them
    if (!name_exists && !steam64_exists) {
        nlohmann::json newEntry;
        newEntry["steam64"] = { steam64 };
        newEntry["name"] = name;
        jsonData.push_back(newEntry);
    }

    std::ofstream out(file);
    if (out.is_open()) {
        out << jsonData.dump(4);
        out.close();
    }

    IdentifyAlias();
}

header file:
#pragma once

class Alias {

public:

    void IdentifyAlias();
    void AddEntryToJsonFile(unsigned long long steam64, const std::string& name);

public:

    bool previously_populated_alias_list;
    std::string file;
    std::vector <std::pair<unsigned long long, std::string>> alias_list[2] = {};

public:

    __forceinline bool FindAliasInList(unsigned long long xuid) {
        for (int i = 0; i < alias_list->size(); i++) {

            auto entry = &alias_list->at(i);
            if (entry->first != xuid)
                continue;

            return true;
        }
        return false;
    }
};

extern Alias g_alias;

you can either render this directly in esp or you can update it in some sort of player list like i have (hence the existence of AddEntryToJsonFile)

C++:
// example code
bool __fastcall Detours::hkGetPlayerInfo(void* ecx, void* edx, int index, player_info_t* info) {

    auto ret = g_Detours.oGetPlayerInfo(ecx, edx, index, info);

    if (index != g_csgo.m_engine->GetLocalPlayer()) {

        for (int i = 0; i < g_alias.alias_list->size(); i++) {

            auto entry = &g_alias.alias_list->at(i);
            if (entry->first != info->m_xuid)
                continue;

            strcpy(info->m_name, entry->second.c_str());
        }
    }

    return ret;
}
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Top