Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented entity transmit feature #608

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c7c0e8c
chore: bump to latest hl2sdk
KillStr3aK Oct 6, 2024
35fca3f
feat: get interface `ISource2GameEntities`
KillStr3aK Oct 6, 2024
850a389
feat: Add `CheckTransmit`
KillStr3aK Oct 6, 2024
148fbf8
feat: Add `CheckTransmitPlayerSlot`
KillStr3aK Oct 6, 2024
2e2771e
feat: Add hook and listener for `CheckTransmit`
KillStr3aK Oct 6, 2024
01479af
feat: added `CheckTransmit` listener
KillStr3aK Oct 6, 2024
265cfb8
feat: Added `CFixedBitVecBase` (thanks: qstage)
KillStr3aK Oct 6, 2024
ce19fe8
feat: implemented `CCheckTransmitInfoList` and added `CCheckTransmitI…
KillStr3aK Oct 6, 2024
9d03cb4
feat: added example for `CheckTransmit` listener
KillStr3aK Oct 6, 2024
82a2346
Merge branch 'roflmuffin:main' into feature/entity-transmit
KillStr3aK Oct 6, 2024
23f625b
feat: added `WithCheckTransmit` example
KillStr3aK Oct 6, 2024
3519a95
Merge branch 'feature/entity-transmit' of https://github.com/KillStr3…
KillStr3aK Oct 6, 2024
0cdbc1d
fix: added check for self
KillStr3aK Oct 6, 2024
46c323f
chore: update and extended examples
KillStr3aK Oct 6, 2024
c12ed80
fix: continue instead of return
KillStr3aK Oct 6, 2024
d479cac
tweak: reuse code from utils
KillStr3aK Oct 7, 2024
c507f6f
tweak: renamed to `TransmitEntities`
KillStr3aK Oct 9, 2024
6c1125f
feat: `CFixedBitVecBase::Write`
KillStr3aK Oct 9, 2024
e6a1248
tweak: adjusted naming
KillStr3aK Oct 9, 2024
b20aaa5
feat: methods with `CEntityInstance` params
KillStr3aK Oct 9, 2024
9a69a63
tweak: adjusted changes
KillStr3aK Oct 9, 2024
0eac0a9
tweak: adjusted
KillStr3aK Oct 9, 2024
17170b5
Merge branch 'roflmuffin:main' into feature/entity-transmit
KillStr3aK Oct 10, 2024
a3d5e14
feat: added `TransmitAlways` to `CCheckTransmitInfo`
KillStr3aK Oct 10, 2024
6fd68b5
feat: added wrapper `CCheckTransmitInfoList`
KillStr3aK Oct 10, 2024
2c9db33
tweak: removed `infoCount`
KillStr3aK Oct 10, 2024
a99cd58
tweak: adjusted changes and supports `Count`
KillStr3aK Oct 10, 2024
663f07e
tweak: adjusted changes
KillStr3aK Oct 10, 2024
6f9e465
feat: throw exception when oob
KillStr3aK Oct 10, 2024
3ed0c0d
tweak: break down code
KillStr3aK Oct 10, 2024
6782b93
style: adjusted code
KillStr3aK Oct 10, 2024
700550d
style: adjusted code
KillStr3aK Oct 10, 2024
c516cce
fix: adjusted code to return full info
KillStr3aK Oct 10, 2024
daf35f5
tweak: `CCheckTransmitInfoList.Get` is now private
KillStr3aK Oct 10, 2024
441485a
style: fix indentitation
KillStr3aK Oct 10, 2024
c161dcc
Merge branch 'main' into feature/entity-transmit
KillStr3aK Oct 11, 2024
f887fed
Merge branch 'main' into feature/entity-transmit
KillStr3aK Oct 13, 2024
dd24d8c
Merge branch 'main' into feature/entity-transmit
KillStr3aK Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/WithCheckTransmit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# With CheckTransmit
This example shows how to work with the `CheckTransmit` listener.
13 changes: 13 additions & 0 deletions examples/WithCheckTransmit/WithCheckTransmit.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\managed\CounterStrikeSharp.API\CounterStrikeSharp.API.csproj" />
</ItemGroup>

</Project>
60 changes: 60 additions & 0 deletions examples/WithCheckTransmit/WithCheckTransmitPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;

namespace WithCheckTransmit;

[MinimumApiVersion(276)]
public class WithCheckTransmitPlugin : BasePlugin
{
public override string ModuleName => "Example: With CheckTransmit";
public override string ModuleVersion => "1.0.0";
public override string ModuleAuthor => "CounterStrikeSharp & Contributors";
public override string ModuleDescription => "A simple plugin that uses the CheckTransmit listener!";

public override void Load(bool hotReload)
{
RegisterListener<Listeners.CheckTransmit>((CCheckTransmitInfoList infoList, int infoCount) =>
{
// Get the list of the current players, we only work with this value later on
List<CCSPlayerController> players = Utilities.GetPlayers();

for (int i = 0; i < infoCount; i++)
{
// The 'Get' function returns a tuple with the info for the given index, also the slot the info belongs to.
// You should never pass an integer outside of the boundaries! (0 <= index < infoCount)
(CCheckTransmitInfo info, int slot) = infoList.Get(i);

// We can use the slot to get the player the info belongs to
CCSPlayerController? infoPlayer = Utilities.GetPlayerFromSlot(slot);

// If no player is found, we can return
if (infoPlayer == null)
{
return;
}

// Otherwise, lets do the work:

// as an example, lets hide everyone for this player who is in the same team.
IEnumerable<CCSPlayerController> targetPlayers = players.Where(p =>
// is the player and its pawn valid
p.IsValid && p.Pawn.IsValid &&

// is the player is in the same team
p.Team == infoPlayer.Team &&

// is alive
p.PlayerPawn.Value?.LifeState == (byte)LifeState_t.LIFE_ALIVE
);

foreach (CCSPlayerController targetPlayer in targetPlayers)
{
// Calling 'Clear' will remove the entity index of the target player pawn from the transmission list
// so it won't be transmitted for the 'infoPlayer' player.
info.TransmitEntity.Clear(targetPlayer.Pawn.Index);
}
}
});
}
}
26 changes: 21 additions & 5 deletions managed/CounterStrikeSharp.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35309.182
MinimumVisualStudioVersion = 10.0.40219.1
Comment on lines +3 to +5
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure about these, probably was autogenerated when saving

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestPlugin", "TestPlugin\TestPlugin.csproj", "{57E64289-5D69-4AA1-BEF0-D0D96A55EE8F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CounterStrikeSharp.API", "CounterStrikeSharp.API\CounterStrikeSharp.API.csproj", "{55B47E41-61AA-4D75-9069-CB14328107B7}"
Expand Down Expand Up @@ -42,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WithSharedTypesConsumer", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WithUserMessages", "..\examples\WithUserMessages\WithUserMessages.csproj", "{A14029BA-CADE-4F25-ADC5-48CF14332F61}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WithCheckTransmit", "..\examples\WithCheckTransmit\WithCheckTransmit.csproj", "{854B06B5-0E7B-438A-BA51-3F299557F884}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -108,14 +113,14 @@ Global
{6FA3107D-42AF-42A0-BF51-2230D13268B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6FA3107D-42AF-42A0-BF51-2230D13268B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6FA3107D-42AF-42A0-BF51-2230D13268B5}.Release|Any CPU.Build.0 = Release|Any CPU
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Release|Any CPU.Build.0 = Release|Any CPU
{1309954E-FAF7-47A5-9FF9-C7263B33E4E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1309954E-FAF7-47A5-9FF9-C7263B33E4E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1309954E-FAF7-47A5-9FF9-C7263B33E4E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1309954E-FAF7-47A5-9FF9-C7263B33E4E3}.Release|Any CPU.Build.0 = Release|Any CPU
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Release|Any CPU.Build.0 = Release|Any CPU
{A37676EA-CF2F-424D-85A1-C359D07A679D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A37676EA-CF2F-424D-85A1-C359D07A679D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A37676EA-CF2F-424D-85A1-C359D07A679D}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -128,6 +133,13 @@ Global
{A14029BA-CADE-4F25-ADC5-48CF14332F61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A14029BA-CADE-4F25-ADC5-48CF14332F61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A14029BA-CADE-4F25-ADC5-48CF14332F61}.Release|Any CPU.Build.0 = Release|Any CPU
{854B06B5-0E7B-438A-BA51-3F299557F884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{854B06B5-0E7B-438A-BA51-3F299557F884}.Debug|Any CPU.Build.0 = Debug|Any CPU
{854B06B5-0E7B-438A-BA51-3F299557F884}.Release|Any CPU.ActiveCfg = Release|Any CPU
{854B06B5-0E7B-438A-BA51-3F299557F884}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{57E64289-5D69-4AA1-BEF0-D0D96A55EE8F} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A}
Expand All @@ -141,10 +153,14 @@ Global
{31EABE0B-871F-497B-BF36-37FFC6FAD15F} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A}
{BB44E08E-CCA8-4E22-A132-11B2F69D1890} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A}
{6FA3107D-42AF-42A0-BF51-2230D13268B5} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A}
{4E5289B5-E81D-421C-B340-B98B6FFE09D1} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A}
{1309954E-FAF7-47A5-9FF9-C7263B33E4E3} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A}
{4E5289B5-E81D-421C-B340-B98B6FFE09D1} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A}
{A37676EA-CF2F-424D-85A1-C359D07A679D} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A}
{76AD7BB0-A096-4336-83E2-B32CAE4E9933} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A}
{A14029BA-CADE-4F25-ADC5-48CF14332F61} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A}
{854B06B5-0E7B-438A-BA51-3F299557F884} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {069C4CD4-BACA-446A-A6B8-0194E4F75355}
Comment on lines +163 to +164
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure about these, probably was autogenerated when saving

EndGlobalSection
EndGlobal