Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
added new event for players leaving the lobby
Browse files Browse the repository at this point in the history
  • Loading branch information
v0idp committed Nov 23, 2021
1 parent 68a2089 commit 7dca974
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 4 deletions.
1 change: 1 addition & 0 deletions AmongUsMenu.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<ItemGroup>
<ClCompile Include="events\CastVoteEvent.cpp" />
<ClCompile Include="events\CheatDetectedEvent.cpp" />
<ClCompile Include="events\DisconnectEvent.cpp" />
<ClCompile Include="events\KillEvent.cpp" />
<ClCompile Include="events\ReportDeadBodyEvent.cpp" />
<ClCompile Include="events\TaskCompletedEvent.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions AmongUsMenu.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@
<ClCompile Include="events\WalkEvent.cpp">
<Filter>events</Filter>
</ClCompile>
<ClCompile Include="events\DisconnectEvent.cpp">
<Filter>events</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="appdata\il2cpp-api-functions.h">
Expand Down
24 changes: 24 additions & 0 deletions events/DisconnectEvent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "pch-il2cpp.h"
#include "_events.h"
#include "utility.h"

DisconnectEvent::DisconnectEvent(EVENT_PLAYER source) : EventInterface(source, EVENT_DISCONNECT) { }

void DisconnectEvent::Output() {
ImGui::TextColored(AmongUsColorToImVec4(GetPlayerColor(source.colorId)), source.playerName.c_str());
ImGui::SameLine();
ImGui::Text("has left the game");
ImGui::SameLine();
auto sec = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count() - std::chrono::duration_cast<std::chrono::seconds>(this->timestamp.time_since_epoch()).count();
auto min = std::chrono::duration_cast<std::chrono::minutes>(std::chrono::system_clock::now().time_since_epoch()).count() - std::chrono::duration_cast<std::chrono::minutes>(this->timestamp.time_since_epoch()).count();
if (sec < 60) ImGui::Text(" [%ds ago]", sec);
else ImGui::Text(" [%dm ago]", min);
}

void DisconnectEvent::ColoredEventOutput() {
ImGui::Text("[");
ImGui::SameLine();
ImGui::TextColored(ImVec4(1.f, 1.f, 1.f, 1.f), "DISCONNECT");
ImGui::SameLine();
ImGui::Text("]");
}
12 changes: 10 additions & 2 deletions events/_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ enum EVENT_TYPES {
EVENT_MEETING = 0x5,
EVENT_VOTE = 0x6,
EVENT_CHEAT = 0x7,
EVENT_WALK = 0x8,
EVENT_TYPES_SIZE = 9
EVENT_DISCONNECT = 0x8,
EVENT_WALK = 0x9,
EVENT_TYPES_SIZE = 10
};

enum VENT_ACTION {
Expand Down Expand Up @@ -149,6 +150,13 @@ class CheatDetectedEvent : public EventInterface {
virtual void ColoredEventOutput() override;
};

class DisconnectEvent : public EventInterface {
public:
DisconnectEvent(EVENT_PLAYER source);
virtual void Output() override;
virtual void ColoredEventOutput() override;
};

class WalkEvent : public EventInterface {
private:
Vector2 position;
Expand Down
2 changes: 1 addition & 1 deletion gui/console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <vector>

namespace ConsoleGui {
const std::vector<const char*> BY_TYPE = { "", "Kill", "Vent", "Task", "Report", "Meeting", "Vote", "Cheat" };
const std::vector<const char*> BY_TYPE = { "All", "Kill", "Vent", "Task", "Report", "Meeting", "Vote", "Cheat", "Disconnect" };
extern int selectedType;

void Init();
Expand Down
3 changes: 3 additions & 0 deletions hooks/InnerNetClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ void dAmongUsClient_OnPlayerLeft(AmongUsClient* __this, ClientData* data, Discon
auto it = std::find(State.aumUsers.begin(), State.aumUsers.end(), data->fields.Character->fields.PlayerId);
if (it != State.aumUsers.end())
State.aumUsers.erase(it);

State.events[data->fields.Character->fields.PlayerId][EVENT_DISCONNECT].push_back(new DisconnectEvent(GetEventPlayer(data->fields.Character->fields._cachedData).value()));
State.consoleEvents.push_back(new DisconnectEvent(GetEventPlayer(data->fields.Character->fields._cachedData).value()));
}

AmongUsClient_OnPlayerLeft(__this, data, reason, method);
Expand Down
2 changes: 1 addition & 1 deletion user/gitparams.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#define GIT_CUR_COMMIT 9c1b3553fa9d5ce5471b61c88699736db773ed77
#define GIT_CUR_COMMIT 68a2089d212e5058138387a4202ead7f92350570
#define GIT_BRANCH main

0 comments on commit 7dca974

Please sign in to comment.