Администратор
-
Автор темы
- #1
Изменение рангов (вы должны быть создателем лобби)
Игроки в лобби
CLobbyScreen
Host SteamID
Author: Beakers, pasted by UC
Код:
static void ChangeRanks(int rank)
{
if (g_Valve.g_LobbyScreen->InLobby() && g_Valve.g_LobbyScreen->IsHost())
{
KeyValues* kv = reinterpret_cast<KeyValues*>(KeyValues::operator new(36));
kv->InitKeyValues("Update");
auto session_setting = g_Valve.g_MatchFramework->GetMatchSession()->GetSessionSettings();
auto members = session_setting->FindKey("Members");
if (members)
{
auto size = members->GetInt("numMachines", 0);
for (int i = 0; i < size; ++i)
{
std::string machine = "machine" + std::to_string(i);
auto machine_key = members->FindKey(machine.c_str());
if (machine_key)
{
auto num_players = machine_key->GetInt("numPlayers", 0);
for (int x = 0; x < num_players; ++x)
{
std::string player = "player" + std::to_string(x);
auto player_key = machine_key->FindKey(player.c_str());
if (player_key)
kv->SetInt(std::string("Update/Members/" + machine + "/" + player + "/game/ranking").c_str(), rank);
}
}
}
}
g_Valve.g_MatchFramework->GetMatchSession()->UpdateSessionSettings(kv);
delete kv;
}
}
Игроки в лобби
Код:
static std::vector<LobbyPlayer> GetPlayersInLobby()
{
std::vector<LobbyPlayer> players;
auto session_setting = g_Valve.g_MatchFramework->GetMatchSession()->GetSessionSettings();
auto members = session_setting->FindKey("Members");
if (members)
{
auto num_machines = members->GetInt("numMachines", 0);
for (int i = 0; i < num_machines; ++i)
{
std::string machine = "machine" + std::to_string(i);
auto machine_key = members->FindKey(machine.c_str());
if (machine_key)
{
auto num_players = machine_key->GetInt("numPlayers", 0);
for (int x = 0; x < num_players; ++x)
{
std::string player = "player" + std::to_string(x);
auto player_key = machine_key->FindKey(player.c_str());
if (player_key)
{
auto xuid_key = player_key->FindKey("xuid");
int session_id_low = *reinterpret_cast<int*>(*reinterpret_cast<uintptr_t*>(reinterpret_cast<uintptr_t>(xuid_key) + 0x4));
int session_id_high = *reinterpret_cast<int*>(*reinterpret_cast<uintptr_t*>(reinterpret_cast<uintptr_t>(xuid_key) + 0x4) + 0x4);
auto ranking = player_key->GetInt("game/ranking", 0);
auto wins = player_key->GetInt("game/wins", 0);
players.push_back(LobbyPlayer(session_id_low, session_id_high, ranking, wins));
}
}
}
}
}
return players;
}
CLobbyScreen
Код:
bool IsHost()
{
auto pThis = *reinterpret_cast<uintptr_t*>(g_LobbyScreen);
return pThis ? *reinterpret_cast<bool*>(pThis + 0x30) : false;
}
Host SteamID
Код:
static const char* GetHostSteamID()
{
auto session_data = g_Valve.g_MatchFramework->GetMatchSession()->GetSessionSystemData();
return session_data ? session_data->GetString("xuidHost", "") : false;
}
Author: Beakers, pasted by UC
Последнее редактирование: