Skip to content

In "Player packet usage" see all packet types#4779

Open
ArranTuna wants to merge 2 commits intomultitheftauto:masterfrom
ArranTuna:perfpackets
Open

In "Player packet usage" see all packet types#4779
ArranTuna wants to merge 2 commits intomultitheftauto:masterfrom
ArranTuna:perfpackets

Conversation

@ArranTuna
Copy link
Copy Markdown
Collaborator

@ArranTuna ArranTuna commented Apr 5, 2026

Summary

Current in player packet usage you can only see 3 types, command, lua event, and custom data. There are benefits to seeing all packets in order to detect malicious activity.

Motivation

My server, and after looking at the discord, many other servers are being attacked, one method of attack is certain packet types being sent in by a player, now although the "Packet usage" section shows you which packet is flooding, you don't know whose doing it, until now:

image

Test plan

I have tried different things and see that it is showing those packets come in, for example shooting would show me 98_Player_bulletsync, being on foot shows 32_Player_puresync, get in a vehicle it changes to 33_Player_vehicle_puresync incoming.

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

@ArranTuna ArranTuna requested a review from a team as a code owner April 5, 2026 11:30

constexpr size_t GetPacketIdCount()
{
return static_cast<size_t>(PACKET_ID_PLAYER_WORLD_SPECIAL_PROPERTY) + 1;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach is not safe, because adding a new packet in the future would require manually updating this value.
It might be better to add something like NUM_PACKETS at the end of the ePacketID enum, along with a comment indicating that all new packets should be added above this line.

Comment on lines +29 to +31
std::vector<uchar> GetAllPacketIds()
{
std::vector<uchar> packetIds(GetPacketIdCount());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uchar -> std::uint8_t


for (size_t index = 0; index < packetIds.size(); ++index)
{
packetIds[index] = static_cast<uchar>(index);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::ranges::iota?

const uint uiNumPacketIds = NUMELMS(packetIdList);
// Build the request from the shared packet enum so new packet types show up in
// getPerformanceStats automatically instead of being hidden behind a stale shortlist.
auto packetIdList = GetAllPacketIds();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto&

@ArranTuna
Copy link
Copy Markdown
Collaborator Author

Thanks FileEX, I've made a new commit which addresses your feedbacks.

@FileEX FileEX added the enhancement New feature or request label Apr 5, 2026
@FileEX FileEX added this to the 1.7 (Current) milestone Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants