Fix uses of GetSteamIDForPlayerIndex returning spoofed FriendsID
This commit is contained in:
parent
55fa263036
commit
32d15aaa2d
@ -128,23 +128,25 @@ void onKilledBy(unsigned id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CatCommand mark_betrayal("pl_mark_betrayal", "Mark a steamid32 as betrayal", [](const CCommand &args) {
|
static CatCommand mark_betrayal("pl_mark_betrayal", "Mark a steamid32 as betrayal",
|
||||||
if (args.ArgC() < 2)
|
[](const CCommand &args)
|
||||||
{
|
{
|
||||||
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please provide a valid steamid32!");
|
if (args.ArgC() < 2)
|
||||||
return;
|
{
|
||||||
}
|
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Please provide a valid steamid32!");
|
||||||
try
|
return;
|
||||||
{
|
}
|
||||||
// Grab steamid
|
try
|
||||||
unsigned steamid = std::stoul(args.Arg(1));
|
{
|
||||||
betrayal_list[steamid] = *betrayal_limit;
|
// Grab steamid
|
||||||
}
|
unsigned steamid = std::stoul(args.Arg(1));
|
||||||
catch (const std::invalid_argument &)
|
betrayal_list[steamid] = *betrayal_limit;
|
||||||
{
|
}
|
||||||
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Invalid Steamid32 provided.");
|
catch (const std::invalid_argument &)
|
||||||
}
|
{
|
||||||
});
|
g_ICvar->ConsoleColorPrintf(MENU_COLOR, "Invalid Steamid32 provided.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
void onKilledBy(CachedEntity *entity)
|
void onKilledBy(CachedEntity *entity)
|
||||||
{
|
{
|
||||||
@ -156,8 +158,8 @@ class PlayerToolsEventListener : public IGameEventListener2
|
|||||||
void FireGameEvent(IGameEvent *event) override
|
void FireGameEvent(IGameEvent *event) override
|
||||||
{
|
{
|
||||||
|
|
||||||
int killer_id = g_IEngine->GetPlayerForUserID(event->GetInt("attacker"));
|
int killer_id = GetPlayerForUserID(event->GetInt("attacker"));
|
||||||
int victim_id = g_IEngine->GetPlayerForUserID(event->GetInt("userid"));
|
int victim_id = GetPlayerForUserID(event->GetInt("userid"));
|
||||||
|
|
||||||
if (victim_id == g_IEngine->GetLocalPlayer())
|
if (victim_id == g_IEngine->GetLocalPlayer())
|
||||||
{
|
{
|
||||||
@ -173,9 +175,11 @@ PlayerToolsEventListener &listener()
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
static InitRoutine register_event([]() {
|
static InitRoutine register_event(
|
||||||
g_IEventManager2->AddListener(&listener(), "player_death", false);
|
[]()
|
||||||
EC::Register(
|
{
|
||||||
EC::Shutdown, []() { g_IEventManager2->RemoveListener(&listener()); }, "playerlist_shutdown");
|
g_IEventManager2->AddListener(&listener(), "player_death", false);
|
||||||
});
|
EC::Register(
|
||||||
|
EC::Shutdown, []() { g_IEventManager2->RemoveListener(&listener()); }, "playerlist_shutdown");
|
||||||
|
});
|
||||||
} // namespace player_tools
|
} // namespace player_tools
|
||||||
|
@ -975,7 +975,7 @@ public:
|
|||||||
// Something took damage
|
// Something took damage
|
||||||
else if (!strcmp(event->GetName(), "player_hurt"))
|
else if (!strcmp(event->GetName(), "player_hurt"))
|
||||||
{
|
{
|
||||||
int victim = g_IEngine->GetPlayerForUserID(event->GetInt("userid"));
|
int victim = GetPlayerForUserID(event->GetInt("userid"));
|
||||||
int health = event->GetInt("health");
|
int health = event->GetInt("health");
|
||||||
|
|
||||||
auto &status = player_status_list[victim - 1];
|
auto &status = player_status_list[victim - 1];
|
||||||
@ -984,7 +984,7 @@ public:
|
|||||||
status.just_updated = true;
|
status.just_updated = true;
|
||||||
|
|
||||||
// That something was hurt by us
|
// That something was hurt by us
|
||||||
if (g_IEngine->GetPlayerForUserID(event->GetInt("attacker")) == g_pLocalPlayer->entity_idx)
|
if (GetPlayerForUserID(event->GetInt("attacker")) == g_pLocalPlayer->entity_idx)
|
||||||
{
|
{
|
||||||
// Don't count self damage
|
// Don't count self damage
|
||||||
if (victim != g_pLocalPlayer->entity_idx)
|
if (victim != g_pLocalPlayer->entity_idx)
|
||||||
|
@ -71,8 +71,8 @@ void check_combos()
|
|||||||
|
|
||||||
void on_kill(IGameEvent *event)
|
void on_kill(IGameEvent *event)
|
||||||
{
|
{
|
||||||
int killer_id = g_IEngine->GetPlayerForUserID(event->GetInt("attacker"));
|
int killer_id = GetPlayerForUserID(event->GetInt("attacker"));
|
||||||
int victim_id = g_IEngine->GetPlayerForUserID(event->GetInt("userid"));
|
int victim_id = GetPlayerForUserID(event->GetInt("userid"));
|
||||||
|
|
||||||
if (victim_id == g_IEngine->GetLocalPlayer())
|
if (victim_id == g_IEngine->GetLocalPlayer())
|
||||||
{
|
{
|
||||||
@ -122,7 +122,7 @@ void on_kill(IGameEvent *event)
|
|||||||
|
|
||||||
void on_spawn(IGameEvent *event)
|
void on_spawn(IGameEvent *event)
|
||||||
{
|
{
|
||||||
int userid = g_IEngine->GetPlayerForUserID(event->GetInt("userid"));
|
int userid = GetPlayerForUserID(event->GetInt("userid"));
|
||||||
|
|
||||||
if (userid == g_IEngine->GetLocalPlayer())
|
if (userid == g_IEngine->GetLocalPlayer())
|
||||||
{
|
{
|
||||||
@ -160,8 +160,10 @@ void shutdown()
|
|||||||
g_IEventManager2->RemoveListener(&listener());
|
g_IEventManager2->RemoveListener(&listener());
|
||||||
}
|
}
|
||||||
|
|
||||||
static InitRoutine EC([]() {
|
static InitRoutine EC(
|
||||||
EC::Register(EC::Shutdown, shutdown, "shutdown_announcer", EC::average);
|
[]()
|
||||||
init();
|
{
|
||||||
});
|
EC::Register(EC::Shutdown, shutdown, "shutdown_announcer", EC::average);
|
||||||
|
init();
|
||||||
|
});
|
||||||
} // namespace hacks::shared::announcer
|
} // namespace hacks::shared::announcer
|
||||||
|
@ -97,13 +97,13 @@ public:
|
|||||||
if (name == "player_activate")
|
if (name == "player_activate")
|
||||||
{
|
{
|
||||||
int uid = event->GetInt("userid");
|
int uid = event->GetInt("userid");
|
||||||
int entity = g_IEngine->GetPlayerForUserID(uid);
|
int entity = GetPlayerForUserID(uid);
|
||||||
ResetPlayer(entity);
|
ResetPlayer(entity);
|
||||||
}
|
}
|
||||||
else if (name == "player_disconnect")
|
else if (name == "player_disconnect")
|
||||||
{
|
{
|
||||||
int uid = event->GetInt("userid");
|
int uid = event->GetInt("userid");
|
||||||
int entity = g_IEngine->GetPlayerForUserID(uid);
|
int entity = GetPlayerForUserID(uid);
|
||||||
ResetPlayer(entity);
|
ResetPlayer(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (g_IEngine->GetPlayerForUserID(event->GetInt("attacker")) == g_IEngine->GetLocalPlayer())
|
if (GetPlayerForUserID(event->GetInt("attacker")) == g_IEngine->GetLocalPlayer())
|
||||||
{
|
{
|
||||||
bool nearby = false;
|
bool nearby = false;
|
||||||
for (int i = 1; i <= HIGHEST_ENTITY; i++)
|
for (int i = 1; i <= HIGHEST_ENTITY; i++)
|
||||||
|
@ -223,7 +223,7 @@ void do_random_votekick()
|
|||||||
|
|
||||||
int target = targets[rand() % targets.size()];
|
int target = targets[rand() % targets.size()];
|
||||||
player_info_s info;
|
player_info_s info;
|
||||||
if (!GetPlayerInfo(g_IEngine->GetPlayerForUserID(target), &info))
|
if (!GetPlayerInfo(GetPlayerForUserID(target), &info))
|
||||||
return;
|
return;
|
||||||
hack::ExecuteCommand("callvote kick \"" + std::to_string(target) + " cheating\"");
|
hack::ExecuteCommand("callvote kick \"" + std::to_string(target) + " cheating\"");
|
||||||
}
|
}
|
||||||
@ -496,8 +496,8 @@ class CatBotEventListener : public IGameEventListener2
|
|||||||
void FireGameEvent(IGameEvent *event) override
|
void FireGameEvent(IGameEvent *event) override
|
||||||
{
|
{
|
||||||
|
|
||||||
int killer_id = g_IEngine->GetPlayerForUserID(event->GetInt("attacker"));
|
int killer_id = GetPlayerForUserID(event->GetInt("attacker"));
|
||||||
int victim_id = g_IEngine->GetPlayerForUserID(event->GetInt("userid"));
|
int victim_id = GetPlayerForUserID(event->GetInt("userid"));
|
||||||
|
|
||||||
if (victim_id == g_IEngine->GetLocalPlayer())
|
if (victim_id == g_IEngine->GetLocalPlayer())
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ std::string ComposeCritSay(IGameEvent *event)
|
|||||||
int kid = event->GetInt("attacker");
|
int kid = event->GetInt("attacker");
|
||||||
if (kid == vid)
|
if (kid == vid)
|
||||||
return "";
|
return "";
|
||||||
if (g_IEngine->GetPlayerForUserID(kid) != g_IEngine->GetLocalPlayer())
|
if (GetPlayerForUserID(kid) != g_IEngine->GetLocalPlayer())
|
||||||
return "";
|
return "";
|
||||||
std::string msg = source->at(rand() % source->size());
|
std::string msg = source->at(rand() % source->size());
|
||||||
// checks if the killsays.txt file is not 1 line. 100% sure it's going
|
// checks if the killsays.txt file is not 1 line. 100% sure it's going
|
||||||
@ -63,14 +63,14 @@ std::string ComposeCritSay(IGameEvent *event)
|
|||||||
msg = source->at(rand() % source->size());
|
msg = source->at(rand() % source->size());
|
||||||
lastmsg = msg;
|
lastmsg = msg;
|
||||||
player_info_s info{};
|
player_info_s info{};
|
||||||
GetPlayerInfo(g_IEngine->GetPlayerForUserID(vid), &info);
|
GetPlayerInfo(GetPlayerForUserID(vid), &info);
|
||||||
|
|
||||||
ReplaceSpecials(msg);
|
ReplaceSpecials(msg);
|
||||||
CachedEntity *ent = ENTITY(g_IEngine->GetPlayerForUserID(vid));
|
CachedEntity *ent = ENTITY(GetPlayerForUserID(vid));
|
||||||
int clz = g_pPlayerResource->GetClass(ent);
|
int clz = g_pPlayerResource->GetClass(ent);
|
||||||
ReplaceString(msg, "%class%", tf_classes_killsay[clz]);
|
ReplaceString(msg, "%class%", tf_classes_killsay[clz]);
|
||||||
player_info_s infok{};
|
player_info_s infok{};
|
||||||
GetPlayerInfo(g_IEngine->GetPlayerForUserID(kid), &infok);
|
GetPlayerInfo(GetPlayerForUserID(kid), &infok);
|
||||||
ReplaceString(msg, "%killer%", std::string(infok.name));
|
ReplaceString(msg, "%killer%", std::string(infok.name));
|
||||||
ReplaceString(msg, "%team%", tf_teams_killsay[ent->m_iTeam() - 2]);
|
ReplaceString(msg, "%team%", tf_teams_killsay[ent->m_iTeam() - 2]);
|
||||||
ReplaceString(msg, "%myteam%", tf_teams_killsay[LOCAL_E->m_iTeam() - 2]);
|
ReplaceString(msg, "%myteam%", tf_teams_killsay[LOCAL_E->m_iTeam() - 2]);
|
||||||
|
@ -46,7 +46,7 @@ std::string ComposeDominateSay(IGameEvent *event)
|
|||||||
int dnum = event->GetInt("dominations");
|
int dnum = event->GetInt("dominations");
|
||||||
|
|
||||||
// this is actually impossible but just in case.
|
// this is actually impossible but just in case.
|
||||||
if (g_IEngine->GetPlayerForUserID(kid) != g_IEngine->GetLocalPlayer())
|
if (GetPlayerForUserID(kid) != g_IEngine->GetLocalPlayer())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
std::string msg = source->at(rand() % source->size());
|
std::string msg = source->at(rand() % source->size());
|
||||||
@ -56,15 +56,15 @@ std::string ComposeDominateSay(IGameEvent *event)
|
|||||||
lastmsg = msg;
|
lastmsg = msg;
|
||||||
player_info_s info{};
|
player_info_s info{};
|
||||||
|
|
||||||
GetPlayerInfo(g_IEngine->GetPlayerForUserID(vid), &info);
|
GetPlayerInfo(GetPlayerForUserID(vid), &info);
|
||||||
ReplaceSpecials(msg);
|
ReplaceSpecials(msg);
|
||||||
|
|
||||||
CachedEntity *ent = ENTITY(g_IEngine->GetPlayerForUserID(vid));
|
CachedEntity *ent = ENTITY(GetPlayerForUserID(vid));
|
||||||
int clz = g_pPlayerResource->GetClass(ent);
|
int clz = g_pPlayerResource->GetClass(ent);
|
||||||
|
|
||||||
ReplaceString(msg, "%class%", tf_classes_dominatesay[clz]);
|
ReplaceString(msg, "%class%", tf_classes_dominatesay[clz]);
|
||||||
player_info_s infok{};
|
player_info_s infok{};
|
||||||
GetPlayerInfo(g_IEngine->GetPlayerForUserID(kid), &infok);
|
GetPlayerInfo(GetPlayerForUserID(kid), &infok);
|
||||||
|
|
||||||
ReplaceString(msg, "%dominum%", std::to_string(dnum));
|
ReplaceString(msg, "%dominum%", std::to_string(dnum));
|
||||||
ReplaceString(msg, "%killer%", std::string(infok.name));
|
ReplaceString(msg, "%killer%", std::string(infok.name));
|
||||||
|
@ -1359,7 +1359,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent)
|
|||||||
|
|
||||||
// Attempt to get player info, and if cant, return
|
// Attempt to get player info, and if cant, return
|
||||||
player_info_s info;
|
player_info_s info;
|
||||||
if (!g_IEngine->GetPlayerInfo(ent->m_IDX, &info))
|
if (!GetPlayerInfo(ent->m_IDX, &info))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO, check if u can just use "ent->m_bEnemy()" instead of m_iTeam
|
// TODO, check if u can just use "ent->m_bEnemy()" instead of m_iTeam
|
||||||
|
@ -59,7 +59,7 @@ std::string ComposeKillSay(IGameEvent *event)
|
|||||||
int kid = event->GetInt("attacker");
|
int kid = event->GetInt("attacker");
|
||||||
if (kid == vid)
|
if (kid == vid)
|
||||||
return "";
|
return "";
|
||||||
if (g_IEngine->GetPlayerForUserID(kid) != g_IEngine->GetLocalPlayer())
|
if (GetPlayerForUserID(kid) != g_IEngine->GetLocalPlayer())
|
||||||
return "";
|
return "";
|
||||||
std::string msg = source->at(rand() % source->size());
|
std::string msg = source->at(rand() % source->size());
|
||||||
// checks if the killsays.txt file is not 1 line. 100% sure it's going
|
// checks if the killsays.txt file is not 1 line. 100% sure it's going
|
||||||
@ -68,14 +68,14 @@ std::string ComposeKillSay(IGameEvent *event)
|
|||||||
msg = source->at(rand() % source->size());
|
msg = source->at(rand() % source->size());
|
||||||
lastmsg = msg;
|
lastmsg = msg;
|
||||||
player_info_s info{};
|
player_info_s info{};
|
||||||
GetPlayerInfo(g_IEngine->GetPlayerForUserID(vid), &info);
|
GetPlayerInfo(GetPlayerForUserID(vid), &info);
|
||||||
|
|
||||||
ReplaceSpecials(msg);
|
ReplaceSpecials(msg);
|
||||||
CachedEntity *ent = ENTITY(g_IEngine->GetPlayerForUserID(vid));
|
CachedEntity *ent = ENTITY(GetPlayerForUserID(vid));
|
||||||
int clz = g_pPlayerResource->GetClass(ent);
|
int clz = g_pPlayerResource->GetClass(ent);
|
||||||
ReplaceString(msg, "%class%", tf_classes_killsay[clz]);
|
ReplaceString(msg, "%class%", tf_classes_killsay[clz]);
|
||||||
player_info_s infok{};
|
player_info_s infok{};
|
||||||
GetPlayerInfo(g_IEngine->GetPlayerForUserID(kid), &infok);
|
GetPlayerInfo(GetPlayerForUserID(kid), &infok);
|
||||||
ReplaceString(msg, "%killer%", std::string(infok.name));
|
ReplaceString(msg, "%killer%", std::string(infok.name));
|
||||||
ReplaceString(msg, "%team%", tf_teams_killsay[ent->m_iTeam() - 2]);
|
ReplaceString(msg, "%team%", tf_teams_killsay[ent->m_iTeam() - 2]);
|
||||||
ReplaceString(msg, "%myteam%", tf_teams_killsay[LOCAL_E->m_iTeam() - 2]);
|
ReplaceString(msg, "%myteam%", tf_teams_killsay[LOCAL_E->m_iTeam() - 2]);
|
||||||
|
@ -62,8 +62,8 @@ void apply_killstreaks()
|
|||||||
|
|
||||||
void on_kill(IGameEvent *event)
|
void on_kill(IGameEvent *event)
|
||||||
{
|
{
|
||||||
int killer_id = g_IEngine->GetPlayerForUserID(event->GetInt("attacker"));
|
int killer_id = GetPlayerForUserID(event->GetInt("attacker"));
|
||||||
int victim_id = g_IEngine->GetPlayerForUserID(event->GetInt("userid"));
|
int victim_id = GetPlayerForUserID(event->GetInt("userid"));
|
||||||
|
|
||||||
if (victim_id == g_IEngine->GetLocalPlayer())
|
if (victim_id == g_IEngine->GetLocalPlayer())
|
||||||
{
|
{
|
||||||
@ -91,7 +91,7 @@ void on_kill(IGameEvent *event)
|
|||||||
|
|
||||||
void on_spawn(IGameEvent *event)
|
void on_spawn(IGameEvent *event)
|
||||||
{
|
{
|
||||||
int userid = g_IEngine->GetPlayerForUserID(event->GetInt("userid"));
|
int userid = GetPlayerForUserID(event->GetInt("userid"));
|
||||||
|
|
||||||
if (userid == g_IEngine->GetLocalPlayer())
|
if (userid == g_IEngine->GetLocalPlayer())
|
||||||
{
|
{
|
||||||
|
@ -1040,8 +1040,8 @@ public:
|
|||||||
// Store userids
|
// Store userids
|
||||||
int victim = event->GetInt("userid");
|
int victim = event->GetInt("userid");
|
||||||
int attacker = event->GetInt("attacker");
|
int attacker = event->GetInt("attacker");
|
||||||
int attacker_idx = g_IEngine->GetPlayerForUserID(attacker);
|
int attacker_idx = GetPlayerForUserID(attacker);
|
||||||
int victim_idx = g_IEngine->GetPlayerForUserID(victim);
|
int victim_idx = GetPlayerForUserID(victim);
|
||||||
player_info_s kinfo{};
|
player_info_s kinfo{};
|
||||||
player_info_s vinfo{};
|
player_info_s vinfo{};
|
||||||
|
|
||||||
|
@ -105,8 +105,8 @@ void Event(KeyValues *event)
|
|||||||
{
|
{
|
||||||
int attacker = event->GetInt("attacker");
|
int attacker = event->GetInt("attacker");
|
||||||
int victim = event->GetInt("userid");
|
int victim = event->GetInt("userid");
|
||||||
int eid = g_IEngine->GetPlayerForUserID(attacker);
|
int eid = GetPlayerForUserID(attacker);
|
||||||
int vid = g_IEngine->GetPlayerForUserID(victim);
|
int vid = GetPlayerForUserID(victim);
|
||||||
if (eid > 0 && eid <= MAX_PLAYERS && vid > 0 && vid <= MAX_PLAYERS)
|
if (eid > 0 && eid <= MAX_PLAYERS && vid > 0 && vid <= MAX_PLAYERS)
|
||||||
{
|
{
|
||||||
auto &Po_v = Player_origs[vid];
|
auto &Po_v = Player_origs[vid];
|
||||||
|
@ -1957,6 +1957,20 @@ bool GetPlayerInfo(int idx, player_info_s *info)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetPlayerForUserID(int userID)
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= g_IEngine->GetMaxClients(); i++)
|
||||||
|
{
|
||||||
|
player_info_s player_info;
|
||||||
|
if (!GetPlayerInfo(i, &player_info))
|
||||||
|
continue;
|
||||||
|
// Found player
|
||||||
|
if (player_info.userID == userID)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool HookNetvar(std::vector<std::string> path, ProxyFnHook &hook, RecvVarProxyFn function)
|
bool HookNetvar(std::vector<std::string> path, ProxyFnHook &hook, RecvVarProxyFn function)
|
||||||
{
|
{
|
||||||
auto pClass = g_IBaseClient->GetAllClasses();
|
auto pClass = g_IBaseClient->GetAllClasses();
|
||||||
|
@ -68,7 +68,7 @@ void OnShot()
|
|||||||
|
|
||||||
void OnHit(bool crit, int idx, bool is_sniper)
|
void OnHit(bool crit, int idx, bool is_sniper)
|
||||||
{
|
{
|
||||||
idx = g_IEngine->GetPlayerForUserID(idx);
|
idx = GetPlayerForUserID(idx);
|
||||||
count_hits++;
|
count_hits++;
|
||||||
if (is_sniper)
|
if (is_sniper)
|
||||||
count_hits_sniper++;
|
count_hits_sniper++;
|
||||||
@ -134,7 +134,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (strcmp("player_hurt", event->GetName()))
|
if (strcmp("player_hurt", event->GetName()))
|
||||||
return;
|
return;
|
||||||
if (g_IEngine->GetPlayerForUserID(event->GetInt("attacker")) == g_IEngine->GetLocalPlayer())
|
if (GetPlayerForUserID(event->GetInt("attacker")) == g_IEngine->GetLocalPlayer())
|
||||||
{
|
{
|
||||||
if (CE_GOOD(LOCAL_W) && (LOCAL_W->m_iClassID() == CL_CLASS(CTFSniperRifle) || LOCAL_W->m_iClassID() == CL_CLASS(CTFSniperRifleDecap)))
|
if (CE_GOOD(LOCAL_W) && (LOCAL_W->m_iClassID() == CL_CLASS(CTFSniperRifle) || LOCAL_W->m_iClassID() == CL_CLASS(CTFSniperRifleDecap)))
|
||||||
OnHit(event->GetBool("crit"), event->GetInt("userid"), true);
|
OnHit(event->GetBool("crit"), event->GetInt("userid"), true);
|
||||||
|
@ -53,7 +53,7 @@ CatCommand spectate("spectate", "Spectate", [](const CCommand &args) {
|
|||||||
spectator_target = 0;
|
spectator_target = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
spectator_target = g_IEngine->GetPlayerForUserID(id);
|
spectator_target = GetPlayerForUserID(id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ static void handlePlayerConnectClient(KeyValues *kv)
|
|||||||
static void handlePlayerActivate(KeyValues *kv)
|
static void handlePlayerActivate(KeyValues *kv)
|
||||||
{
|
{
|
||||||
int uid = kv->GetInt("userid");
|
int uid = kv->GetInt("userid");
|
||||||
int entity = g_IEngine->GetPlayerForUserID(uid);
|
int entity = GetPlayerForUserID(uid);
|
||||||
player_info_s info{};
|
player_info_s info{};
|
||||||
if (GetPlayerInfo(entity, &info))
|
if (GetPlayerInfo(entity, &info))
|
||||||
PrintChat("\x07%06X%s\x01 connected", 0xa06ba0, info.name);
|
PrintChat("\x07%06X%s\x01 connected", 0xa06ba0, info.name);
|
||||||
@ -42,7 +42,7 @@ static void handlePlayerActivate(KeyValues *kv)
|
|||||||
|
|
||||||
static void handlePlayerDisconnect(KeyValues *kv)
|
static void handlePlayerDisconnect(KeyValues *kv)
|
||||||
{
|
{
|
||||||
CachedEntity *player = ENTITY(g_IEngine->GetPlayerForUserID(kv->GetInt("userid")));
|
CachedEntity *player = ENTITY(GetPlayerForUserID(kv->GetInt("userid")));
|
||||||
if (player == nullptr || RAW_ENT(player) == nullptr)
|
if (player == nullptr || RAW_ENT(player) == nullptr)
|
||||||
return;
|
return;
|
||||||
PrintChat("\x07%06X%s\x01 \x07%06X%s\x01 disconnected", colors::chat::team(player->m_iTeam()), kv->GetString("name"), 0x914e65, kv->GetString("networkid"));
|
PrintChat("\x07%06X%s\x01 \x07%06X%s\x01 disconnected", colors::chat::team(player->m_iTeam()), kv->GetString("name"), 0x914e65, kv->GetString("networkid"));
|
||||||
@ -69,10 +69,10 @@ static void handlePlayerHurt(KeyValues *kv)
|
|||||||
int health = kv->GetInt("health");
|
int health = kv->GetInt("health");
|
||||||
player_info_s kinfo{};
|
player_info_s kinfo{};
|
||||||
player_info_s vinfo{};
|
player_info_s vinfo{};
|
||||||
if (!GetPlayerInfo(g_IEngine->GetPlayerForUserID(victim), &vinfo) || !GetPlayerInfo(g_IEngine->GetPlayerForUserID(attacker), &kinfo))
|
if (!GetPlayerInfo(GetPlayerForUserID(victim), &vinfo) || !GetPlayerInfo(GetPlayerForUserID(attacker), &kinfo))
|
||||||
return;
|
return;
|
||||||
CachedEntity *vic = ENTITY(g_IEngine->GetPlayerForUserID(victim));
|
CachedEntity *vic = ENTITY(GetPlayerForUserID(victim));
|
||||||
CachedEntity *att = ENTITY(g_IEngine->GetPlayerForUserID(attacker));
|
CachedEntity *att = ENTITY(GetPlayerForUserID(attacker));
|
||||||
|
|
||||||
if (vic == nullptr || att == nullptr || RAW_ENT(vic) == nullptr || RAW_ENT(att) == nullptr)
|
if (vic == nullptr || att == nullptr || RAW_ENT(vic) == nullptr || RAW_ENT(att) == nullptr)
|
||||||
return;
|
return;
|
||||||
@ -86,10 +86,10 @@ static void handlePlayerDeath(KeyValues *kv)
|
|||||||
int attacker = kv->GetInt("attacker");
|
int attacker = kv->GetInt("attacker");
|
||||||
player_info_s kinfo{};
|
player_info_s kinfo{};
|
||||||
player_info_s vinfo{};
|
player_info_s vinfo{};
|
||||||
if (!GetPlayerInfo(g_IEngine->GetPlayerForUserID(victim), &vinfo) || !GetPlayerInfo(g_IEngine->GetPlayerForUserID(attacker), &kinfo))
|
if (!GetPlayerInfo(GetPlayerForUserID(victim), &vinfo) || !GetPlayerInfo(GetPlayerForUserID(attacker), &kinfo))
|
||||||
return;
|
return;
|
||||||
CachedEntity *vic = ENTITY(g_IEngine->GetPlayerForUserID(victim));
|
CachedEntity *vic = ENTITY(GetPlayerForUserID(victim));
|
||||||
CachedEntity *att = ENTITY(g_IEngine->GetPlayerForUserID(attacker));
|
CachedEntity *att = ENTITY(GetPlayerForUserID(attacker));
|
||||||
|
|
||||||
if (vic == nullptr || att == nullptr || RAW_ENT(vic) == nullptr || RAW_ENT(att) == nullptr)
|
if (vic == nullptr || att == nullptr || RAW_ENT(vic) == nullptr || RAW_ENT(att) == nullptr)
|
||||||
return;
|
return;
|
||||||
@ -101,9 +101,9 @@ static void handlePlayerSpawn(KeyValues *kv)
|
|||||||
{
|
{
|
||||||
int id = kv->GetInt("userid");
|
int id = kv->GetInt("userid");
|
||||||
player_info_s info{};
|
player_info_s info{};
|
||||||
if (!GetPlayerInfo(g_IEngine->GetPlayerForUserID(id), &info))
|
if (!GetPlayerInfo(GetPlayerForUserID(id), &info))
|
||||||
return;
|
return;
|
||||||
CachedEntity *player = ENTITY(g_IEngine->GetPlayerForUserID(id));
|
CachedEntity *player = ENTITY(GetPlayerForUserID(id));
|
||||||
if (player == nullptr || RAW_ENT(player) == nullptr)
|
if (player == nullptr || RAW_ENT(player) == nullptr)
|
||||||
return;
|
return;
|
||||||
PrintChat("\x07%06X%s\x01 (re)spawned", colors::chat::team(player->m_iTeam()), info.name);
|
PrintChat("\x07%06X%s\x01 (re)spawned", colors::chat::team(player->m_iTeam()), info.name);
|
||||||
@ -115,9 +115,9 @@ static void handlePlayerChangeClass(KeyValues *kv)
|
|||||||
if (id > PLAYER_ARRAY_SIZE || id < 0)
|
if (id > PLAYER_ARRAY_SIZE || id < 0)
|
||||||
return;
|
return;
|
||||||
player_info_s info{};
|
player_info_s info{};
|
||||||
if (!GetPlayerInfo(g_IEngine->GetPlayerForUserID(id), &info))
|
if (!GetPlayerInfo(GetPlayerForUserID(id), &info))
|
||||||
return;
|
return;
|
||||||
CachedEntity *player = ENTITY(g_IEngine->GetPlayerForUserID(id));
|
CachedEntity *player = ENTITY(GetPlayerForUserID(id));
|
||||||
if (player == nullptr || RAW_ENT(player) == nullptr)
|
if (player == nullptr || RAW_ENT(player) == nullptr)
|
||||||
return;
|
return;
|
||||||
PrintChat("\x07%06X%s\x01 changed to \x07%06X%s\x01", colors::chat::team(player->m_iTeam()), info.name, 0xa06ba0, classname(kv->GetInt("class")));
|
PrintChat("\x07%06X%s\x01 changed to \x07%06X%s\x01", colors::chat::team(player->m_iTeam()), info.name, 0xa06ba0, classname(kv->GetInt("class")));
|
||||||
|
@ -20,7 +20,7 @@ static std::unique_ptr<zerokernel::special::PlayerListController> controller{ nu
|
|||||||
static zerokernel::special::PlayerListData createPlayerListData(int userid)
|
static zerokernel::special::PlayerListData createPlayerListData(int userid)
|
||||||
{
|
{
|
||||||
zerokernel::special::PlayerListData data{};
|
zerokernel::special::PlayerListData data{};
|
||||||
auto idx = g_IEngine->GetPlayerForUserID(userid);
|
auto idx = GetPlayerForUserID(userid);
|
||||||
player_info_s info{};
|
player_info_s info{};
|
||||||
GetPlayerInfo(idx, &info);
|
GetPlayerInfo(idx, &info);
|
||||||
data.classId = g_pPlayerResource->getClass(idx);
|
data.classId = g_pPlayerResource->getClass(idx);
|
||||||
@ -76,7 +76,7 @@ void sortPList()
|
|||||||
player_info_s info{};
|
player_info_s info{};
|
||||||
if (GetPlayerInfo(i, &info))
|
if (GetPlayerInfo(i, &info))
|
||||||
{
|
{
|
||||||
auto idx = g_IEngine->GetPlayerForUserID(info.userID);
|
auto idx = GetPlayerForUserID(info.userID);
|
||||||
if (g_pPlayerResource->getTeam(idx) == 2)
|
if (g_pPlayerResource->getTeam(idx) == 2)
|
||||||
{
|
{
|
||||||
controller->addPlayer(info.userID, createPlayerListData(info.userID));
|
controller->addPlayer(info.userID, createPlayerListData(info.userID));
|
||||||
@ -88,7 +88,7 @@ void sortPList()
|
|||||||
player_info_s info{};
|
player_info_s info{};
|
||||||
if (GetPlayerInfo(i, &info))
|
if (GetPlayerInfo(i, &info))
|
||||||
{
|
{
|
||||||
auto idx = g_IEngine->GetPlayerForUserID(info.userID);
|
auto idx = GetPlayerForUserID(info.userID);
|
||||||
if (g_pPlayerResource->getTeam(idx) == 3)
|
if (g_pPlayerResource->getTeam(idx) == 3)
|
||||||
{
|
{
|
||||||
controller->addPlayer(info.userID, createPlayerListData(info.userID));
|
controller->addPlayer(info.userID, createPlayerListData(info.userID));
|
||||||
@ -100,7 +100,7 @@ void sortPList()
|
|||||||
player_info_s info{};
|
player_info_s info{};
|
||||||
if (GetPlayerInfo(i, &info))
|
if (GetPlayerInfo(i, &info))
|
||||||
{
|
{
|
||||||
auto idx = g_IEngine->GetPlayerForUserID(info.userID);
|
auto idx = GetPlayerForUserID(info.userID);
|
||||||
if (g_pPlayerResource->getTeam(idx) != 2 && g_pPlayerResource->getTeam(idx) != 3)
|
if (g_pPlayerResource->getTeam(idx) != 2 && g_pPlayerResource->getTeam(idx) != 3)
|
||||||
{
|
{
|
||||||
controller->addPlayer(info.userID, createPlayerListData(info.userID));
|
controller->addPlayer(info.userID, createPlayerListData(info.userID));
|
||||||
|
Reference in New Issue
Block a user