Compare commits

...

318 Commits

Author SHA1 Message Date
roflmuffin
0390a03829 Merge remote-tracking branch 'origin/main' into release/v2
# Conflicts:
#	managed/CounterStrikeSharp.API/Core/Schema/Classes/CCSPlayer_MovementServices.g.cs
2025-11-06 11:12:52 +10:00
dependabot[bot]
0322548ebd chore(deps): bump libraries/metamod-source from 4399ff0 to 07c708a (#1101)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-06 00:57:56 +00:00
dependabot[bot]
e4b1a35308 chore(deps): bump libraries/hl2sdk-cs2 from 84a823d to da981a8 (#1108)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: roflmuffin <shortguy014@gmail.com>
2025-11-06 00:51:23 +00:00
dependabot[bot]
fd8defc1b9 chore(deps): bump libraries/Protobufs from 53da9bc to 7af53a5 (#1109)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-06 09:11:33 +10:00
Michael Wilson
cebec419fa release: v1.0.346 2025-11-05 10:52:14 +00:00
Michael Wilson
52550e31bc chore: update server.json 2025-11-05 20:51:13 +10:00
LynchMus
e59e9cf148 fix: changes for 2025-11-5 Update (#1107) 2025-11-05 20:44:03 +10:00
Luca.
1568d077e8 feat: add localization for no permission error messages & spanish language support. (#1099) 2025-11-05 16:57:45 +10:00
roflmuffin
ed919216f1 fix: make natives internal 2025-11-04 13:29:00 +00:00
roflmuffin
d999da91c8 fix: generate natives into generated folder as well 2025-11-04 13:27:41 +00:00
roflmuffin
5f482ea2a1 chore: move schema generated content to the generated folder as well 2025-11-04 13:25:12 +00:00
roflmuffin
9b451e535f feat: generate game events into separate files 2025-11-04 13:21:26 +00:00
roflmuffin
39995a7054 fix: generate handles as value type 2025-11-04 13:06:18 +00:00
roflmuffin
7ae4ba959f chore: reorganise some files 2025-11-04 22:59:50 +10:00
roflmuffin
e7299d2b6a fix: misc test fixes, change schema properties to virtual 2025-11-04 09:37:04 +00:00
roflmuffin
b006506695 fix: don't generate constructor and fix type for auto generated CEntityInstance 2025-11-03 05:12:38 +00:00
roflmuffin
3d6e99d9de ci: run build on release branches 2025-11-01 06:28:00 +00:00
roflmuffin
7fabd8e1d0 feat: swap Vector4D and Vector2D for numerics versions 2025-11-01 06:25:19 +00:00
roflmuffin
de95e4f873 fix: test plugin 2025-10-30 07:20:51 +00:00
roflmuffin
38d2dfd17c feat: add network change methods to schema classes 2025-10-30 06:57:46 +00:00
roflmuffin
0cddb171c6 feat: update schema system to add get/set of value types 2025-10-30 06:33:47 +00:00
roflmuffin
6794d0a21c feat: use system numerics vector3 and create qangle class based on numerics.vector3 2025-10-30 06:33:09 +00:00
Ravid Atia
55542dba7c feat: allow plugins to be loaded from subdirectories (#1031)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2025-10-30 05:27:42 +00:00
Michael Wilson
33538eca60 release: v1.0.345 2025-10-30 01:41:23 +00:00
Michael Wilson
b4e83dfb4a fix: update linux signature for GetCSWeaponDataFromKey 2025-10-30 11:40:04 +10:00
roflmuffin
4ff2732d8a feat(schema): update schema generator to use @GAMMACASE schema dumper format 2025-10-27 06:48:05 +00:00
Michael Wilson
67d3d044fd release: v1.0.344 2025-10-27 05:36:18 +00:00
roflmuffin
f50540583d chore(schema): update schema to latest 2025-10-27 05:15:04 +00:00
roflmuffin
97957f6220 fix(schema): allow for negative enum values in source schema file 2025-10-27 05:14:15 +00:00
roflmuffin
0c2f1cd078 [no ci] chore: update devcontainer location 2025-10-22 20:18:59 +10:00
Michael Wilson
9eefe9c61a release: v1.0.343 2025-10-20 01:03:13 +00:00
Nocky
7be329466a feat: add BuyWithCtrl to AcquireMethod enum
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2025-10-19 23:25:46 +00:00
Matlord93
a21f0b5277 fix: update ConVar flag retrieval that adapts to different Source 2 SDK versions (#1059)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2025-10-18 08:10:39 +00:00
dxqshka
b4ba7d8ca0 feat(experimental): add NuGet Dependency Resolver for Plugins (#1012) 2025-10-18 07:35:40 +00:00
Michal
0eb73eb348 feat: add FindVirtualTable method (#1075) 2025-10-18 10:59:33 +10:00
Markus
43c1c89596 feat: use shared libgcc and libc++ (#1007)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2025-10-17 06:53:42 +00:00
宇宙 猫
53996666f8 feat: implement TerminateSelf(string reason) to allow plugins to safely terminate themselves (#1047)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2025-10-17 06:30:59 +00:00
schwarper
a8510d183d feat: add core translations & processtargetstring (#1051) 2025-10-17 16:19:49 +10:00
Michael Wilson
a52f5e737d release: v1.0.342 2025-10-16 06:41:06 +00:00
LynchMus
34598dd56e fix: update Sigs & CTakeDamageResult & EmitSound_t (#1071) 2025-10-16 06:40:10 +00:00
Michael Wilson
325728e753 release: v1.0.341 2025-10-16 06:19:32 +00:00
roflmuffin
56e007402b fix: update schema for update 2025-10-16 16:15:05 +10:00
dependabot[bot]
bf75d43039 chore(deps): bump libraries/hl2sdk-cs2 from bc59586 to 9310e72 (#908)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-16 15:09:02 +10:00
dependabot[bot]
7572722de4 chore(deps): bump libraries/metamod-source from 3f3136d to 4399ff0 (#1067)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-15 14:37:56 +00:00
LynchMus
638d74470e fix: EmitSoundFilter Crash (#1066) 2025-10-16 00:28:03 +10:00
LynchMus
37951f2875 fix(update): update signatures and offsets for 1.41.1.3 Update (#1064) 2025-10-15 19:46:38 +10:00
schwarper
7b9df9097c feat: improve getplayers & RemoveItemByDesignerName (#1044) 2025-09-27 08:52:41 +10:00
宇宙 猫
31cedca2b7 feat: Allow custom CS# directory for flexible server deployment (aka. css_basepath) (#1033) 2025-09-22 14:40:20 +10:00
Michael Wilson
4869acac41 release: v1.0.340 2025-09-18 06:53:31 +00:00
Oylsister
2c80971393 fix: update for CS2 09-17-25 (patch 20022951) (#1037)
Co-authored-by: Alex <6075172+vauff@users.noreply.github.com>
Co-authored-by: MADAO <73157477+ismadao@users.noreply.github.com>
2025-09-18 06:50:37 +00:00
宇宙 猫
44922da680 fix: Invalid string pointers passed by SetResult due to C++ memory lifecycle (#1032) 2025-09-09 19:23:23 +10:00
宇宙 猫
1ca8ff2172 feat: Implement bypass hook for Invoke method (#1027) 2025-09-08 06:15:11 +00:00
Michael Wilson
99f7f37b10 release: v1.0.339 2025-09-04 00:34:35 +00:00
SLAYER
54f8d5ef95 Fixed offset values of Respawn and Slay for Windows (#1026) 2025-09-04 10:26:11 +10:00
Michael Wilson
a7443b2a60 release: v1.0.338 2025-08-31 11:29:55 +00:00
Levin V.
72d66cb5d5 Update gamedata.json (#1020) 2025-08-29 08:39:42 +10:00
Michael Wilson
adccc4b9e9 release: v1.0.337 2025-08-21 00:47:25 +00:00
Michael Wilson
fc7301a8d3 feat(schema): add new schema classes for build 19644975 2025-08-21 00:36:35 +00:00
Michael Wilson
ef4b8f9442 feat(schema): update schema classes for build 19644975 2025-08-21 00:32:21 +00:00
Michael Wilson
245f55daf3 fix: update FindPickerEntity implementation (thanks @KillStr3aK) 2025-08-21 00:20:05 +00:00
Michael Wilson
936b88d57c fix(gamedata): update CBasePlayerController_SetPawn signature 2025-08-21 10:15:10 +10:00
Michael Wilson
ee792de1a0 release: v1.0.336 2025-08-18 01:53:16 +00:00
Michael Wilson
624ca0f0de fix: re-add GetHitGroup with GameData backed offset 2025-08-18 01:50:39 +00:00
Michael Wilson
592acc28aa release: v1.0.335 2025-08-16 00:53:03 +00:00
Michael Wilson
51b6b45390 fix: obsolete GetHitGroup() and point to HitGroupId schema property 2025-08-16 00:35:58 +00:00
Michael Wilson
d5fad8d801 chore(deps): update hl2sdk 2025-08-16 00:08:27 +00:00
Michael Wilson
bf1ce2e8a3 chore(gamedata): update offsets & signatures 2025-08-16 00:08:11 +00:00
Michael Wilson
0761d267ba fix: revert MaxPlayers caching 2025-08-15 00:49:44 +00:00
Michael Wilson
92959dea6e release: v1.0.334 2025-08-15 00:22:04 +00:00
Daniel Saewitz
f7c69a60be fix: update hl2sdk for patch 19602992 (Aug 14 2025) (#988) 2025-08-15 10:21:08 +10:00
Michael Wilson
6f796d9ae9 release: v1.0.333 2025-08-05 12:18:39 +00:00
Michael Wilson
1f9c7a090b perf: cache Server.MaxPlayers to improve performance of Utilities.GetPlayers() 2025-08-05 12:11:07 +00:00
Michael Wilson
2cf2d45e8e feat: add OnPlayerChat listener (#973) 2025-08-05 11:43:38 +00:00
Michael Wilson
fa383cda68 chore: apply alliedmodders hl2sdk again (#974) 2025-08-05 21:38:23 +10:00
Michael Wilson
e1acada35e release: v1.0.332 2025-08-05 06:58:41 +00:00
samyyc
dc503e7f57 fix: re-enable EmitSoundFilter (#968) 2025-08-05 16:53:24 +10:00
Luca.
fedfe75601 fix: update GetHitGroup offset (#970) 2025-08-04 23:39:33 +00:00
samyyc
3508fdfd8c fix: crash caused by AddEntityIOEvent (#969) 2025-08-04 22:13:33 +10:00
Michael Wilson
741d6a3fc8 release: v1.0.331 2025-08-04 10:30:24 +00:00
Michael Wilson
356152a567 fix: revert chat command hooking back to detour of Host_Say 2025-08-04 10:26:00 +00:00
Michael Wilson
31e12ba809 release: v1.0.330 2025-08-04 05:46:01 +00:00
samyyc
529a0cbf5b fix: CheckTransmit hook not firing (#966) 2025-08-04 15:31:26 +10:00
Michael Wilson
ed7c28f9e3 release: v1.0.329 2025-08-03 23:34:14 +00:00
Michael Wilson
1f30e5619f fix: Update CS# for Patch 19388062 (#958) 2025-08-04 09:28:05 +10:00
Michael Wilson
af3bb528d7 chore: schema update for patch 19388062 (#962) 2025-08-03 11:38:08 +10:00
K4ryuu
b7abd1d59e chore: update Gamedata for Patch 19388062
Credits: @Pisex, @stefanx11, @K4ryuu
2025-07-29 13:05:53 +00:00
Michael Wilson
dd50221321 feat: add OnPlayerButtonsChanged listener (#942) 2025-07-20 11:20:23 +00:00
Michael Wilson
9491732a38 feat: add Vector3 and QAngle explicit casts to System.Numerics.Vector3 (#943) 2025-07-20 11:15:11 +00:00
Michael Wilson
6c9321e3e7 feat: add OnServerPreEntityThink and OnServerPostEntityThink listeners (#941) 2025-07-17 15:42:07 +10:00
Michael Wilson
6acfa1491a release: v1.0.328 2025-07-17 02:01:56 +00:00
Michael Wilson
ad8116d4d2 feat: add css_dump_leaks command which outputs vector/angle count 2025-07-17 01:53:13 +00:00
Michael Wilson
26a8f641c8 test: add integration tests xunit plugin/runner (#928) 2025-07-14 14:54:35 +10:00
roflmuffin
f08b5e8439 chore(build): prevent unnecessary test builds 2025-07-11 20:58:22 +10:00
Michael Wilson
6e27a67917 release: v1.0.327 2025-07-10 21:36:17 +00:00
Michael Wilson
a8eff60d0b fix: update core.example.json 2025-07-10 21:36:03 +00:00
Michael Wilson
89fc5aeaf9 release: v1.0.326 2025-07-10 15:32:53 +00:00
Michael Wilson
ffb274d636 fix: remove requirement for https for game config updates (#930) 2025-07-11 01:31:49 +10:00
samyyc
b5303d15ab Support operating bytes type protobuf field (#922)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2025-07-10 06:19:46 +00:00
Michael Wilson
1a521ec3bb fix: prefix dump_schema command to enable compat with Source2 Schema Dumper by GAMMACASE 2025-07-10 05:22:31 +00:00
Michael Wilson
ec61ad37f0 release: v1.0.325 2025-07-10 03:53:52 +00:00
Michael Wilson
260015d765 fix: revert internal stack trace for performance (#927) 2025-07-10 13:53:01 +10:00
Michael Wilson
d346a02f98 release: v1.0.324 2025-07-10 01:04:18 +00:00
Michael Wilson
8ab61b00e8 feat: Add Automatic Gamedata Updates (#925) 2025-07-10 10:23:48 +12:00
Michael Wilson
c746c4e2e7 chore(dev): add node to devcontainer 2025-07-07 02:28:43 +00:00
Michael Wilson
32d3e18657 chore(dev): create release script 2025-07-07 02:26:26 +00:00
Michael Wilson
d5fa42cb50 release: v1.0.323 2025-07-07 02:18:32 +00:00
Michael Wilson
22809e3ec6 feat: update schema for game update 1.40.8.5 (03.07.2025) (#921) 2025-07-07 12:14:28 +10:00
Michael Wilson
87d197309b chore(dev): add build & sync commands for .NET API 2025-07-07 01:50:52 +00:00
Michael Wilson
e6bfb7939d chore(dev): add build & sync commands to vscode tasks 2025-07-07 01:42:50 +00:00
dependabot[bot]
0ae9227d73 chore(deps): bump libraries/metamod-source from 6091f15 to b17dc63 (#906)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2025-07-07 00:42:23 +00:00
Michael Wilson
7285d29454 release: v1.0.322 2025-07-07 00:36:16 +00:00
ZoNiCaL
124ffac7a9 Implement CVariant functions (#905) 2025-07-07 00:22:02 +00:00
Michael Wilson
267b017787 release: v1.0.321 2025-07-06 23:55:26 +00:00
Ian Lucas
018bcba655 Continued: Fixes for game update 1.40.8.5 (03.07.2025) (#917) 2025-07-05 06:49:02 +10:00
Michael Wilson
011401adb9 release: v1.0.320 2025-07-04 06:07:15 +00:00
Roman
bebeedf272 Fixes for game update 1.40.8.5 (03.07.2025) (#911) 2025-07-03 18:57:20 +00:00
Michael Wilson
7af153cf25 release: v1.0.319 2025-06-20 12:39:17 +00:00
Michal
6f663164ee Improve FunctionReference trace logging with real user stack origin (#895)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
Co-authored-by: root <root@ns3203586.ip-146-59-53.eu>
2025-06-20 12:28:14 +00:00
Michael Wilson
22f5c06c49 release: v1.0.318 2025-05-12 06:08:34 +00:00
Michael Wilson
073728b4ce fix(gameevents): merge and sort game event properties if duplicate events 2025-05-12 05:59:21 +00:00
Michael Wilson
6511a0098a chore: cleanup cpp & add clang format linting (#862) 2025-05-12 15:46:13 +10:00
Eason
f50fb783bb chore(build): duplicate include path: ${SOURCESDK}/public/entity2 (#756)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2025-05-12 04:23:03 +00:00
roflmuffin
49e8ab0e27 release: v1.0.317 2025-05-10 12:34:59 +10:00
roflmuffin
4be0634625 chore(gameevents): update game events (bullet_damage changes) 2025-05-10 12:32:05 +10:00
roflmuffin
7025b62615 chore(schema): update (mainly removal of danger zone classes) 2025-05-10 12:31:38 +10:00
Michael Wilson
462ca52229 chore(deps): upgrade metamod & hl2sdk (#856) 2025-05-10 12:17:45 +10:00
dependabot[bot]
d7e23e8282 chore(deps): bump libraries/Protobufs from 3d85413 to 53da9bc (#857)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-08 14:37:58 +10:00
roflmuffin
3ddfa71e3f feat: add Scoreboard and Inspect buttons to PlayerButtons 2025-05-02 20:16:02 +10:00
ipsvn
688b226bcf Fix potential event natives crashes (#852) 2025-04-29 14:32:50 +10:00
Michael Wilson
0d23387347 release: v1.0.316 2025-04-04 01:09:56 +00:00
Michael Wilson
68e6ffaebe fix(gamedata): update CCSPlayer_WeaponServices_CanUse signature 2025-04-04 11:08:07 +10:00
Michael Wilson
2f8f370cd3 fix: commit links in changelog finally 2025-04-01 17:02:15 +10:00
Michael Wilson
169d43e31d release: 1.0.315 2025-04-01 02:05:37 +00:00
schwarper
0ce4a2903c Update CCSPlayer_ItemServices_CanAcquire signature (#832) 2025-04-01 11:24:21 +10:00
Pawel Bartusiak
33b46eb214 docs: add automatic build and deploy guide (#831) 2025-03-31 11:45:43 +10:00
Michael Wilson
a27ba3b005 fix: move EventPlayerChat to dedicated file and exclude from generator
- Created a separate EventPlayerChat since this is being fired manually
- Updated event generator to exclude player_chat event from GameEvents.g.cs
2025-03-31 11:44:15 +10:00
Michael Wilson
57286c9990 chore(changelog): cleanup whitespace once and for all 2025-03-28 06:53:49 +00:00
Michael Wilson
ae808c05c8 [no ci] chore: fix commit links in release changelog 2025-03-27 14:46:17 +10:00
Michael Wilson
c9f8e477d3 release: 1.0.314 2025-03-27 04:06:33 +00:00
Michael Wilson
2398ba0a5d fix: manually revert EventPlayerChat to old value (#827) 2025-03-27 13:56:15 +10:00
roflmuffin
e45c20481d ci: hide release commits in changelog 2025-03-25 20:56:03 +10:00
roflmuffin
fe321ee93d ci: include full changelog link in discord message 2025-03-25 20:31:42 +10:00
roflmuffin
be19103556 chore: remove footer from cliff changelog 2025-03-25 20:29:16 +10:00
roflmuffin
64cb26b86d chore: fix newlines in changelog 2025-03-25 20:24:26 +10:00
roflmuffin
637224dc55 ci: fix cliff generation 2025-03-25 20:18:15 +10:00
roflmuffin
3aca7c37f1 ci: add changelog to release & webhook 2025-03-25 20:07:02 +10:00
roflmuffin
87f38d72ee release: v1.0.313 2025-03-25 19:28:06 +10:00
roflmuffin
5daf94791f chore(changelog): update cliff.toml 2025-03-25 19:18:19 +10:00
Michael Wilson
c50213c442 feat(config): add toml loading support (#804) 2025-03-25 19:12:29 +10:00
roflmuffin
c02d31cb2e chore: add links to contributors github page 2025-03-24 19:49:53 +10:00
roflmuffin
98cbca44d4 chore: update changelog to use semantic tags 2025-03-24 19:44:22 +10:00
Michael Wilson
4cf88fc03e fix(gameevents): promote core.gameevents to have higher priority (#819) 2025-03-24 19:32:47 +10:00
Michael Wilson
f1dff6d4d3 chrore: Implement SemVer instead of build numbers (#816) 2025-03-24 19:15:46 +10:00
Michael Wilson
414a59a36d fix(schema): inherited schema classes with clashing properties (#818) 2025-03-24 18:43:41 +10:00
Michael Wilson
f1c108087b fix(concommand): don't remove reference flags when running convar/concmd unlocker (#817) 2025-03-24 17:49:09 +10:00
roflmuffin
47ddf42c11 [no ci] add CHANGELOG.md 2025-03-24 12:27:09 +10:00
samyyc
ded133f1db Fix EmitSoundFilter signature for linux (#815) 2025-03-23 19:29:09 +10:00
samyyc
bbc621acdc feat: Implement EmitSoundFilter (#808)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2025-03-23 07:56:34 +00:00
Michael Wilson
f7784c26c6 fix: change terrorist chat colour to orange to be more in line with the game (#813) 2025-03-23 14:07:05 +10:00
qstage
2da5448c8e feat: add ListenerHandlerAttribute<T> (#757)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2025-03-17 02:16:33 +00:00
Michael Wilson
e406b78044 [no ci] chore: update protobuf (#803) 2025-03-17 12:10:01 +10:00
Michael Wilson
3839831ea9 [no ci] Update publish-docs.yml (#802) 2025-03-17 11:55:12 +10:00
samyyc
54ad6c0b79 feat: Expose Metamod MetaFactory to NativeAPI (#801) 2025-03-17 11:45:38 +10:00
Michael Wilson
7c2cc8a7f6 [no ci] chore: fix deprecated CI steps (#759) 2025-02-05 13:23:24 +10:00
qstage
e99d27ca30 fix: errors when reloading auto generated config (#754) 2025-01-30 21:08:44 +10:00
dependabot[bot]
44d3c51bc7 [no ci] chore(deps): bump libraries/Protobufs from b46090a to 157162d (#753)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-01-30 11:22:36 +10:00
Joakim
f72e6d5daf feat: add ReplicateConVar (#751) 2025-01-27 22:10:14 +00:00
samyyc
c8bccb07e0 Remove the characters limit for CenterHtmlMenu (#747) 2025-01-23 13:06:06 +00:00
qstage
2c0640700a fix: ArgumentOutOfRangeException when calling GetArgTargetResult (#745) 2025-01-23 22:53:51 +10:00
Ian Lucas
0f71e1aebe feat: handle quotes for FakeConVar<string> (#743) 2025-01-20 12:09:44 +10:00
dependabot[bot]
ac38ec249b chore(deps): bump libraries/hl2sdk-cs2 from a658a0f to a26ca82 (#739)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-01-15 23:45:00 +10:00
Roflmuffin
cff24f4321 Revert "Make NetworkedVector support Vector and QAngle (#728)"
This reverts commit bd1105d752.
2025-01-14 00:18:56 +10:00
Michael Wilson
f05cc5e043 fix: NetworkedVector throwing error 2025-01-09 11:07:40 +10:00
Yarukon
bd1105d752 Make NetworkedVector support Vector and QAngle (#728) 2025-01-09 09:14:56 +10:00
Michael Wilson
9b4ee727c7 Fix RemoveMapChangeTimers (#720) 2024-12-24 23:30:44 +10:00
Michael Wilson
38d248defe [no ci] chore: use ninja in linux build (#722) 2024-12-24 16:14:59 +10:00
Michael Wilson
6b4306948b Update Schema to Latest (#721) 2024-12-24 16:01:10 +10:00
Michael Wilson
3fee00e8c4 [no ci] Update getting-started.md 2024-12-24 16:00:36 +10:00
Michael Wilson
d22af142cb [no ci] chore: upgrade to cxx20 (#719) 2024-12-24 15:34:12 +10:00
dependabot[bot]
c1176a3192 [no ci] chore(deps): bump libraries/hl2sdk-cs2 from 14e77af to a658a0f (#718)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-24 15:32:38 +10:00
dependabot[bot]
3c321be5a0 [no ci] chore(deps): bump libraries/Protobufs from 76e070d to b46090a (#717)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-24 15:32:20 +10:00
Michael Wilson
466da1b193 chore: back to using hl2sdk 2024-12-20 23:34:21 +00:00
Michael Wilson
ba860a92d2 fix: temporary patch hl2sdk entity listeners 2024-12-20 12:37:50 +00:00
Ian Lucas
461fc0ea67 Fix GiveNamedItem and CanAcquire signatures (#713) 2024-12-20 22:12:14 +10:00
Michael Wilson
6349c11d07 fix: revert base entity teleport changes, add warning to player controller (#688) 2024-11-27 21:25:12 +10:00
ZoNiCaL
b2046b21c4 [no ci] Shuffle player documentation, add to game event documentation (#685) 2024-11-25 10:48:25 +10:00
Michael Wilson
3c6be481c5 [no ci] Update publish-docs.yml 2024-11-25 10:48:05 +10:00
Michael Wilson
0a6fe0946d [no ci] Allow manual publish-docs.yml 2024-11-25 10:47:01 +10:00
schwarper
79297511e3 Added hitgroup to CTakeDamageInfo (#665)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-11-23 10:55:22 +00:00
schwarper
c6d3988902 CBaseEntity player teleport adjustment update (#661)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-11-23 10:07:12 +00:00
schwarper
8a063f4fb6 Added PluginConfigExtensions (#675) 2024-11-23 20:00:39 +10:00
Gold KingZ
6cf124bfb6 System.ArgumentException: Player with slot X not found (#667) 2024-11-13 08:08:47 +00:00
schwarper
1f904a52a7 Added TargetType.PlayerAim (#639)
Co-authored-by: KillStr3aK <KillStr3aK@users.noreply.github.com>
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-11-06 06:52:28 +00:00
Nexd
32c99b2e49 Implemented entity transmit feature (#608)
Co-authored-by: KillStr3aK <KillStr3aK@users.noreply.github.com>
2024-11-06 16:46:03 +10:00
Nexd
5c9d38b2b0 fix: only close the menu if it has exit button (#622)
Co-authored-by: KillStr3aK <KillStr3aK@users.noreply.github.com>
2024-10-20 23:41:25 +00:00
Nexd
b54f5c3dee fix: gamedata update (#631)
Co-authored-by: KillStr3aK <KillStr3aK@users.noreply.github.com>
2024-10-21 09:35:38 +10:00
schwarper
761380dff6 CCSPlayer_ItemServices_CanAcquire and GetCSWeaponDataFromKey signatures update (#636) 2024-10-19 10:07:07 +10:00
Interesting
71ae253e5e Add GetGameframeTime to NativeAPI (#627)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-10-17 03:32:10 +00:00
schwarper
c2f212df51 Add GetCSWeaponDataFromKey and CCSPlayer_ItemServices_CanAcquire (#628) 2024-10-17 00:44:32 +00:00
Ian Lucas
ad7f7bd365 fix: InvalidOperationException when removing command in its callback (#626) 2024-10-13 09:29:06 +10:00
Ian Lucas
a0fcb7817e fix: remove command to use command manager (#579)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-10-11 02:15:01 +00:00
Nexd
cdb7a6ed17 New NetworkDisconnectionReason values (#621)
Co-authored-by: KillStr3aK <KillStr3aK@users.noreply.github.com>
2024-10-11 12:10:11 +10:00
dependabot[bot]
38e29531c3 [no ci] chore(deps): bump libraries/hl2sdk-cs2 from 9be8cba to fc4b98f (#620)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-10 01:43:51 +00:00
dependabot[bot]
5f95969980 [no ci] chore(deps): bump libraries/Protobufs from 3ea793c to 76e070d (#619)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-10 11:32:36 +10:00
dependabot[bot]
42dd270b78 chore(deps): bump libraries/Protobufs from 686a062 to 3ea793c (#607)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-06 14:17:45 +10:00
dependabot[bot]
b807c3eda8 chore(deps): bump libraries/hl2sdk-cs2 from 1f1d158 to 9be8cba (#606)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-06 14:06:59 +10:00
Michael Wilson
3ede4c366c [no ci] Update dependabot.yaml 2024-10-06 14:02:28 +10:00
number201724
49cc91e373 fix CreateEvent leak (#604) 2024-10-06 14:01:18 +10:00
StefanX
8a795de9fa fix: CCSPlayerPawnBase_PostThink signature (#601) 2024-10-06 13:55:05 +10:00
dependabot[bot]
e36d2e07e4 chore(deps): bump libraries/hl2sdk-cs2 from 3c7b355 to 1f1d158 (#600)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-05 10:36:21 +10:00
Ivan Kardapoltsev
cdd2a8275e Fix crash after map change (#593)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-10-05 00:54:27 +10:00
Michael Wilson
2b31f519eb Update Schema for Armory Update (#592) 2024-10-05 00:47:33 +10:00
Nexd
2c7f896189 fix: armory update broken signatures and offsets (#584)
Co-authored-by: KillStr3aK <KillStr3aK@users.noreply.github.com>
2024-10-04 14:35:55 +00:00
dependabot[bot]
5a354a25e3 chore(deps): bump libraries/hl2sdk-cs2 from 40a9bb9 to 3c7b355 (#594)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-04 23:35:15 +10:00
dependabot[bot]
74ce0d295a chore(deps): bump libraries/hl2sdk-cs2 from f21e0c9 to 40a9bb9 (#586)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-10-04 09:46:21 +10:00
Yarukon
9c8f25f721 Fix calling Send using UM instance from UM hook (#578) 2024-09-22 15:37:26 +10:00
Markus
4b1a2c427e CoreConfig: Prevent "Error invoking callback" if core.json not found (#576)
Thanks @markus-wa
2024-09-19 01:26:55 +00:00
roflmuffin
8f59fd5b97 fix: prevent early global cleanup when inside invoke
closes #501
2024-09-02 16:34:22 +10:00
Michael Wilson
cbeac50e4a [no ci] Update README 2024-09-02 14:43:52 +10:00
Michael Wilson
eba7d9c313 [no ci] Update README.md 2024-09-02 14:43:11 +10:00
dependabot[bot]
23828153eb chore(deps): bump libraries/hl2sdk-cs2 from 0b862d7 to f21e0c9 (#560)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-08-29 02:04:34 +00:00
Roflmuffin
0e3698b370 feat: add player.Disconnect(reason) method 2024-08-29 11:42:57 +10:00
Michael Wilson
bb38b1cb1a Cleanup Protobuf Generation (#562) 2024-08-29 11:23:50 +10:00
Michael Wilson
10f472ec85 Implement Usermessages (#435) 2024-08-26 17:18:40 +10:00
dependabot[bot]
28ce183cdc chore(deps): bump libraries/hl2sdk-cs2 from c57d5ab to 0b862d7 (#550)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-19 04:48:07 +00:00
Michael Wilson
dddf24d0f3 feat: add localizer extension methods for player language 2024-08-19 12:10:12 +10:00
Yarukon
fce68cb160 Update SetStateChanged parameters (#541)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-08-19 01:58:25 +00:00
Ian Lucas
a82faeb5c8 Fix CBasePlayerController_SetPawn signature (#547) 2024-08-19 11:52:30 +10:00
dependabot[bot]
ce3ff449b9 chore(deps): bump libraries/hl2sdk-cs2 from a5d9f80 to c57d5ab (#542)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-08-10 06:23:36 +00:00
Michael Wilson
aa40d81a86 fix: update gamedata json for update 2024-08-10 16:18:42 +10:00
Michael Wilson
5644921873 Improve plugin unloading consistency (#532) 2024-07-26 22:37:54 +10:00
Michael Wilson
3860ca1662 fix: update CNetworkQuantizedFloat to resolve to float
closes #482
2024-07-26 18:28:37 +10:00
Michael Wilson
b79fd19c85 chore: update schema (#531) 2024-07-26 18:11:57 +10:00
dependabot[bot]
b7ea025b03 chore(deps): bump libraries/hl2sdk-cs2 from 4b31db7 to a5d9f80 (#522)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-26 18:08:21 +10:00
Michael Wilson
5ac173df51 [no ci] chore: add actionlint (#530) 2024-07-26 16:11:46 +10:00
Michael Wilson
c82a58f5ab feat: update game events (adds bullet_damage event) 2024-07-26 14:47:18 +10:00
Yarukon
1806919559 Fix function hooking on windows (#529) 2024-07-24 16:26:41 +10:00
Levin V
f8451c2818 Update gamedata.json (#521) 2024-07-03 23:37:08 +10:00
Yarukon
a87bd25b48 Improve Teleport Function (#513) 2024-06-27 23:51:57 +10:00
Michael Wilson
9c5468e5ba fix: bad vector natives (closes #512) 2024-06-27 03:58:21 +00:00
Michael Wilson
f826be664f [no ci] Add Linux Dev Container (#448) 2024-06-27 13:52:14 +10:00
Michael Wilson
7f5103d9ee Add Basic VPROF Budgets, Add Con Command Unlocker to Core (#505) 2024-06-17 21:08:05 +10:00
dependabot[bot]
877b7c5a4a chore(deps): bump libraries/hl2sdk-cs2 from 4202f1c to 4b31db7 (#496)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-06-17 08:35:54 +00:00
WidovV
24363d6352 [no ci] Change example command prefix to follow "best practice" (#503) 2024-06-17 18:25:13 +10:00
Yarukon
2eaf7c2d8c Fix AddResource offset for Linux (#479) 2024-06-13 22:27:34 +10:00
dependabot[bot]
8b486ecf7e chore(deps): bump libraries/hl2sdk-cs2 from 739c88f to 4202f1c (#494)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Roflmuffin <shortguy014@gmail.com>
2024-06-13 22:26:50 +10:00
StefanX
54cc93e0f8 fix: CBasePlayerController_SetPawn signature (#493) 2024-06-13 21:55:33 +10:00
Michael Wilson
a695eec4fa Revert "fix: improve error handling if globals are accessed before ready"
This reverts commit e207be2fbf.
2024-05-31 20:06:26 +10:00
Roflmuffin
e207be2fbf fix: improve error handling if globals are accessed before ready 2024-05-31 12:51:48 +10:00
Nukoooo
eea64519a6 Update `GiveNamedItem` signature for linux (#470) 2024-05-31 08:49:03 +10:00
Ian Lucas
13ec19e412 Update GiveNamedItem signature on Linux (#467) 2024-05-30 14:19:50 +10:00
Ian Lucas
3240a5e582 Update GiveNamedItem signature on Linux (#463) 2024-05-26 10:29:41 +10:00
Michael Wilson
cafc4e237f Initial update after 2024-05-23 CS2 update (#461) 2024-05-25 18:50:09 +10:00
dependabot[bot]
02d5191e74 chore(deps): bump libraries/hl2sdk-cs2 from f7ed6a0 to 36dd2db (#452)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: roflmuffin <shortguy014@gmail.com>
2024-05-10 11:50:41 +10:00
dependabot[bot]
aec696abc0 chore(deps): bump libraries/hl2sdk-cs2 from 9ddef9a to f7ed6a0 (#451)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-09 00:43:54 +10:00
Roflmuffin
c01aeec14b [no ci] chore: fix dependabot prefix 2024-05-08 20:13:19 +10:00
dependabot[bot]
41e7bee85a chore(deps): update hl2sdk: bump libraries/metamod-source from e857fbe to 607301a (#450)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-08 20:10:01 +10:00
Roflmuffin
9834271956 [no ci] chore: add metamod source dependabot config 2024-05-08 19:59:53 +10:00
Michael Wilson
fb5967d102 Back to C++17 (#447) 2024-05-08 16:34:51 +10:00
dependabot[bot]
928bc3f74d chore(deps): update hl2sdk: bump libraries/hl2sdk-cs2 from 3fc8d0f to 9ddef9a (#446)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-08 15:27:48 +10:00
Roflmuffin
6a7d7dba4f [no ci] feat: add hl2sdk-cs2 dependabot 2024-05-08 14:30:51 +10:00
Roflmuffin
11e5e9972d fix: concommand crash when no description 2024-05-01 14:44:57 +10:00
Michael Wilson
9a221b4ebb chore: bump hl2sdk after update (#434) 2024-05-01 09:38:54 +10:00
Yarukon
e270bdfd44 AcceptInput changes (#433) 2024-05-01 01:12:25 +10:00
Michael Wilson
f591fe58d0 fix: add memoverride on windows, use correct MT flag (#431) 2024-04-30 17:40:25 +10:00
Roflmuffin
052cb4e14e chore: improve ccsplayercontroller helpers validity checks 2024-04-30 11:39:49 +10:00
Michael Wilson
bc3bec4aa8 feat: improve docs and add more null checking for handle accesses (#417) 2024-04-30 11:20:47 +10:00
Roflmuffin
20bab7f4a8 feat: add PrintToCenterAlert player helper 2024-04-29 20:14:58 +10:00
Roflmuffin
c7eac71109 feat: add generic math operators to Vector 2024-04-29 00:56:00 +10:00
Roflmuffin
e3d2370e2e chore: use IDA style sigs for gamedata 2024-04-28 13:57:07 +10:00
Roflmuffin
142242744c chore: update give named item sig for linux 2024-04-28 09:44:51 +10:00
Nukoooo
0eebffd860 Copy bytes of a module to prevent signature scanning failures and some minor changes (#414)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-04-27 10:44:42 +00:00
Michael Wilson
25ca5dbe0c chore: use offsets for give named item (#427) 2024-04-27 19:56:07 +10:00
Nexd
7cae4be96d Fix: new game update broke signatures (#425)
Co-authored-by: KillStr3aK <KillStr3aK@users.noreply.github.com>
Co-authored-by: Roflmuffin <shortguy014@gmail.com>
2024-04-26 16:29:38 +10:00
Nexd
83bc1a95fb Make shared type loader less strict (#424)
Co-authored-by: KillStr3aK <KillStr3aK@users.noreply.github.com>
2024-04-26 10:26:39 +10:00
roflmuffin
71c694b52e [no ci] add windows install script 2024-04-14 13:25:43 +10:00
Michael Wilson
a452d79ba3 [no ci] feat: add install script 2024-04-14 12:58:24 +10:00
Nukoooo
dfc9859806 Make signature support IDA/x64Dbg style (#407)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-04-13 12:11:26 +10:00
Nukoooo
f99f58402a Add mising `GameData.GetSignature to NetworkStateChangedFunc` (#415) 2024-04-13 11:00:51 +10:00
Michael Wilson
6317559bd2 [no ci] Update .clang-format & add formatting tool install scripts (#410) 2024-04-12 12:36:39 +10:00
Michael Wilson
ad6e1ca2e2 chore: bump hl2sdk (#408) 2024-04-11 18:15:50 +10:00
Michael Wilson
2564ef9f39 fix: fix startup server listener 2024-04-11 16:14:16 +10:00
Michael Wilson
83a341d3cf feat: expose TargetTypeMap 2024-04-11 15:34:01 +10:00
Michael Wilson
534fc42444 fix: bad commit 2024-04-11 14:26:21 +10:00
Michael Wilson
41355d05fa docs: add more comments to base plugin 2024-04-11 14:20:24 +10:00
luxury fabka
d9da15be83 Add teleport overloads (#399)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-04-11 00:48:55 +00:00
B3none
75e2f6e8aa [no ci] Rename ACKNOWLEDGEMENTS to ACKNOWLEDGEMENTS.md (#401) 2024-04-10 16:34:15 +10:00
Michael Wilson
37b34e1d41 [no ci] add basic contributing guide 2024-04-08 10:02:18 +10:00
WidovV
5ce04649fd Add CenterHtmlMenu button colors (#398) 2024-04-06 21:43:38 +10:00
Michael Wilson
7b7202fe8a [no ci] Update README.md 2024-04-05 11:54:53 +10:00
Michael Wilson
cadb817ed2 fix: mark center html menu constructor as obsolete, throw error (#396) 2024-04-04 09:33:22 +10:00
luxury fabka
211516cce5 added Open method to each menu type (#385)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
Co-authored-by: Roflmuffin <shortguy014@gmail.com>
2024-04-01 18:04:12 +10:00
Roflmuffin
ab211a42e6 [skip ci] chore: update ApiCompat to v202, disable suppression file 2024-03-26 12:46:42 +10:00
Roflmuffin
696ecadee4 fix: bad vector math 2024-03-26 12:16:53 +10:00
Roflmuffin
e4d598dba8 fix: main version number 2024-03-25 17:15:31 +10:00
Michael Wilson
5c67d88844 feat: improve version stamping (#389) 2024-03-25 17:11:16 +10:00
Michael Wilson
9d8b6beae6 .NET8 Upgrade (#261)
Co-authored-by: Frederik St-Onge <frederik.stonge@gmail.com>
Co-authored-by: B3none <24966460+B3none@users.noreply.github.com>
2024-03-25 14:16:32 +10:00
ipsvn
39604b7ad7 Fix backwards compatibility in DynamicHook (#388) 2024-03-22 23:04:09 +10:00
luxury fabka
1b1f1d04dd minor menu changes (#373)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
Co-authored-by: Roflmuffin <shortguy014@gmail.com>
2024-03-18 05:00:31 +00:00
Ian Lucas
dbc348c1bf Add RemoveAll method to NetworkedVector class (#380) 2024-03-18 14:56:29 +10:00
Michael Wilson
d295589c44 fix: update collision groups (#376) 2024-03-13 16:10:42 +10:00
Michael Wilson
16767fd494 feat: add Server.RunOnTick method which allows tick scheduling (#374) 2024-03-11 23:08:54 +10:00
roflmuffin
36a97bfffd fix: disable autoload plugin but allow shared library loading 2024-03-09 15:29:45 +10:00
roflmuffin
178f7472c6 feat: add PluginAutoLoadEnabled config option
closes #370
2024-03-09 14:29:43 +10:00
luxury fabka
cba5144bbf remove unused arguments (#334)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-03-08 05:08:33 +00:00
roflmuffin
0de951cb6f fix: allows game events to be freed, frees event in print to center html
closes #346
2024-03-08 10:39:59 +10:00
Michael Wilson
c3d44a87bc feat: use concurrent queue for next frame & world update tasks (#365) 2024-03-06 21:08:22 +10:00
B3none
bd3c0c76e3 [no ci] Update minimum api version for shared api docs (#364) 2024-03-06 15:42:34 +10:00
Yarukon
656c0e3a84 Fix TerminateRound params (#363) 2024-03-04 10:59:02 +00:00
Michael Wilson
40c842149c fix: add error handling to OnAllPluginsLoaded 2024-03-04 17:21:50 +10:00
roflmuffin
64d1c0a9f4 chore: remove erroneous log 2024-03-04 16:56:49 +10:00
roflmuffin
a6de51c444 fix: use concurrent dictionary for function reference 2024-03-04 13:41:18 +10:00
roflmuffin
2535ac0575 feat: add assembly name lazy loading of shared libraries 2024-03-04 12:15:37 +10:00
Michael Wilson
bc61323315 chore: migrate to protobufs submodule (#362) 2024-03-04 10:48:52 +10:00
roflmuffin
241817b7f2 feat: update game events dump from Feb 14 update 2024-03-04 10:34:58 +10:00
BuSheeZy
fbcdce34fc fix: allow empty overrides to skip checks (#357)
Co-authored-by: Michael Wilson <roflmuffin@users.noreply.github.com>
2024-03-04 00:13:17 +00:00
Michael Wilson
daf0d25f36 Shared Plugin APIs/Capabilities (#253)
Co-authored-by: B3none <ablackham2000@gmail.com>
Co-authored-by: B3none <24966460+B3none@users.noreply.github.com>
2024-03-04 09:45:34 +10:00
Yarukon
12485be29f Adding the proper way to do resource precache (#358) 2024-03-02 15:10:37 +10:00
2023 changed files with 416688 additions and 158370 deletions

View File

@@ -1,21 +1,72 @@
BasedOnStyle: LLVM
# Spacing
IndentWidth: 4
ColumnLimit: 100
UseTab: Never
ColumnLimit: 140
# Line Endings
LineEnding: LF
InsertNewlineAtEOF: true
DerivePointerAlignment: false
PointerAlignment: Left
AlignAfterOpenBracket: Align
KeepEmptyLinesAtTheStartOfBlocks: false
SortIncludes: false
SpaceBeforeParens: ControlStatements
AllowAllArgumentsOnNextLine: true
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
IndentCaseLabels: true
# Line Breaks
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterStruct: true
AfterControlStatement: Always
AfterEnum: true
AfterUnion: true
AfterNamespace: false
AfterFunction: true
AfterNamespace: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
PointerAlignment: Left
SortIncludes: Never
IncludeBlocks: Regroup
IncludeCategories:
# External headers in <> with extension or /
- Regex: '<[-\w\/-_]+[\.\/][-\w\/-_]+>'
Priority: 2
# Standard headers in <>
- Regex: '<[-\w\/-_]+>'
Priority: 3
# Local headers in ""
- Regex: '"[-\w\/-_]*"'
Priority: 4
ReflowComments: true
CompactNamespaces: false
Cpp11BracedListStyle: false
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignEscapedNewlines: Left
AlignTrailingComments: Never
AllowShortBlocksOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: OnlyFirstIf
AllowShortLambdasOnASingleLine: Empty
BinPackArguments: true
BinPackParameters: false
LambdaBodyIndentation: OuterScope

View File

@@ -0,0 +1,21 @@
{
"name": "SteamRT Sniper SDK",
"image": "registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest",
"updateContentCommand": "git submodule update --init --recursive",
"postCreateCommand": "cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -G Ninja && cmake --build build -j$(nproc)",
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csdevkit",
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"GitHub.copilot",
"jeff-hykin.better-cpp-syntax"
]
}
},
"features": {
"ghcr.io/devcontainers/features/dotnet": "8.0",
"ghcr.io/devcontainers/features/node": "lts"
}
}

14
.editorconfig Normal file
View File

@@ -0,0 +1,14 @@
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
max_line_length = 140
trim_trailing_whitespace = true
[{*.json,*.yaml,*.yml}]
indent_size = 2

13
.github/dependabot.yaml vendored Normal file
View File

@@ -0,0 +1,13 @@
version: 2
updates:
# Update the submodule in libraries/hl2sdk-cs2 every day
- package-ecosystem: "gitsubmodule"
directory: "/"
allow:
- dependency-name: "libraries/hl2sdk-cs2"
- dependency-name: "libraries/metamod-source"
- dependency-name: "libraries/Protobufs"
schedule:
interval: "daily"
commit-message:
prefix: "chore(deps)"

21
.github/workflows/actionlint.yaml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: actionlint
on:
workflow_dispatch:
pull_request:
branches: ["main"]
paths:
- ".github/actions/**"
- ".github/workflows/**"
jobs:
actionlint:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v4
- name: actionlint
uses: reviewdog/action-actionlint@v1
with:
reporter: github-pr-review
fail_on_error: true

270
.github/workflows/build-and-publish.yml vendored Normal file
View File

@@ -0,0 +1,270 @@
name: Build & Publish
env:
BUILD_TYPE: Release
# Remove default permissions of GITHUB_TOKEN for security
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
permissions: {}
on:
push:
paths-ignore:
- "docfx/**"
branches: ["main", "release/*"]
tags:
- "v*"
pull_request:
branches: ["main"]
jobs:
setup:
runs-on: ubuntu-latest
outputs:
gitversion_semver: ${{ steps.gitversion.outputs.semVer }}
gitversion_fullsemver: ${{ steps.gitversion.outputs.fullSemVer }}
gitversion_assemblysemver: ${{ steps.gitversion.outputs.assemblySemVer }}
gitversion_informationalversion: ${{ steps.gitversion.outputs.informationalVersion }}
steps:
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v1
with:
versionSpec: 6.0.x
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Execute GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v1
with:
useConfigFile: true
build_windows:
needs: setup
runs-on: windows-latest
steps:
- name: Prepare env
shell: bash
run: |
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
echo "SEMVER=${{ needs.setup.outputs.gitversion_semver }}" >> $GITHUB_ENV
- name: Visual Studio environment
shell: cmd
run: |
:: See https://github.com/microsoft/vswhere/wiki/Find-VC
for /f "usebackq delims=*" %%i in (`vswhere -latest -property installationPath`) do (
call "%%i"\Common7\Tools\vsdevcmd.bat -arch=x64 -host_arch=x64
)
:: Loop over all environment variables and make them global.
for /f "delims== tokens=1,2" %%a in ('set') do (
echo>>"%GITHUB_ENV%" %%a=%%b
)
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Build
run: |
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ..
cmake --build . --config ${{env.BUILD_TYPE}} -- /m:16
- name: Clean build directory
run: |
mkdir -p build/addons/counterstrikesharp/bin/win64
mv build/${{env.BUILD_TYPE}}/*.dll build/addons/counterstrikesharp/bin/win64
mkdir build/output/
mv build/addons build/output
- uses: actions/upload-artifact@v4
with:
name: counterstrikesharp-windows-${{ needs.setup.outputs.gitversion_semver }}
path: build/output/
build_linux:
needs: setup
runs-on: ubuntu-latest
# Could not figure out how to run in a container only on some matrix paths, so I've split it out into its own build.
container:
image: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest
steps:
- name: Prepare env
shell: bash
run: |
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
echo "SEMVER=${{ needs.setup.outputs.gitversion_semver }}" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Build
run: |
mkdir -p build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ..
cmake --build . --config ${{env.BUILD_TYPE}} -- -j16
- name: Clean build directory
run: |
mkdir build/output/
mv build/addons build/output
- uses: actions/upload-artifact@v4
with:
name: counterstrikesharp-linux-${{ needs.setup.outputs.gitversion_semver }}
path: build/output/
build_managed:
needs: setup
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
# We don't need expensive submodules for the managed side.
- uses: actions/checkout@v4
- name: Build runtime v${{ needs.setup.outputs.gitversion_semver }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Install dependencies
run: dotnet restore managed/CounterStrikeSharp.sln
- name: Run tests
run: dotnet test --logger trx --results-directory "TestResults-${{ needs.setup.outputs.gitversion_semver }}" managed/CounterStrikeSharp.API.Tests/CounterStrikeSharp.API.Tests.csproj
- name: Upload dotnet test results
uses: actions/upload-artifact@v4
with:
name: test-results-${{ needs.setup.outputs.gitversion_semver }}
path: TestResults-${{ needs.setup.outputs.gitversion_semver }}
if: ${{ always() }}
- name: Publish artifacts
run: |
dotnet publish -c Release \
/p:Version=${{ needs.setup.outputs.gitversion_semver }} \
/p:AssemblyVersion=${{ needs.setup.outputs.gitversion_assemblySemver }} \
/p:InformationalVersion=${{ needs.setup.outputs.gitversion_informationalversion }} \
managed/CounterStrikeSharp.API
dotnet pack -c Release \
/p:Version=${{ needs.setup.outputs.gitversion_semver }} \
/p:AssemblyVersion=${{ needs.setup.outputs.gitversion_assemblySemver }} \
/p:InformationalVersion=${{ needs.setup.outputs.gitversion_informationalversion }} \
managed/CounterStrikeSharp.API
- uses: actions/upload-artifact@v4
with:
name: counterstrikesharp-api-${{ needs.setup.outputs.gitversion_semver }}
path: managed/CounterStrikeSharp.API/bin/Release
publish:
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.repository == 'roflmuffin/CounterStrikeSharp' }}
permissions:
contents: write
needs: ["setup", "build_linux", "build_windows", "build_managed"]
runs-on: ubuntu-latest
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: counterstrikesharp-windows-${{ needs.setup.outputs.gitversion_semver }}
path: build/windows
- uses: actions/download-artifact@v4
with:
name: counterstrikesharp-linux-${{ needs.setup.outputs.gitversion_semver }}
path: build/linux
- uses: actions/download-artifact@v4
with:
name: counterstrikesharp-api-${{ needs.setup.outputs.gitversion_semver }}
path: build/api
# TODO: This stuff should really be in a matrix
- name: Add API to Artifacts
run: |
mkdir -p build/linux/addons/counterstrikesharp/api
mkdir -p build/windows/addons/counterstrikesharp/api
cp -r build/api/net8.0/publish/* build/linux/addons/counterstrikesharp/api
cp -r build/api/net8.0/publish/* build/windows/addons/counterstrikesharp/api
- name: Zip Builds
run: |
(cd build/linux && zip -qq -r ../../counterstrikesharp-linux-${{ needs.setup.outputs.gitversion_semver }}.zip *)
(cd build/windows && zip -qq -r ../../counterstrikesharp-windows-${{ needs.setup.outputs.gitversion_semver }}.zip *)
- name: Add dotnet runtime
run: |
mkdir -p build/linux/addons/counterstrikesharp/dotnet
curl -s -L https://download.visualstudio.microsoft.com/download/pr/c1371dc2-eed2-47be-9af3-ae060dbe3c7d/bd509e0a87629764ed47608466d183e6/aspnetcore-runtime-8.0.3-linux-x64.tar.gz \
| tar xvz -C build/linux/addons/counterstrikesharp/dotnet
mkdir -p build/windows/addons/counterstrikesharp/dotnet
curl -s -L https://download.visualstudio.microsoft.com/download/pr/086d1dd6-57a5-437a-a1ef-549cf702fb48/dd4a8fe6c53a1016a414d6f2925c1323/aspnetcore-runtime-8.0.3-win-x64.zip -o dotnet.zip
unzip -qq dotnet.zip -d build/windows/addons/counterstrikesharp/dotnet
- name: Zip Builds
run: |
(cd build/linux && zip -qq -r ../../counterstrikesharp-with-runtime-linux-${{ needs.setup.outputs.gitversion_semver }}.zip *)
(cd build/windows && zip -qq -r ../../counterstrikesharp-with-runtime-windows-${{ needs.setup.outputs.gitversion_semver }}.zip *)
- name: Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: cliff.toml
args: --current -s footer
- name: Release
id: release
uses: softprops/action-gh-release@v1
with:
append_body: true
body: |
${{ steps.git-cliff.outputs.content }}
Please refer to [CHANGELOG.md](https://github.com/roflmuffin/CounterStrikeSharp/blob/${{ github.ref_name }}/CHANGELOG.md) for details.
files: |
counterstrikesharp-windows-${{ needs.setup.outputs.gitversion_semver }}.zip
counterstrikesharp-with-runtime-windows-${{ needs.setup.outputs.gitversion_semver }}.zip
counterstrikesharp-linux-${{ needs.setup.outputs.gitversion_semver }}.zip
counterstrikesharp-with-runtime-linux-${{ needs.setup.outputs.gitversion_semver }}.zip
- name: Publish NuGet package
run: |
dotnet nuget push build/api/CounterStrikeSharp.API.${{ needs.setup.outputs.gitversion_semver }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push build/api/CounterStrikeSharp.API.${{ needs.setup.outputs.gitversion_semver }}.snupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Send Notification to Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@0.3.2
with:
args: |
A new release of CS# has been tagged [v${{ needs.setup.outputs.gitversion_semver }}](${{ steps.release.outputs.url }})
${{ steps.git-cliff.outputs.content }}
Please refer to [CHANGELOG.md](https://github.com/roflmuffin/CounterStrikeSharp/blob/${{ github.ref_name }}/CHANGELOG.md) for details.

View File

@@ -1,219 +0,0 @@
name: Build & Publish
on:
push:
paths-ignore:
- 'docfx/**'
branches: [ "main", "dev" ]
pull_request:
branches: [ "main", "dev" ]
env:
BUILD_TYPE: Release
jobs:
build_windows:
runs-on: windows-latest
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Visual Studio environment
shell: cmd
run: |
:: See https://github.com/microsoft/vswhere/wiki/Find-VC
for /f "usebackq delims=*" %%i in (`vswhere -latest -property installationPath`) do (
call "%%i"\Common7\Tools\vsdevcmd.bat -arch=x64 -host_arch=x64
)
:: Loop over all environment variables and make them global.
for /f "delims== tokens=1,2" %%a in ('set') do (
echo>>"%GITHUB_ENV%" %%a=%%b
)
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Build
run: |
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ..
cmake --build . --config ${{env.BUILD_TYPE}} -- /m:16
- name: Clean build directory
run: |
mkdir -p build/addons/counterstrikesharp/bin/win64
mv build/${{env.BUILD_TYPE}}/*.dll build/addons/counterstrikesharp/bin/win64
mkdir build/output/
mv build/addons build/output
- uses: actions/upload-artifact@v3
with:
name: counterstrikesharp-build-windows-${{ env.GITHUB_SHA_SHORT }}
path: build/output/
build_linux:
runs-on: ubuntu-latest
# Could not figure out how to run in a container only on some matrix paths, so I've split it out into its own build.
container:
image: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Build
run: |
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ..
cmake --build . --config ${{env.BUILD_TYPE}} -- -j16
- name: Clean build directory
run: |
mkdir build/output/
mv build/addons build/output
- uses: actions/upload-artifact@v3
with:
name: counterstrikesharp-build-linux-${{ env.GITHUB_SHA_SHORT }}
path: build/output/
build_managed:
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
buildnumber: ${{ steps.buildnumber.outputs.build_number }}
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Fallback build number
if: ${{ github.event_name == 'pull_request' || github.ref != 'refs/heads/main' }}
shell: bash
run: echo "BUILD_NUMBER=0" >> $GITHUB_ENV
# We don't need expensive submodules for the managed side.
- uses: actions/checkout@v3
- name: Generate build number
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
id: buildnumber
uses: onyxmueller/build-tag-number@v1
with:
token: ${{secrets.github_token}}
- name: Build runtime v${{ env.BUILD_NUMBER }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
- name: Install dependencies
run: dotnet restore managed/CounterStrikeSharp.sln
- name: Run tests
run: dotnet test --logger trx --results-directory "TestResults-${{ env.GITHUB_SHA_SHORT }}" managed/CounterStrikeSharp.API.Tests/CounterStrikeSharp.API.Tests.csproj
- name: Upload dotnet test results
uses: actions/upload-artifact@v3
with:
name: test-results-${{ env.GITHUB_SHA_SHORT }}
path: TestResults-${{ env.GITHUB_SHA_SHORT }}
if: ${{ always() }}
- name: Publish artifacts
run: |
dotnet publish -c Release /p:Version=1.0.${{ env.BUILD_NUMBER }} managed/CounterStrikeSharp.API
dotnet pack -c Release /p:Version=1.0.${{ env.BUILD_NUMBER }} managed/CounterStrikeSharp.API
- uses: actions/upload-artifact@v3
with:
name: counterstrikesharp-build-api-${{ env.GITHUB_SHA_SHORT }}
path: managed/CounterStrikeSharp.API/bin/Release
publish:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
permissions:
contents: write
needs: [ "build_linux", "build_windows", "build_managed" ]
runs-on: ubuntu-latest
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- uses: actions/download-artifact@v3
with:
name: counterstrikesharp-build-windows-${{ env.GITHUB_SHA_SHORT }}
path: build/windows
- uses: actions/download-artifact@v3
with:
name: counterstrikesharp-build-linux-${{ env.GITHUB_SHA_SHORT }}
path: build/linux
- uses: actions/download-artifact@v3
with:
name: counterstrikesharp-build-api-${{ env.GITHUB_SHA_SHORT }}
path: build/api
# TODO: This stuff should really be in a matrix
- name: Add API to Artifacts
run: |
mkdir -p build/linux/addons/counterstrikesharp/api
mkdir -p build/windows/addons/counterstrikesharp/api
cp -r build/api/net7.0/publish/* build/linux/addons/counterstrikesharp/api
cp -r build/api/net7.0/publish/* build/windows/addons/counterstrikesharp/api
- name: Zip Builds
run: |
(cd build/linux && zip -qq -r ../../counterstrikesharp-build-${{ needs.build_managed.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip *)
(cd build/windows && zip -qq -r ../../counterstrikesharp-build-${{ needs.build_managed.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip *)
- name: Add dotnet runtime
run: |
mkdir -p build/linux/addons/counterstrikesharp/dotnet
curl -s -L https://download.visualstudio.microsoft.com/download/pr/dc2c0a53-85a8-4fda-a283-fa28adb5fbe2/8ccade5bc400a5bb40cd9240f003b45c/aspnetcore-runtime-7.0.11-linux-x64.tar.gz \
| tar xvz -C build/linux/addons/counterstrikesharp/dotnet
mv build/linux/addons/counterstrikesharp/dotnet/shared/Microsoft.NETCore.App/7.0.11/* build/linux/addons/counterstrikesharp/dotnet/shared/Microsoft.NETCore.App/
mkdir -p build/windows/addons/counterstrikesharp/dotnet
curl -s -L https://download.visualstudio.microsoft.com/download/pr/a99861c8-2e00-4587-aaef-60366ca77307/a44ceec2c5d34165ae881600f52edc43/aspnetcore-runtime-7.0.11-win-x64.zip -o dotnet.zip
unzip -qq dotnet.zip -d build/windows/addons/counterstrikesharp/dotnet
- name: Zip Builds
run: |
(cd build/linux && zip -qq -r ../../counterstrikesharp-with-runtime-build-${{ needs.build_managed.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip *)
(cd build/windows && zip -qq -r ../../counterstrikesharp-with-runtime-build-${{ needs.build_managed.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip *)
- name: Release
id: release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.build_managed.outputs.buildnumber }}
files: |
counterstrikesharp-build-${{ needs.build_managed.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip
counterstrikesharp-with-runtime-build-${{ needs.build_managed.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip
counterstrikesharp-build-${{ needs.build_managed.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip
counterstrikesharp-with-runtime-build-${{ needs.build_managed.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip
- name: Publish NuGet package
run: |
dotnet nuget push build/api/CounterStrikeSharp.API.1.0.${{ needs.build_managed.outputs.buildnumber }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push build/api/CounterStrikeSharp.API.1.0.${{ needs.build_managed.outputs.buildnumber }}.snupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Send Notification to Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@0.3.2
with:
args: "A new release of CS# has been tagged (v${{ needs.build_managed.outputs.buildnumber }}) at ${{ steps.release.outputs.url }}"

25
.github/workflows/lint-code.yaml vendored Normal file
View File

@@ -0,0 +1,25 @@
name: Code format checks
on:
pull_request:
paths:
- '.github/workflows/**'
- 'src/**'
- '.clang-format'
push:
paths:
- '.github/workflows/**'
- 'src/**'
- '.clang-format'
jobs:
lint:
name: Lint code with clang-format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jidicula/clang-format-action@4726374d1aa3c6aecf132e5197e498979588ebc8
with:
clang-format-version: '20'
check-path: 'src'
exclude-regex: '(sdk|\.proto)'

View File

@@ -2,6 +2,7 @@ on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
@@ -22,10 +23,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Dotnet Setup
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
@@ -34,13 +35,13 @@ jobs:
- run: docfx docfx/docfx.json
- name: Setup Pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
path: "docfx/_site"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4

5
.gitignore vendored
View File

@@ -1,9 +1,9 @@
.ccls-cache/
.cmake/
cmake-build-debug*/
cmake-build-*/
.kdev4/
.vscode/
generated/
!**/protobuf/generated/
# configure_file auto generated.
configs/addons/metamod/counterstrikesharp.vdf
@@ -12,6 +12,7 @@ libraries/mono/
CMakeSettings.json
build-*/
build/
build_test/

6
.gitmodules vendored
View File

@@ -14,12 +14,12 @@
[submodule "libraries/dyncall"]
path = libraries/dyncall
url = https://github.com/LWJGL-CI/dyncall
[submodule "libraries/GameTracking-CS2"]
path = libraries/GameTracking-CS2
url = https://github.com/SteamDatabase/GameTracking-CS2
[submodule "libraries/DynoHook"]
path = libraries/DynoHook
url = https://github.com/qubka/DynoHook
[submodule "libraries/asmjit"]
path = libraries/asmjit
url = https://github.com/asmjit/asmjit
[submodule "libraries/Protobufs"]
path = libraries/Protobufs
url = https://github.com/SteamDatabase/Protobufs

4
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,4 @@
{
"editor.defaultFormatter": null,
"editor.formatOnSave": true
}

50
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,50 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "sync-linux",
"type": "shell",
"command": "lftp -c \"open -u $LINUX_SERVER_SFTP_USERNAME,$LINUX_SERVER_SFTP_PASSWORD $LINUX_SERVER_SFTP_HOST; mirror -R ${workspaceFolder}/build/addons /game/csgo/addons; mirror -R ${workspaceFolder}/managed/CounterStrikeSharp.API/bin/Release/net8.0/ /game/csgo/addons/counterstrikesharp/api; mirror -R ${workspaceFolder}/managed/CounterStrikeSharp.Tests.Native/bin/Debug/net8.0/ /game/csgo/addons/counterstrikesharp/plugins/NativeTestsPlugin\"",
"dependsOn": [
"build",
"build-api",
"build-test-plugin"
],
"problemMatcher": []
},
{
"label": "build",
"type": "shell",
"group": "build",
"command": "cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -G Ninja && cmake --build build -j$(nproc)",
},
{
"label": "build-api",
"type": "shell",
"group": "build",
"command": "dotnet build -c Release",
"options": {
"cwd": "${workspaceFolder}/managed/CounterStrikeSharp.API"
}
},
{
"label": "build-test-plugin",
"type": "shell",
"group": "build",
"command": "dotnet build -c Debug",
"options": {
"cwd": "${workspaceFolder}/managed/CounterStrikeSharp.Tests.Native"
}
},
{
"label": "generate-schema",
"type": "shell",
"command": "dotnet run -- ../CounterStrikeSharp.API/Core/Schema",
"options": {
"cwd": "${workspaceFolder}/managed/CounterStrikeSharp.SchemaGen"
}
}
]
}

1528
CHANGELOG.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -5,6 +5,13 @@ project(counterstrikesharp C CXX ASM)
include("makefiles/shared.cmake")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(FUNCHOOK_BUILD_TESTS OFF CACHE BOOL "Disable building tests for funchook." FORCE)
set(ZYDIS_BUILD_EXAMPLES OFF CACHE BOOL "Disable building examples for Zydis." FORCE)
set(ZYDIS_BUILD_TOOLS OFF CACHE BOOL "Disable building tools for Zydis." FORCE)
set(DYNOHOOK_BUILD_TESTS OFF CACHE BOOL "Disable building tests for funchook." FORCE)
add_subdirectory(libraries/spdlog)
add_subdirectory(libraries/dyncall)
add_subdirectory(libraries/funchook)
@@ -13,7 +20,10 @@ add_subdirectory(libraries/DynoHook)
set_property(TARGET dynohook PROPERTY DYNO_ARCH_X86 64)
set_property(TARGET funchook-static PROPERTY POSITION_INDEPENDENT_CODE ON)
SET(SOURCE_FILES
include("makefiles/protobuf.cmake")
set(SOURCE_FILES
libraries/hl2sdk-cs2/public/tier0/memoverride.cpp
src/mm_plugin.cpp
src/mm_plugin.h
libraries/hl2sdk-cs2/tier1/convar.cpp
@@ -38,6 +48,8 @@ SET(SOURCE_FILES
src/core/coreconfig.cpp
src/core/gameconfig.h
src/core/gameconfig.cpp
src/core/gameconfig_updater.h
src/core/gameconfig_updater.cpp
src/core/log.h
src/core/log.cpp
src/scripting/script_engine.h
@@ -49,10 +61,10 @@ SET(SOURCE_FILES
src/core/managers/event_manager.cpp
src/core/timer_system.h
src/core/timer_system.cpp
src/core/tick_scheduler.h
src/core/tick_scheduler.cpp
src/scripting/autonative.h
src/scripting/natives/natives_engine.cpp
src/core/engine_trace.h
src/core/engine_trace.cpp
src/scripting/natives/natives_callbacks.cpp
src/core/managers/player_manager.h
src/core/managers/player_manager.cpp
@@ -65,10 +77,10 @@ SET(SOURCE_FILES
src/core/managers/con_command_manager.cpp
src/core/managers/con_command_manager.h
src/scripting/natives/natives_commands.cpp
src/scripting/natives/natives_convars.cpp
src/core/memory_module.h
src/core/memory_module.cpp
src/core/cs2_sdk/interfaces/cgameresourceserviceserver.h
src/core/cs2_sdk/interfaces/cschemasystem.h
src/core/cs2_sdk/interfaces/cs2_interfaces.h
src/core/cs2_sdk/interfaces/cs2_interfaces.cpp
src/core/cs2_sdk/schema.h
@@ -79,6 +91,9 @@ SET(SOURCE_FILES
src/scripting/natives/natives_schema.cpp
src/scripting/natives/natives_entities.cpp
src/scripting/natives/natives_voice.cpp
src/scripting/natives/natives_metamod.cpp
src/scripting/natives/natives_cvariant.cpp
src/scripting/natives/natives_cutil.cpp
src/core/managers/entity_manager.cpp
src/core/managers/entity_manager.h
src/core/managers/chat_manager.cpp
@@ -86,72 +101,48 @@ SET(SOURCE_FILES
src/core/managers/server_manager.cpp
src/core/managers/server_manager.h
src/scripting/natives/natives_server.cpp
src/scripting/natives/natives_usermessages.cpp
libraries/nlohmann/json.hpp
src/core/managers/voice_manager.cpp
src/core/managers/voice_manager.h
src/core/managers/usermessage_manager.cpp
src/core/managers/usermessage_manager.h
src/scripting/natives/natives_dynamichooks.cpp
src/core/game_system.h
src/core/game_system.cpp
src/core/UserMessage.h
src/core/UserMessage.cpp
src/core/recipientfilters.h
)
if (LINUX)
# memoverride.cpp is not usable on CMake Windows, cuz CMake default link libraries (seems) always link ucrt.lib
set(SOURCE_FILES
${SOURCE_FILES}
libraries/hl2sdk-cs2/public/tier0/memoverride.cpp
)
endif()
set(PROTO_DIRS -I${CMAKE_CURRENT_SOURCE_DIR}/libraries/GameTracking-CS2/Protobufs)
file(GLOB PROTOS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/GameTracking-CS2/Protobufs/*.proto")
## Generate protobuf source & headers
if (LINUX)
set(PROTOC_EXECUTABLE ${CMAKE_CURRENT_SOURCE_DIR}/libraries/hl2sdk-cs2/devtools/bin/linux/protoc)
elseif(WIN32)
set(PROTOC_EXECUTABLE ${CMAKE_CURRENT_SOURCE_DIR}/libraries/hl2sdk-cs2/devtools/bin/protoc.exe)
endif()
add_custom_command(
OUTPUT protobuf_output_stamp
COMMAND ${PROTOC_EXECUTABLE} --proto_path=thirdparty/protobuf-3.21.8/src --proto_path=common --cpp_out=common common/network_connection.proto
COMMENT "Generating protobuf file"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libraries/hl2sdk-cs2
VERBATIM
)
SET(SOURCE_FILES ${SOURCE_FILES} protobuf_output_stamp)
# Sources
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${NATIVES_SOURCES} ${CONVERSIONS_SOURCES} ${CONVERSIONS_HEADERS})
target_include_directories(
${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/core/cs2_sdk
${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/core/cs2_sdk
)
if (LINUX)
if(LINUX)
include("makefiles/linux.base.cmake")
set_target_properties(${PROJECT_NAME} PROPERTIES
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/addons/counterstrikesharp/bin/linuxsteamrt64"
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/addons/counterstrikesharp/bin/linuxsteamrt64"
)
elseif(WIN32)
include("makefiles/windows.base.cmake")
set_target_properties(${PROJECT_NAME} PROPERTIES
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/addons/counterstrikesharp/bin/win64"
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/addons/counterstrikesharp/bin/win64"
)
endif()
# Libraries
target_link_libraries(${PROJECT_NAME} ${COUNTER_STRIKE_SHARP_LINK_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${COUNTER_STRIKE_SHARP_LINK_LIBRARIES} Protobufs)
add_custom_command(
TARGET ${PROJECT_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/configs ${CMAKE_BINARY_DIR}
)
TARGET ${PROJECT_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/configs ${CMAKE_BINARY_DIR}
)

103
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,103 @@
# Contributing to CounterStrikeSharp
We'd love for you to contribute to CS# to make it better than it is today!
Here are the guidelines we'd like you to follow:
- [Question or Problem?](#question)
- [Issues and Bugs](#issue)
- [Submission Guidelines](#submit)
- [Coding Format](#format)
## <a name="question"></a> Got a Question or Problem?
If you have questions about how to contribute to CounterStrikeSharp, please join our [Discord][discord] server.
## <a name="issue"></a> Found an Issue?
If you find a bug in the source code or a mistake in the documentation, you can help us by
submitting an issue to our [GitHub Repository][github]. Even better you can submit a Pull Request
with a fix.
**Please see the [Submission Guidelines](#submit) below.**
## <a name="submit"></a> Submission Guidelines
### Submitting an Issue
Before you submit your issue please search the archive, maybe your question was already answered.
If your issue appears to be a bug and hasn't been reported, open a new issue. Help us to maximize
the effort we can spend fixing issues and adding new features, by not reporting duplicate issues.
Providing the following information will increase the chances of your issue being dealt with
quickly:
* **Overview of the Issue** - if an error is being thrown a stack trace helps
* **Operating System** - is this a problem with a specific OS (Windows or Linux)?
* **Reproduce the Error** - provide details, if possible, on how to reproduce the error
* **Related Issues** - has a similar issue been reported before?
* **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be causing the problem (line of code or commit)
### Submitting a Pull Request
Before you submit your pull request consider the following guidelines:
* Search [GitHub](https://github.com/roflmuffin/CounterStrikeSharp/pulls) for an open or closed Pull Request
that relates to your submission. You don't want to duplicate effort.
* If adding a feature or enhancement, we recommend you first [start a discussion for
it](https://github.com/roflmuffin/CounterStrikeSharp/discussions) before submitting a Pull Request.
* [Fork](https://help.github.com/articles/fork-a-repo/) this repo.
* [Clone](https://help.github.com/articles/cloning-a-repository/) your copy.
```shell
git clone https://github.com/YOUR_USERNAME/CounterStrikeSharp.git
cd CounterStrikeSharp/
```
* After cloning, set a new remote [upstream](https://help.github.com/articles/configuring-a-remote-for-a-fork/) (this helps to keep your fork up to date)
```shell
git remote add upstream https://github.com/roflmuffin/CounterStrikeSharp.git
```
* Make your changes in a new git branch:
```shell
git checkout -b my-fix-branch master
```
* Create your patch and run appropriate tests.
* Commit your changes using a descriptive commit message that uses the imperative, present tense: "change" not "changed" nor "changes".
```shell
git commit -a
```
Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files.
* Push your branch to GitHub:
```shell
git push origin my-fix-branch
```
In GitHub, send a pull request to `CounterStrikeSharp:master`.
If we suggest changes, then:
* Make the required updates.
* Re-run CounterStrikeSharp to ensure everything is still working & tests are passing.
* Commit your changes to your branch (e.g. `my-fix-branch`).
* Push the changes to your GitHub repository (this will update your Pull Request).
If the PR gets too outdated we may ask you to rebase and force push to update the PR:
```shell
git fetch upstream
git rebase upstream/master
git push origin my-fix-branch -f
```
That's it! Thank you for your contribution!
#### After your pull request is merged
After your pull request is merged, you can safely delete your branch and pull the changes
from the main (upstream) repository.
[github]: https://github.com/roflmuffin/CounterStrikeSharp
[discord]: https://discord.gg/eAZU3guKWU

17
Dockerfile Normal file
View File

@@ -0,0 +1,17 @@
FROM registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest
WORKDIR /workspace
RUN apt update && apt install -y \
clang-16 \
cmake \
ninja-build \
git \
zlib1g-dev \
libssl-dev \
libprotobuf-dev \
protobuf-compiler \
pkg-config \
curl && \
ln -sf /usr/bin/clang-16 /usr/bin/clang && \
ln -sf /usr/bin/clang++-16 /usr/bin/clang++

1
GitVersion.yml Normal file
View File

@@ -0,0 +1 @@
workflow: GitHubFlow/v1

View File

@@ -1,15 +1,19 @@
# CounterStrikeSharp
<div align=right>Table of Contents ↗️</div>
CounterStrikeSharp is a server side modding framework for Counter-Strike: Global Offensive. This project attempts to implement a .NET Core scripting layer on top of a Metamod Source Plugin, allowing developers to create plugins that interact with the game server in a modern language (C#) to facilitate the creation of maintainable and testable code.
<h1 align=center><code>CounterStrikeSharp</code></h1>
<div align=center>
<a href=https://github.com/roflmuffin/CounterStrikeSharp/releases><img src=https://img.shields.io/github/v/release/roflmuffin/CounterStrikeSharp?style=flat-square&label=latest></a>
<a href=https://github.com/roflmuffin/CounterStrikeSharp/releases><img src=https://img.shields.io/github/release-date/roflmuffin/CounterStrikeSharp?style=flat-square&label=last%20release></a>
<a href=https://github.com/roflmuffin/CounterStrikeSharp/releases><img src=https://img.shields.io/github/downloads/roflmuffin/CounterStrikeSharp/total.svg?style=flat-square alt=downloads></a>
<a href=https://discord.gg/eAZU3guKWU><img src=https://img.shields.io/discord/1160907911501991946?logo=discord&cacheSeconds=3500&style=flat-square alt="chat on discord"></a>
</div>
<br>
CounterStrikeSharp is a server side modding framework for Counter-Strike 2. This project implements a .NET 8 scripting layer on top of a Metamod Source Plugin, allowing developers to create plugins that interact with the game server in a modern language (C#) to facilitate the creation of maintainable and testable code.
[Come and join our Discord](https://discord.gg/eAZU3guKWU)
## History
This project is an ongoing migration of a previous project (titled [VSP.NET](https://github.com/roflmuffin/vspdotnet)) whereby a scripting layer was added to a Valve Server Plugin for CSGO.
Due to the architectural changes of CS2, the plugin is being rebuilt on the ground up, to support Linux 64-bit, something which was previously impossible.
## Install
Download the latest build from [here](https://github.com/roflmuffin/CounterStrikeSharp/releases). (Download the with runtime version if this is your first time installing).
@@ -18,14 +22,12 @@ Detailed installation instructions can be found in the [docs](https://docs.cssha
## What works?
_(Note, these were features in the previous VSP.NET project, but have not been implemented yet in this project)_
These features are the core of the platform and work pretty well/have a low risk of causing issues.
- [x] Console Commands, Server Commands (e.g. css_mycommand)
- [x] Chat Commands with `!` and `/` prefixes (e.g. !mycommand)
- [ ] **(In Progress)** Console Variables
- [x] Game Event Handlers & Custom Events (e.g. player_death)
- [x] Fake Console Variables (commands which mimic ConVar behaviour as these have not been fully reverse engineered)
- [x] Game Event Handlers & Firing of Events (e.g. player_death)
- [x] Basic event value get/set (string, bool, int32, float)
- [x] Complex event values get/set (ehandle, pawn, player controller)
- [x] Game Tick Based Timers (e.g. repeating map timers)
@@ -34,7 +36,7 @@ These features are the core of the platform and work pretty well/have a low risk
- [x] Client Listeners (e.g. connect, disconnect, put in server)
- [x] OnMapStart
- [x] OnTick
- [x] Server Information (current map, game time, tick rate, model precaching)
- [x] Server Information (current map, game time)
- [x] Schema System Access (access player values like current weapon, money, location etc.)
## Links
@@ -81,7 +83,7 @@ public class HelloWorldPlugin : BasePlugin
return HookResult.Continue;
}
[ConsoleCommand("issue_warning", "Issue warning to player")]
[ConsoleCommand("css_issue_warning", "Issue warning to player")]
public void OnCommand(CCSPlayerController? player, CommandInfo command)
{
Logger.LogWarning("Player shouldn't be doing that");

85
cliff.toml Normal file
View File

@@ -0,0 +1,85 @@
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration
[remote.github]
owner = "roflmuffin"
repo = "CounterStrikeSharp"
# token = ""
[changelog]
# A Tera template to be rendered for each release in the changelog.
# See https://keats.github.io/tera/docs/#introduction
body = """
## What's Changed
{%- if version %} in {{ version }}{%- endif -%}
{% for commit in commits %}
* {{ commit.message | split(pat="\n") | first | trim }}\
{% if commit.remote.username and commit.remote.username != remote.github.owner %} by \
[@{{ commit.remote.username }}](https://github.com/{{ commit.remote.username }}) \
{%- endif -%}
{% if commit.remote.pr_number %} in \
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }})\
{%- endif %}
{%- if commit.id %} ([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url()}}/commit/{{ commit.id }})){%- endif -%}
{%- endfor -%}
{%- if github -%}
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
{% raw %}\n{% endraw -%}
## New Contributors
{%- endif %}\
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
* [@{{ contributor.username }}](https://github.com/{{ contributor.username }}) made their first contribution
{%- if contributor.pr_number %} in \
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
{%- endif %}
{%- endfor -%}
{%- endif -%}
{% if version %}
{% else -%}
{% raw %}\n{% endraw %}
{% endif %}
{%- macro remote_url() -%}
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}
"""
# Remove leading and trailing whitespaces from the changelog's body.
trim = true
# A Tera template to be rendered as the changelog's footer.
# See https://keats.github.io/tera/docs/#introduction
footer = """
<!-- generated by git-cliff -->
"""
# An array of regex based postprocessors to modify the changelog.
# Replace the placeholder `<REPO>` with a URL.
postprocessors = []
[git]
# Parse commits according to the conventional commits specification.
# See https://www.conventionalcommits.org
conventional_commits = false
# Exclude commits that do not match the conventional commits specification.
filter_unconventional = true
# Split commits on newlines, treating each line as an individual commit.
split_commits = false
# An array of regex based parsers to modify commit messages prior to further processing.
commit_preprocessors = [
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
{ pattern = '\[no ci\]', replace = "" }
]
commit_parsers = [
{ message = "^release:", skip = true }
]
# Exclude commits that are not matched by any commit parser.
filter_commits = false
# Order releases topologically instead of chronologically.
topo_order = false
# Order of commits in each group/release within the changelog.
# Allowed values: newest, oldest
sort_commits = "newest"
tag_pattern = "v[0-9]+\\.[0-9]+\\.[0-9]+"

View File

@@ -3,5 +3,11 @@
"SilentChatTrigger": [ "/" ],
"FollowCS2ServerGuidelines": true,
"PluginHotReloadEnabled": true,
"ServerLanguage": "en"
"PluginAutoLoadEnabled": true,
"PluginResolveNugetPackages": false,
"ServerLanguage": "en",
"UnlockConCommands": true,
"UnlockConVars": true,
"AutoUpdateEnabled": true,
"AutoUpdateURL": "http://gamedata.cssharp.dev"
}

View File

@@ -2,190 +2,222 @@
"UTIL_ClientPrintAll": {
"signatures": {
"library": "server",
"windows": "\\x48\\x89\\x5C\\x24\\x08\\x48\\x89\\x6C\\x24\\x10\\x48\\x89\\x74\\x24\\x18\\x57\\x48\\x81\\xEC\\x70\\x01\\x2A\\x2A\\x8B\\xE9",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x49\\x89\\xD7\\x41\\x56\\x49\\x89\\xF6\\x41\\x55\\x41\\x89\\xFD"
"windows": "48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 60 8B E9",
"linux": "55 48 89 E5 41 57 4D 89 CF 41 56 4D 89 C6 41 55 49 89 CD 41 54 49 89 D4 53 48 8D"
}
},
"ClientPrint": {
"signatures": {
"library": "server",
"windows": "\\x48\\x85\\xC9\\x0F\\x84\\x2A\\x2A\\x2A\\x2A\\x48\\x8B\\xC4\\x48\\x89\\x58\\x18",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x49\\x89\\xCF\\x41\\x56\\x49\\x89\\xD6\\x41\\x55\\x41\\x89\\xF5\\x41\\x54\\x4C\\x8D\\xA5\\xA0\\xFE\\xFF\\xFF"
"windows": "48 85 C9 0F 84 ? ? ? ? 48 89 5C 24 ? 55",
"linux": "55 48 8D 05 ? ? ? ? 48 89 E5 41 57 41 89 F7 31 F6"
}
},
"CCSPlayerController_SwitchTeam": {
"signatures": {
"library": "server",
"windows": "\\x40\\x56\\x57\\x48\\x81\\xEC\\x2A\\x2A\\x2A\\x2A\\x48\\x8B\\xF9\\x8B\\xF2\\x8B\\xCA",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x55\\x49\\x89\\xFD\\x89\\xF7"
"windows": "40 53 57 48 81 EC ? ? ? ? 48 8B D9 8B FA",
"linux": "55 48 89 E5 41 54 49 89 FC 89 F7"
}
},
"CCSPlayerController_ChangeTeam": {
"offsets": {
"windows": 93,
"linux": 92
"windows": 109,
"linux": 108
}
},
"CCSPlayerController_Respawn": {
"offsets": {
"windows": 244,
"linux": 246
"windows": 277,
"linux": 279
}
},
"CBasePlayerController_SetPawn": {
"signatures": {
"library": "server",
"windows": "\\x44\\x88\\x4C\\x24\\x20\\x55\\x57\\x41\\x54\\x41\\x56\\x41\\x57\\x48\\x8D\\x6C\\x24\\x2A\\x48\\x81\\xEC\\x2A",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x41\\x54\\x49\\x89\\xFC\\x53\\x48\\x89\\xF3\\x48\\x81\\xEC\\xC8\\x00\\x00\\x00"
"windows": "44 88 4C 24 ? 53 57",
"linux": "55 48 8D 87 ? ? ? ? 48 89 E5 41 57 41 56 41 89 CE 41 55 45 89 CD"
}
},
"CCSPlayerPawnBase_PostThink": {
"signatures": {
"library": "server",
"windows": "\\x48\\x8B\\xC4\\x48\\x89\\x48\\x08\\x55\\x53\\x56\\x57\\x41\\x56\\x48\\x8D\\xA8\\xD8\\xFE\\xFF\\xFF",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x41\\x54\\x53\\x48\\x89\\xFB\\x48\\x81\\xEC\\x2A\\x2A\\x2A\\x2A\\xE8\\x2A\\x2A\\x2A\\x2A\\x48\\x89\\xDF"
"windows": "48 ? ? 55 53 56 57 41 ? 48 ? ? ? 48 ? ? ? ? ? ? 4C 89 68",
"linux": "55 48 89 E5 41 56 41 55 41 54 53 48 89 FB 48 83 EC 40 E8 ? ? ? ? F3 0F 10 83"
}
},
"CGameEventManager_Init": {
"signatures": {
"library": "server",
"windows": "40 53 48 83 EC 20 48 8B 01 48 8B D9 FF 50 10",
"linux": "55 48 89 E5 53 48 89 FB 48 83 EC 08 48 8B 07 FF 50 18"
}
},
"GiveNamedItem": {
"signatures": {
"library": "server",
"windows": "\\x48\\x89\\x5C\\x24\\x18\\x48\\x89\\x74\\x24\\x20\\x55\\x57\\x41\\x54\\x41\\x56\\x41\\x57\\x48\\x8D\\x6C\\x24\\xD9",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x49\\x89\\xCE\\x41\\x55\\x49\\x89\\xF5\\x41\\x54\\x49\\x89\\xD4"
"windows": "48 89 5C 24 ? 48 89 74 24 ? 55 57 41 55 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 4D 8B F9",
"linux": "55 48 89 E5 41 57 41 56 41 55 41 54 53 48 81 EC D8 00 00 00 48 89 8D 18 FF FF FF"
}
},
"UTIL_Remove": {
"signatures": {
"library": "server",
"windows": "\\x48\\x85\\xC9\\x74\\x2A\\x48\\x8B\\xD1\\x48\\x8B\\x0D\\x2A\\x2A\\x2A\\x2A",
"linux": "\\x48\\x89\\xFE\\x48\\x85\\xFF\\x74\\x2A\\x48\\x8D\\x05\\x2A\\x2A\\x2A\\x2A\\x48"
}
},
"Host_Say": {
"signatures": {
"library": "server",
"windows": "\\x44\\x89\\x4C\\x24\\x20\\x44\\x88\\x44\\x24\\x18",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x49\\x89\\xFF\\x41\\x56\\x41\\x55\\x41\\x54\\x4D\\x89\\xC4"
"windows": "48 85 C9 74 ? 48 8B D1 48 8B 0D ? ? ? ?",
"linux": "48 89 FE 48 85 FF 74 ? 48 8D 05 ? ? ? ? 48"
}
},
"CBaseModelEntity_SetModel": {
"signatures": {
"library": "server",
"windows": "\\x48\\x89\\x5C\\x24\\x2A\\x48\\x89\\x7C\\x24\\x2A\\x55\\x48\\x8B\\xEC\\x48\\x83\\xEC\\x50\\x48\\x8B\\xF9\\x4C\\x8B\\xC2",
"linux": "\\x55\\x48\\x89\\xF2\\x48\\x89\\xE5\\x41\\x54\\x49\\x89\\xFC\\x48\\x8D\\x7D\\xE0\\x48\\x83\\xEC\\x2A\\x48\\x8D\\x05\\x2A\\x2A\\x2A\\x2A\\x48\\x8B\\x30\\x48\\x8B\\x06"
"library": "server",
"windows": "40 53 48 83 EC ? 48 8B D9 4C 8B C2 48 8B 0D ? ? ? ? 48 8D 54 24 ? 48 8B 01 FF 50 ? 48 8B 44 24 ? 48 8D 54 24 ? 48 8B CB 48 89 44 24 ? E8 ? ? ? ? 48 83 C4 ? 5B C3 CC CC CC CC CC 48 89 5C 24",
"linux": "55 48 89 F2 48 89 E5 53 48 89 FB 48 8D 7D ? 48 83 EC ? 48 8D 05 ? ? ? ? 48 8B 30 48 8B 06 FF 50 ? 48 8B 45 ? 48 8D 75 ? 48 89 DF 48 89 45 ? E8 ? ? ? ? 48 8B 5D ? C9 C3 CC CC CC 55"
}
},
"CCSPlayer_WeaponServices_CanUse": {
"signatures": {
"library": "server",
"windows": "\\x48\\x89\\x5C\\x24\\x10\\x48\\x89\\x6C\\x24\\x18\\x56\\x57\\x41\\x56\\x48\\x83\\xEC\\x30\\x80\\xB9\\xA0\\x00\\x00\\x00\\x00",
"linux": "\\x48\\x85\\xF6\\x0F\\x84\\x2A\\x2A\\x2A\\x2A\\x55\\x31\\xC9\\x48\\x89\\xE5\\x41\\x55\\x49\\x89\\xFD"
"windows": "48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 56 48 83 EC ? 48 8B 01 48 8B FA",
"linux": "55 48 8D 15 ? ? ? ? 48 89 E5 41 55 41 54 49 89 FC 53 48 89 F3 48 83 EC ? 48 8B 07 48 8B 80 ? ? ? ?"
}
},
"CCSPlayer_ItemServices_CanAcquire": {
"signatures": {
"library": "server",
"windows": "44 89 44 24 ? 48 89 54 24 ? 48 89 4C 24 ? 55 53 56 57 41 55 41 56 41 57 48 8B EC",
"linux": "55 48 89 E5 41 57 41 56 41 55 49 89 CD 41 54 49 89 FC 53 48 89 F3 48 83 EC 78"
}
},
"GetCSWeaponDataFromKey": {
"signatures": {
"library": "server",
"windows": "48 89 5C 24 ? 57 48 83 EC ? 33 FF 4C 8B CA 8B D9",
"linux": "55 31 D2 48 89 E5 41 56 41 55 41 54"
}
},
"CCSPlayer_ItemServices_GiveNamedItem": {
"offsets": {
"windows": 18,
"linux": 19
}
},
"CCSPlayer_ItemServices_DropActivePlayerWeapon": {
"offsets": {
"windows": 18,
"linux": 19
"windows": 21,
"linux": 22
}
},
"CCSPlayer_ItemServices_RemoveWeapons": {
"offsets": {
"windows": 19,
"linux": 20
}
"offsets": {
"windows": 22,
"linux": 23
}
},
"CGameSceneNode_GetSkeletonInstance": {
"offsets": {
"windows": 8,
"linux": 8
"windows": 8,
"linux": 8
}
},
"CCSGameRules_TerminateRound": {
"signatures": {
"library": "server",
"windows": "\\x48\\x8B\\xC4\\x4C\\x89\\x48\\x20\\x55\\x57",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x41\\x54\\x49\\x89\\xFC\\x53\\x48\\x81\\xEC\\xE8\\x01\\x00\\x00\\x48\\x8D\\x05\\x2A\\x2A\\x2A\\x2A"
}
"library": "server",
"windows": "48 8B C4 4C 89 48 ? 48 89 48 ? 55 56",
"linux": "55 48 89 E5 41 57 41 56 49 89 FE 41 55 41 54 53 48 81 EC ? ? ? ? 48 8D 05 ? ? ? ? F3 0F 11 85"
}
},
"CCSGameRules_FindPickerEntity": {
"offsets": {
"windows": 25,
"linux": 26
}
},
"CTakeDamageInfo_HitGroup": {
"offsets": {
"windows": 104,
"linux": 104
}
},
"UTIL_CreateEntityByName": {
"signatures": {
"library": "server",
"windows": "\\x48\\x83\\xEC\\x48\\xC6\\x44\\x24\\x30\\x00",
"linux": "\\x48\\x8D\\x05\\x2A\\x2A\\x2A\\x2A\\x55\\x48\\x89\\xFA"
}
"library": "server",
"windows": "48 83 EC 48 C6 44 24 30 00",
"linux": "48 8D 05 ? ? ? ? 55 48 89 FA"
}
},
"CBaseEntity_DispatchSpawn": {
"signatures": {
"library": "server",
"windows": "\\x48\\x89\\x5C\\x24\\x10\\x57\\x48\\x83\\xEC\\x30\\x48\\x8B\\xDA\\x48\\x8B\\xF9\\x48\\x85\\xC9",
"linux": "\\x48\\x85\\xFF\\x74\\x2A\\x55\\x48\\x89\\xE5\\x41\\x56"
}
"library": "server",
"windows": "48 89 5C 24 10 57 48 83 EC 30 48 8B DA 48 8B F9 48 85 C9",
"linux": "48 85 FF 74 ? 55 48 89 E5 41 55 49 89 FD"
}
},
"CBaseEntity_EmitSoundFilter": {
"signatures": {
"library": "server",
"windows": "40 53 48 83 EC ? 4C 89 4C 24 ? 48 8B D9 45 8B C8",
"linux": "55 48 89 E5 53 48 89 FB 48 83 EC ? E8 ? ? ? ? 48 89 D8 48 8B 5D ? C9 C3 CC CC CC CC CC CC 48 B8"
}
},
"CEntityInstance_AcceptInput": {
"signatures": {
"library": "server",
"windows": "\\x48\\x89\\x5C\\x24\\x10\\x48\\x89\\x74\\x24\\x18\\x57\\x48\\x83\\xEC\\x40\\x49\\x8B\\xF0",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x49\\x89\\xFF\\x41\\x56\\x48\\x8D\\x7D\\xC0"
"windows": "89 5C 24 ? 48 89 74 24 ? 57 48 83 EC ? 49 8B F0 48 8B D9 48 8B 0D",
"linux": "55 48 89 F0 48 89 E5 41 57 49 89 FF 41 56 48 8D 7D C0"
}
},
"CEntitySystem_AddEntityIOEvent": {
"signatures": {
"library": "server",
"windows": "48 89 5C 24 ? 4C 89 4C 24 ? 48 89 4C 24 ? 55 56 57 41 54 41 55 41 56 41 57 48 83 EC ? 49 8B F9",
"linux": "55 48 89 E5 41 55 49 89 CD 41 54 49 89 FC"
}
},
"LegacyGameEventListener": {
"signatures": {
"library": "server",
"windows": "\\x48\\x8B\\x15\\x2A\\x2A\\x2A\\x2A\\x48\\x85\\xD2\\x74\\x2A\\x85\\xC9\\x74",
"linux": "\\x48\\x8B\\x05\\x2A\\x2A\\x2A\\x2A\\x48\\x85\\xC0\\x74\\x2A\\x83\\xFF\\x3F\\x76\\x2A\\x31\\xC0"
"windows": "48 8B 15 ? ? ? ? 48 85 D2 74 ? 83 F9 ? 77 ? 48 63 C1 48 C1 E0",
"linux": "48 8B 05 ? ? ? ? 48 85 C0 74 ? 83 FF ? 77 ? 48 63 FF 48 C1 E7 ? 48 8D 44 38"
}
},
"CBasePlayerPawn_CommitSuicide": {
"offsets": {
"windows": 360,
"linux": 360
"windows": 408,
"linux": 408
}
},
"CBasePlayerPawn_RemovePlayerItem": {
"signatures": {
"library": "server",
"linux": "\\x55\\x48\\x89\\x2A\\x41\\x2A\\x49\\x89\\x2A\\x41\\x2A\\x49\\x89\\x2A\\xE8\\x2A\\x2A\\x2A\\x2A\\x49\\x39",
"windows": "\\x48\\x85\\xD2\\x0F\\x84\\x2A\\x2A\\x2A\\x2A\\x48\\x89\\x5C\\x24\\x08\\x57\\x48\\x83\\xEC\\x30\\x48\\x8B\\xDA"
"windows": "48 ? ? 0F 84 ? ? ? ? 48 89 5C 24 ? 57 48 ? ? ? 48 ? ? 48 ? ? E8",
"linux": "55 48 89 E5 41 54 49 89 FC 53 48 89 F3 E8 ? ? ? ? 48 39 C3 74 ? 4C 89 E7 E8 ? ? ? ? 48 39 C3 74 ? 4C 89 E7 48 89 DE E8 ? ? ? ? 48 89 DF 5B 41 5C 5D E9 ? ? ? ? 0F 1F 44 00 00"
}
},
"CBaseEntity_Teleport": {
"offsets": {
"windows": 149,
"linux": 148
"windows": 168,
"linux": 167
}
},
"CBaseEntity_TakeDamageOld": {
"signatures": {
"library": "server",
"windows": "\\x40\\x56\\x57\\x48\\x83\\xEC\\x58\\x48\\x8B\\x41\\x10",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x41\\x54\\x49\\x89\\xFC\\x53\\x48\\x83\\xEC\\x38\\x4C\\x8D\\x2D\\x2A\\x2A\\x2A\\x2A\\x49\\x8B\\x7D\\x00\\x48\\x85\\xFF\\x0F\\x84\\x2A\\x2A\\x2A\\x2A"
"windows": "40 55 41 54 41 55 41 56 41 57 48 81 EC ? ? ? ? 48 8D 6C 24 ? 48 89 9D ? ? ? ? 45 33 ED",
"linux": "55 48 89 E5 41 57 41 56 49 89 F6 41 55 41 54 49 89 FC 53 48 89 D3 48 83 EC ? 48 85 D2"
}
},
"CBaseTrigger_StartTouch": {
"signatures": {
"library": "server",
"windows": "\\x41\\x56\\x41\\x57\\x48\\x83\\xEC\\x58\\x48\\x8B\\x01",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x56\\x49\\x89\\xF6\\x41\\x55\\x49\\x89\\xFD\\x41\\x54\\x53\\xBB"
"windows": "40 57 41 56 48 83 EC ? 48 8B 01",
"linux": "55 48 89 E5 41 56 41 55 49 89 F5 41 54 53 48 89 FB 48 83 EC 10 48 8B 07"
}
},
"CBaseTrigger_EndTouch": {
"signatures": {
"library": "server",
"windows": "\\x40\\x53\\x57\\x41\\x55\\x48\\x83\\xEC\\x40",
"linux": "\\x55\\xBA\\xFF\\xFF\\xFF\\xFF\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x49\\x89\\xF5\\x41"
}
},
"StateChanged": {
"signatures": {
"library": "server",
"windows": "\\x40\\x55\\x53\\x56\\x41\\x55\\x41\\x57\\x48\\x8D\\x6C\\x24\\xB0",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x41\\x54\\x53\\x89\\xD3"
}
},
"NetworkStateChanged": {
"signatures": {
"library": "server",
"windows": "\\x4C\\x8B\\xC9\\x48\\x8B\\x09\\x48\\x85\\xC9\\x74\\x2A\\x48\\x8B\\x41\\x10",
"linux": "\\x4C\\x8B\\x07\\x4D\\x85\\xC0\\x74\\x2A\\x49\\x8B\\x40\\x10"
"windows": "40 53 41 55 48 83 EC 28",
"linux": "55 BA FF FF FF FF 48 89 E5 41 57 41 56 41 55 49 89 F5 41"
}
},
"GameEntitySystem": {
@@ -203,8 +235,60 @@
"CEntityIOOutput_FireOutputInternal": {
"signatures": {
"library": "server",
"windows": "\\x4C\\x89\\x4C\\x24\\x20\\x53\\x55\\x57\\x41\\x54\\x41\\x56\\x48\\x81\\xEC",
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x41\\x54\\x49\\x89\\xD4\\x53\\x48\\x89\\xF3\\x48\\x83\\xEC\\x58"
"windows": "4C 89 4C 24 ? 48 89 4C 24 ? 53 56",
"linux": "55 48 89 E5 41 57 49 89 FF 41 56 41 55 41 54 49 89 D4 53 48 89 F3"
}
},
"IGameSystem_InitAllSystems_pFirst": {
"signatures": {
"library": "server",
"windows": "48 8B 1D ? ? ? ? 48 85 DB 0F 84 ? ? ? ? BD",
"linux": "4C 8B 35 ? ? ? ? 4D 85 F6 75"
}
},
"CEntityResourceManifest_AddResource": {
"offsets": {
"windows": 2,
"linux": 0
}
},
"CheckTransmit": {
"signatures": {
"library": "server",
"windows": "48 8B C4 4C 89 48 ? 48 89 50 ? 48 89 48 ? 55 48 8D A8",
"linux": "55 48 89 E5 41 57 49 89 FF 41 56 48 8D 3D ? ? ? ? 41 55 41 89 D5"
}
},
"CheckTransmitPlayerSlot": {
"offsets": {
"windows": 576,
"linux": 576
}
},
"NetworkStateChanged": {
"signatures": {
"library": "server",
"windows": "4C 8B C2 48 8B D1 48 8B 09",
"linux": "48 8B 07 48 85 C0 74 ? 48 8B 50 10"
}
},
"SetStateChanged": {
"offsets": {
"windows": 25,
"linux": 26
}
},
"ISource2GameEntities::CheckTransmit": {
"offsets": {
"windows": 12,
"linux": 13
}
},
"Host_Say": {
"signatures": {
"library": "server",
"windows": "44 89 4C 24 20 44 88 44 24 18",
"linux": "55 48 89 E5 41 57 49 89 F7 41 56 41 55 41 54 4D 89 C4"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,320 +0,0 @@
ActionType_t
AimMatrixBlendMode
AmmoFlags_t
AmmoPosition_t
AnimationProcessingType_t
AnimationSnapshotType_t
AnimationType_t
AnimLoopMode_t
AnimNodeNetworkMode
AnimParamButton_t
AnimParamNetworkSetting
AnimParamType_t
AnimPoseControl
AnimScriptType
AnimValueSource
AnimVectorSource
attributeprovidertypes_t
BaseExplosionTypes_t
BBoxVolumeType_t
BeamClipStyle_t
BeamType_t
BeginDeathLifeStateTransition_t
BinaryNodeChildOption
BinaryNodeTiming
Blend2DMode
BlendKeyType
BloomBlendMode_t
BlurFilterType_t
BoneMaskBlendSpace
BoneTransformSpace_t
BrushSolidities_e
C4LightEffect_t
CAnimationGraphVisualizerPrimitiveType
CanPlaySequence_t
ChatIgnoreType_t
ChickenActivity
ChoiceBlendMethod
ChoiceChangeMethod
ChoiceMethod
Class_T
CLogicBranchList__LogicBranchListenerLastState_t
ClosestPointTestType_t
CNmBoneMask__WeightInfo_t
CommandEntitySpecType_t
CommandExecMode_t
CompMatPropertyMutatorConditionType_t
CompMatPropertyMutatorType_t
CompositeMaterialInputContainerSourceType_t
CompositeMaterialInputLooseVariableType_t
CompositeMaterialInputTextureType_t
CompositeMaterialMatchFilterType_t
CompositeMaterialVarSystemVar_t
CRR_Response__ResponseEnum_t
CSPlayerBlockingUseAction_t
CSPlayerState
CSWeaponCategory
CSWeaponMode
CSWeaponSilencerType
CSWeaponState_t
CSWeaponType
DamageTypes_t
DampingSpeedFunction
DebugOverlayBits_t
Detail2Combo_t
DetailCombo_t
DisableShadows_t
Disposition_t
doorCheck_e
DoorState_t
EDemoBoneSelectionMode
EInButtonState
EKillTypes_t
ELayoutNodeType
EntFinderMethod_t
EntityDisolveType_t
EntityDormancyType_t
EntityIOTargetType_t
EntitySubclassScope_t
EOverrideBlockLOS_t
EStyleNodeType
Explosions
FacingMode
FieldNetworkOption
fieldtype_t
filter_t
FixAngleSet_t
FlexOpCode_t
FootFallTagFoot_t
FootLockSubVisualization
FootPinningTimingSource
FootstepLandedFootSoundType_t
ForcedCrouchState_t
FuncDoorSpawnPos_t
FuseVariableAccess_t
FuseVariableType_t
GameAnimEventIndex_t
gear_slot_t
GrenadeType_t
HierarchyType_t
HitboxLerpType_t
HitGroup_t
HorizJustification_e
Hull_t
IChoreoServices__ChoreoState_t
IChoreoServices__ScriptState_t
IKChannelMode
IkEndEffectorType
IKSolverType
IKTargetCoordinateSystem
IKTargetSource
IkTargetType
InheritableBoolType_t
InputBitMask_t
InputLayoutVariation_t
ItemFlagTypes_t
JiggleBoneSimSpace
JointAxis_t
JointMotion_t
JumpCorrectionMethod
LatchDirtyPermission_t
LayoutPositionType_e
LessonPanelLayoutFileTypes_t
LifeState_t
loadout_slot_t
MaterialProxyType_t
Materials
MatterialAttributeTagType_t
MedalRank_t
MeshDrawPrimitiveFlags_t
MissingParentInheritBehavior_t
ModelBoneFlexComponent_t
ModelConfigAttachmentType_t
ModelSkeletonData_t__BoneFlags_t
ModifyDamageReturn_t
MoodType_t
MorphBundleType_t
MorphFlexControllerRemapType_t
MoveCollide_t
MoveLinearAuthoredPos_t
MovementGait_t
MoveMountingAmount_t
MoveType_t
NavAttributeEnum
NavDirType
navproperties_t
NmFootPhase_t
NmFootPhaseCondition_t
NmFrameSnapEventMode_t
NmTransitionRule_t
NmTransitionRuleCondition_t
NPCFollowFormation_t
NPCLookType_t
ObjectTypeFlags_t
ObserverInterpState_t
ObserverMode_t
OnFrame
ParticleAlphaReferenceType_t
ParticleAttachment_t
ParticleAttrBoxFlags_t
ParticleCollisionMode_t
ParticleColorBlendMode_t
ParticleColorBlendType_t
ParticleControlPointAxis_t
ParticleDepthFeatheringMode_t
ParticleDetailLevel_t
ParticleDirectionNoiseType_t
ParticleEndcapMode_t
ParticleFalloffFunction_t
ParticleFloatBiasType_t
ParticleFloatInputMode_t
ParticleFloatMapType_t
ParticleFloatRandomMode_t
ParticleFloatType_t
ParticleFogType_t
ParticleHitboxBiasType_t
ParticleHitboxDataSelection_t
ParticleImpulseType_t
ParticleLightBehaviorChoiceList_t
ParticleLightFogLightingMode_t
ParticleLightingQuality_t
ParticleLightnintBranchBehavior_t
ParticleLightTypeChoiceList_t
ParticleLightUnitChoiceList_t
ParticleModelType_t
ParticleOmni2LightTypeChoiceList_t
ParticleOrientationChoiceList_t
ParticleOrientationSetMode_t
ParticleOutputBlendMode_t
ParticleParentSetMode_t
ParticlePinDistance_t
ParticlePostProcessPriorityGroup_t
ParticleRotationLockType_t
ParticleSelection_t
ParticleSequenceCropOverride_t
ParticleSetMethod_t
ParticleSortingChoiceList_t
ParticleTextureLayerBlendType_t
ParticleTopology_t
ParticleTraceMissBehavior_t
ParticleTraceSet_t
ParticleTransformType_t
ParticleVecType_t
ParticleVRHandChoiceList_t
PerformanceMode_t
PermModelInfo_t__FlagEnum
PetGroundType_t
PFNoiseModifier_t
PFNoiseTurbulence_t
PFNoiseType_t
PFuncVisualizationType_t
PlayerAnimEvent_t
PlayerConnectedState
PointTemplateClientOnlyEntityBehavior_t
PointTemplateOwnerSpawnGroupType_t
PointWorldTextJustifyHorizontal_t
PointWorldTextJustifyVertical_t
PointWorldTextReorientMode_t
PoseType_t
PreviewCharacterMode
PreviewEOMCelebration
PreviewWeaponState
PropDoorRotatingOpenDirection_e
PropDoorRotatingSpawnPos_t
PulseCursorCancelPriority_t
PulseCursorExecResult_t
PulseInstructionCode_t
PulseMethodCallMode_t
PulseTestEnumColor_t
PulseTestEnumShape_t
PulseValueType_t
QuestProgress__Reason
RagdollPoseControl
RenderBufferFlags_t
RenderFx_t
RenderMode_t
RenderMultisampleType_t
RenderPrimitiveType_t
RenderSlotType_t
ResetCycleOption
RumbleEffect_t
ScalarExpressionType_t
SceneOnPlayerDeath_t
ScriptedConflictResponse_t
ScriptedMoveTo_t
ScriptedMoveType_t
ScriptedOnDeath_t
SelectorTagBehavior_t
SeqCmd_t
SeqPoseSetting_t
SequenceFinishNotifyState_t
ShadowType_t
ShakeCommand_t
ShardSolid_t
ShatterDamageCause
ShatterGlassStressType
ShatterPanelMode
SimpleConstraintSoundProfile__SimpleConstraintsSoundProfileKeypoints_t
SnapshotIndexType_t
SolidType_t
SolveIKChainAnimNodeDebugSetting
SosActionSortType_t
SosActionStopType_t
SosEditItemType_t
SosGroupType_t
SoundEventStartType_t
SoundFlags_t
soundlevel_t
SpawnDebugOverrideState_t
SpawnDebugRestrictionOverrideState_t
SpawnPointCoopEnemy__BotDefaultBehavior_t
SpriteCardPerParticleScale_t
SpriteCardShaderType_t
SpriteCardTextureChannel_t
SpriteCardTextureType_t
StanceOverrideMode
StanceType_t
StandardLightingAttenuationStyle_t
StateActionBehavior
StepPhase
SubclassVDataChangeType_t
SurroundingBoundsType_t
TakeDamageFlags_t
TextureRepetitionMode_t
ThreeState_t
TimelineCompression_t
TOGGLE_STATE
Touch_t
TrackOrientationType_t
TRAIN_CODE
TrainOrientationType_t
TrainVelocityType_t
ValueRemapperHapticsType_t
ValueRemapperInputType_t
ValueRemapperMomentumType_t
ValueRemapperOutputType_t
ValueRemapperRatchetType_t
VectorExpressionType_t
VectorFloatExpressionType_t
VelocityMetricMode
VertJustification_e
ViewFadeMode_t
VMixChannelOperation_t
VMixFilterSlope_t
VMixFilterType_t
VMixLFOShape_t
VMixPannerType_t
VMixProcessorType_t
VMixSubgraphSwitchInterpolationType_t
vote_create_failed_t
VPhysXAggregateData_t__VPhysXFlagEnum_t
VPhysXBodyPart_t__VPhysXFlagEnum_t
VPhysXConstraintParams_t__EnumFlags0_t
VPhysXJoint_t__Flags_t
WaterLevel_t
WeaponAttackType_t
WeaponSound_t
WeaponSwitchReason_t
WorldTextPanelHorizontalAlign_t
WorldTextPanelOrientation_t
WorldTextPanelVerticalAlign_t

View File

@@ -0,0 +1,27 @@
{
"menu.button.previous": "Prev",
"menu.button.next": "Next",
"menu.button.close": "Close",
"all": "all players",
"bots": "bots",
"humans": "humans",
"alive": "alive players",
"dead": "dead players",
"notme": "all players except self",
"ct": "ct players",
"t": "t players",
"spec": "spec players",
"No matching client": "No matching client was found.",
"No matching clients": "No matching clients were found.",
"Target must be alive": "This command can only be used on alive players.",
"Target must be dead": "This command can only be used on dead players.",
"Unable to target": "You cannot target this player.",
"Cannot target bot": "Unable to perform this command on a bot.",
"More than one client matched": "More than one client matched the given pattern.",
"Missing permissions": "You are missing the correct permissions",
"Missing one permission": "You do not have one of the correct permissions",
"Command permission denied": "[CSS] {0} ({1}) to execute this command."
}

View File

@@ -0,0 +1,27 @@
{
"menu.button.previous": "Anterior",
"menu.button.next": "Siguiente",
"menu.button.close": "Cerrar",
"all": "todos los jugadores",
"bots": "bots",
"humans": "humanos",
"alive": "jugadores vivos",
"dead": "jugadores muertos",
"notme": "todos los jugadores excepto yo",
"ct": "jugadores CT",
"t": "jugadores T",
"spec": "espectadores",
"No matching client": "No se encontró ningún cliente que coincida.",
"No matching clients": "No se encontraron clientes que coincidan.",
"Target must be alive": "Este comando solo puede usarse en jugadores vivos.",
"Target must be dead": "Este comando solo puede usarse en jugadores muertos.",
"Unable to target": "No puedes seleccionar a este jugador.",
"Cannot target bot": "No se puede ejecutar este comando en un bot.",
"More than one client matched": "Más de un cliente coincidió con el patrón dado.",
"Missing permissions": "No tienes los permisos correctos",
"Missing one permission": "No tienes uno de los permisos correctos",
"Command permission denied": "[CSS] {0} ({1}) para ejecutar este comando."
}

View File

@@ -0,0 +1,27 @@
{
"menu.button.previous": "Geri",
"menu.button.next": "İleri",
"menu.button.close": ıkış",
"all": "tüm oyuncular",
"bots": "botlar",
"humans": "insanlar",
"alive": "hayatta olan oyuncular",
"dead": "ölü oyuncular",
"notme": "kendi hariç tüm oyuncular",
"ct": "CT oyuncular",
"t": "T oyuncular",
"spec": "izleyici oyuncular",
"No matching client": "{white}Eşleşen bir istemci bulunamadı.",
"No matching clients": "{white}Eşleşen istemciler bulunamadı.",
"Target must be alive": "{white}Bu komut yalnızca hayatta olan oyunculara uygulanabilir.",
"Target must be dead": "{white}Bu komut yalnızca ölü oyunculara uygulanabilir.",
"Unable to target": "{white}Bu oyuncu hedeflenemez.",
"Cannot target bot": "{white}Bu komut bir bota uygulanamaz.",
"More than one client matched": "{white}Verilen kalıba birden fazla istemci eşleşti.",
"Missing permissions": "{white}Doğru izinlere sahip değilsiniz",
"Missing one permission": "{white}Doğru izinlerden birine sahip değilsiniz",
"Command permission denied": "[CSS] {0} ({1}) bu komutu çalıştırmak için."
}

View File

@@ -0,0 +1 @@
This folder should contain any shared APIs, in the same DLL structure as the plugins folder (MySharedApi/MySharedApi.dll)

80
create-release.sh Executable file
View File

@@ -0,0 +1,80 @@
#!/bin/bash
set -e
DRY_RUN=false
if [[ "$1" == "--dry-run" || "$1" == "-d" ]]; then
DRY_RUN=true
echo "Running in DRY-RUN mode - no changes will be pushed"
fi
echo "Starting automated release process..."
echo "Fetching latest tags from remote..."
git fetch --tags
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0")
echo "Latest tag found: $LATEST_TAG"
if [[ $LATEST_TAG =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
else
echo "Error: Could not parse version from tag $LATEST_TAG"
echo "Expected format: v1.0.x (e.g., v1.0.322)"
exit 1
fi
NEW_PATCH=$((PATCH + 1))
NEW_TAG="v$MAJOR.$MINOR.$NEW_PATCH"
echo "New version will be: $NEW_TAG"
echo "Generating changelog with git-cliff..."
npx git-cliff -o CHANGELOG.md -t "$NEW_TAG"
if ! git diff --quiet CHANGELOG.md; then
echo "Changelog updated successfully"
git add CHANGELOG.md
COMMIT_MSG="release: $NEW_TAG"
echo "Committing changelog with message: $COMMIT_MSG"
if [ "$DRY_RUN" = true ]; then
git commit -m "$COMMIT_MSG"
echo "Creating tag locally: $NEW_TAG"
git tag "$NEW_TAG"
echo "DRY-RUN: Would push commit to remote"
echo "DRY-RUN: Would push tag to remote"
else
git commit -m "$COMMIT_MSG"
echo "Pushing commit to remote..."
git push origin $(git branch --show-current)
echo "Creating and pushing tag: $NEW_TAG"
git tag "$NEW_TAG"
git push origin tag "$NEW_TAG"
fi
echo "Release $NEW_TAG completed successfully!"
echo "Summary:"
echo " - Previous version: $LATEST_TAG"
echo " - New version: $NEW_TAG"
echo " - Changelog updated: Yes"
if [ "$DRY_RUN" = true ]; then
echo " - Commit pushed: (dry-run)"
echo " - Tag created and pushed: (dry-run)"
else
echo " - Commit pushed: Yes"
echo " - Tag created and pushed: Yes"
fi
else
echo "No changes detected in CHANGELOG.md"
echo "This might indicate that there are no new commits since the last release."
exit 1
fi

View File

@@ -54,6 +54,9 @@ The specific subclass of `GameEvent` will provide strongly typed parameters from
These event properties are mutable so you can update them as normal and they will update in the event instance.
> [!CAUTION]
> `GameEvent` instances and their properties will cease to exist after the event listener function is called, which means that you will encounter errors when accessing properties in timers and functions like `Server.NextFrame()`. You should store the value of properties in variables before calling functions like `Server.NextFrame()` so you can read the data safely.
## Preventing Broadcast
You can modify a game event so that it does not get broadcast to clients by modifying the `bool info.DontBroadcast` property. e.g.

View File

@@ -0,0 +1,103 @@
---
title: Shared Plugin API (Capabilities)
description: How to add inter-plugin communication to CounterStrikeSharp plugins.
---
# Shared Plugin API
> [!NOTE]
> **New (experimental)**: You can now resolve plugin dependencies directly from your local **NuGet packages cache** instead of copying every DLL into the `shared/` folder. See **Dependency Resolution** below. This feature **disabled by default.**
How to expose and use shared plugin APIs between multiple plugins.
## Creating a Contract Library
Inter-plugin communication requires a contract/shared library that simply exposes the shape of the API, using simple interfaces. e.g.
```csharp
public interface IBalanceHandler
{
decimal Balance { get; }
// These are just here to show that you can have methods on your shared types.
// You could also add a Setter to the Balance property.
public decimal Add(decimal amount);
public decimal Subtract(decimal amount);
}
```
This library ideally should not contain any business logic, and simply define the schema for callers.
This library should be placed in the `shared` subfolder, in the same folder layout as the plugins folder. So if a contract DLL is named `MySharedApi.dll` its file path should be: `shared/MySharedApi/MySharedApi.dll`.
## Creating a Capability
A capability can be declared with a simple static variable in your plugin class. A `PlayerCapability` is a player specific capability, and a `PluginCapability` is generic functionality that a plugin can expose.
```csharp
public static PlayerCapability<IBalanceHandler> BalanceCapability { get; } = new("myplugin:balance");
public static PluginCapability<IBalanceService> BalanceServiceCapability { get; } = new("myplugin:balance_service");
```
For every plugin that wishes to use this new "Balance API", they must ensure they create a capability using the shared API interface (`IBalanceHandler`), as well as use the same name (`myplugin:balance`).
## Registering a Capability
If you are the plugin that is expected to provide the basis of the API (i.e. you are providing a currency/balance plugin which does nothing except store users balances), then you will need to provide the implementation that other callers will use. This is done through the use of static members on the `Capabilities` class:
```csharp
// Player capabilities are given the calling player context
Capabilities.RegisterPlayerCapability(BalanceCapability, player => new BalanceHandler(player));
// Plugin capabilities can simply return an instance of the interface
Capabilities.RegisterPluginCapability(BalanceServiceCapability, () => new BalanceService());
```
### Using Capabilities
To utilise a capability, simply call the `.Get()` method provided on the static capability you declared earlier, i.e.
```csharp
var balance = BalanceCapability.Get(player);
var balanceService = BalanceServiceCapability.Get();
if (balance == null) return;
balance.Add(500);
```
This value _MUST_ be checked for null, as if there are no plugins providing implementations for a given capability, this method will return null, and you must handle this flow in your plugin.
## Dependency Resolution
CounterStrikeSharp supports two complementary ways to resolve **external** assemblies used by your plugins and shared contracts:
1. **Shared Folder Resolution (manual)**: copy dependency DLLs into `shared/<PackageName>/<Assembly>.dll`.
2. **NuGet Dependency Resolver (auto)**: when enabled, resolves missing assemblies from the local **NuGet packages root**
### Enabling the NuGet Resolver
Add the following property to your core config (disabled by default):
```json
{
...
"PluginResolveNugetPackages": true
...
}
```
> [!NOTE]
> The engine looks for assemblies in the NuGet cache defined by the `NUGET_PACKAGES` environment variable, or falls back to the default user cache (e.g., `~/.nuget/packages` on Linux/macOS, `%UserProfile%\.nuget\packages` on Windows).
### Dependencies Resolution Order
When the NuGet resolver is **enabled**, resolution proceeds in this general order:
1. **Plugins directory** (in-place assemblies)
2. `shared/` **folder** (existing shared assemblies mechanism)
3. **NuGet cache** (auto-resolver)
This lets you keep proven `shared/` workflows while reducing manual copying for common NuGet dependencies.

View File

@@ -9,3 +9,6 @@
- name: Global Listeners
href: global-listeners.md
- name: Shared Plugin API
href: shared-plugin-api.md

View File

@@ -0,0 +1,99 @@
---
title: Automatically build/deploy your changes
description: Automatically build and deploy plugin changes to a remote development server as you work.
---
# Automatically build and deploy your changes
<sup>Adapted from the
[original guide](https://github.com/uFloppyDisk/create-cssharp-plugin/blob/c8fca43f86a61a5e874624f2f3ed39c5271c9a55/templates/standard-plugin/docs/auto-live-hot-reloading.md).
</sup>
During development of your plugin, you may find yourself repeating a workflow
similar to the following:
1. Make a change to your plugin
2. Run your build task (ex. `dotnet build`)
3. Upload plugin DLLs to your server using an FTP client
4. Alt-tab to the game
5. Test your changes
6. Repeat
Iterating on your plugin this way is painfully slow and impacts your productivity.
Below, you will find a guide and recommendations on how to setup your dev environment
to watch for file changes and automatically update plugin files on your server as you work.
By following this guide, your new workflow should look like this:
1. Make a change to your plugin
2. Alt-tab to the game
3. Test your changes
4. Repeat
> [!CAUTION]
> Exercise caution when developing your plugin while using this workflow.
> Build time errors are mostly caught by .NET SDK before files are committed
> but incomplete implementation may lead to issues such as server crashes.
> Avoid using this workflow on a production server meant for players.
## Setup
#### 1. Build plugin on file changes
The `dotnet` CLI, included with the .NET SDK, offers a convenient command for
automatically watching for source file changes. If you have access to the `dotnet`
CLI, run the following command to start watching your source code.
```shell
dotnet watch build --project path/to/projectName.csproj
```
<sup>By default, `dotnet watch` executes the `dotnet run` command on file changes
so specifying `build` as the first argument is required.</sup>
Your plugin will now build automatically on file change. By default, your builds
should be placed in `bin/<config>/<framework>` in the same directory as your `.csproj`.
```txt
projectDirectory
├── projectName.csproj
├── bin
│   └── Debug
│   └── net8.0
│      └── PLUGIN BUILDS HERE
```
> [!TIP]
> You can have your plugin build to a more convenient location by setting the
> `<OutDir>` build property in your `.csproj` file.
> Example: `<OutDir>./build/$(MSBuildProjectName)</OutDir>`
#### 2. Setup automatic uploads
##### Using WinSCP (Windows only)
Once connected to your server:
1. Go to the `Commands` tab at the top of the WinSCP window
and click `Keep Remote Directory up to Date`.
2. Select the plugin build directory containing your DLLs.
3. Select the plugin destination.
(`csgo/addons/counterstrikesharp/plugins/<projectName>`)
4. Click `Start`
> [!IMPORTANT]
> **For WSL users:**
> Applications running on Windows, such as WinSCP, cannot watch your Linux subsystem for file
> changes. Try using [this workaround](#using-winscp-while-developing-in-wsl) or consider
> moving development to Windows.
##### Using `lsyncd` (Linux)
> **TODO:** in-depth guide for setting up lsyncd
Learn more about `lsyncd`: https://github.com/lsyncd/lsyncd
___
#### Using WinSCP while developing in WSL
Run the following watch command in place of the one mentioned in
[Step 1](#1-build-plugin-on-file-changes) to build to a directory in your Windows filesystem
```shell
dotnet watch build --project path/to/<projectName>.csproj --property:OutDir=/mnt/<drive-letter>/some/path/<projectName>`
```
and have [WinSCP in Step 2](#2-setup-automatic-uploads) watch that path instead.
[Learn about Windows filesystem mounts in WSL](https://blogs.windows.com/windowsdeveloper/2016/07/22/fun-with-the-windows-subsystem-for-linux/#Working%20with%20Windows%20files:~:text=Working%20with%20Windows%20files)

View File

@@ -10,7 +10,7 @@ In this guide you will learn how to install CounterStrikeSharp onto your vanilla
If you're more of a visual person, here is a <a href="https://www.youtube.com/watch?v=FlsKzStHJuY" target="_blank">Youtube video</a> that covers everything.
## Prerequisites
- <a href="https://www.sourcemm.net/downloads.php/?branch=master" target="_blank">Metamod: Source 2.X Dev Build</a>
- <a href="https://www.metamodsource.net/downloads.php/?branch=master" target="_blank">Metamod: Source 2.X Dev Build</a>
- <a href="https://github.com/roflmuffin/CounterStrikeSharp/releases" target="_blank">CounterStrikeSharp With Runtime</a>
## Installing Metamod

View File

@@ -9,7 +9,7 @@ How to write your first plugin for CounterStrikeSharp
## Creating a New Project
First, ensure you have the relevant .NET 7.0 SDK for your platform installed on your machine. You can find the links to the latest downloads on the <a href="https://dotnet.microsoft.com/en-us/download/dotnet/7.0" target="_blank"> official Microsoft download page</a>.
First, ensure you have the relevant .NET 8.0 SDK for your platform installed on your machine. You can find the links to the latest downloads on the <a href="https://dotnet.microsoft.com/en-us/download/dotnet/8.0" target="_blank"> official Microsoft download page</a>.
### Creating a Class Library
@@ -25,7 +25,7 @@ Use your IDE (Visual Studio/Rider) to add a reference to the `CounterStrikeSharp
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
@@ -65,7 +65,7 @@ public class HelloWorldPlugin : BasePlugin
}
```
Now build your project using your ide or the `dotnet build` command. You should now have a built binary file in your `bin/Debug/net7.0` subdirectory in the project.
Now build your project using your ide or the `dotnet build` command. You should now have a built binary file in your `bin/Debug/net8.0` subdirectory in the project.
### Installing your Plugin

View File

@@ -6,3 +6,9 @@
- name: Dependency Injection
href: dependency-injection.md
- name: Referencing Players
href: referencing-players.md
- name: Automatically build and deploy your changes
href: auto-build-and-deploy.md

View File

@@ -28,11 +28,29 @@ receive a ban.
> [!NOTE]
> Disable this option at your own risk.
## PluginHotReloadEnabled
When enabled, plugins are automatically reloaded when their .dll file is updated.
## PluginAutoLoadEnabled
When enabled, plugins are automatically loaded from the plugins directory on server start.
## ServerLanguage
Configures the default language to use for server commands & messages. The format for the culture name based on RFC 4646 is `languagecode2-country`/`regioncode2`, where `languagecode2` is the two-letter language code and `country/regioncode2` is the two-letter subculture code. Examples include `ja-JP` for Japanese (Japan) and `en-US` for English (United States). Defaults to "en".
Configures the default language to use for server commands & messages. The format for the culture name based on RFC 4646 is `languagecode2-country`/`regioncode2`, where `languagecode2` is the two-letter language code and `country/regioncode2` is the two-letter subculture code. Examples include `ja-JP` for Japanese (Japan) and `en-US` for English (United States). Defaults to "en".
## UnlockConCommands
When enabled, will remove the `FCVAR_HIDDEN`,`FCVAR_DEVELOPMENTONLY`, `FCVAR_MISSING0`, `FCVAR_MISSING1`, `FCVAR_MISSING2`, `FCVAR_MISSING3` flags from all console commands.
## UnlockConVars
When enabled, will remove the `FCVAR_HIDDEN`,`FCVAR_DEVELOPMENTONLY`, `FCVAR_MISSING0`, `FCVAR_MISSING1`, `FCVAR_MISSING2`, `FCVAR_MISSING3` flags from all console variables.
## AutoUpdateEnabled
When enabled, CS# will check for any updates to the gamedata.json file and automatically update it if a new version is available.
## AutoUpdateURL
The URL to use for the auto-update feature. This URL should point to a JSON file that contains the latest version of the gamedata.json file.

View File

@@ -1,5 +1,2 @@
- name: Core Configuration
href: core-configuration.md
- name: Referencing Players
href: referencing-players.md
href: core-configuration.md

View File

@@ -0,0 +1,11 @@
[!INCLUDE [WithSharedTypes](../../examples/WithSharedTypes/README.md)]
<a href="https://github.com/roflmuffin/CounterStrikeSharp/tree/main/examples/WithSharedTypes" class="btn btn-secondary">View project on Github <i class="bi bi-github"></i></a>
[!code-csharp[](../../examples/WithSharedTypes/WithSharedTypesPlugin.cs)]
[!INCLUDE [WithSharedTypesConsumer](../../examples/WithSharedTypesConsumer/README.md)]
<a href="https://github.com/roflmuffin/CounterStrikeSharp/tree/main/examples/WithSharedTypesConsumer" class="btn btn-secondary">View project on Github <i class="bi bi-github"></i></a>
[!code-csharp[](../../examples/WithSharedTypesConsumer/WithSharedTypesConsumerPlugin.cs)]

View File

@@ -0,0 +1,5 @@
[!INCLUDE [WithUserMessages](../../examples/WithUserMessages/README.md)]
<a href="https://github.com/roflmuffin/CounterStrikeSharp/tree/main/examples/WithUserMessages" class="btn btn-secondary">View project on Github <i class="bi bi-github"></i></a>
[!code-csharp[](../../examples/WithUserMessages/WithUserMessagesPlugin.cs)]

View File

@@ -15,8 +15,12 @@ items:
href: WithGameEventHandlers.md
- name: Database (Dapper)
href: WithDatabase.md
- name: Shared Plugin Types
href: WithSharedTypes.md
- name: Translations
href: WithTranslations.md
- name: User Messages
href: WithUserMessages.md
- name: Voice Overrides
href: WithVoiceOverrides.md
- name: Warcraft Plugin

View File

@@ -0,0 +1,37 @@
# Tool taken from dotnet/runtime
# https://github.com/dotnet/runtime/blob/a8158c170b694f8c1dbae114c63c346b38244901/eng/formatting/download-tools.ps1
function DownloadClangTool {
param (
[string]
$toolName,
[string]
$downloadOutputPath
)
$clangVersion = "17.0.6"
$clangToolsRootUrl = "https://clrjit2.blob.core.windows.net/clang-tools"
$clangPlatform = "windows-x64"
$toolUrl = "$clangToolsRootUrl/$clangVersion/$clangPlatform/$toolName.exe"
$targetPath = "$downloadOutputPath\$toolName.exe"
if (-not $(ls $downloadOutputPath | Where-Object { $_.Name -eq "$toolName.exe" })) {
Write-Output "Downloading '$toolUrl' to '$targetPath'"
# Pass -PassThru as otherwise Invoke-WebRequest leaves a corrupted file if the download fails. With -PassThru the download is buffered first.
# -UseBasicParsing is necessary for older PowerShells when Internet Explorer might not be installed/configured
$null = Invoke-WebRequest -Uri "$toolUrl" -OutFile $(Join-Path $downloadOutputPath -ChildPath "$toolName.exe") -PassThru -UseBasicParsing
}
else {
Write-Output "Found '$targetPath'"
}
}
$downloadPathFolder = Split-Path $PSScriptRoot -Parent | Split-Path -Parent | Join-Path -ChildPath "artifacts" | Join-Path -ChildPath "tools"
mkdir $downloadPathFolder -ErrorAction SilentlyContinue
DownloadClangTool "clang-format" "$downloadPathFolder"
# Add to path to enable scripts to skip additional downloading steps since the tools will already be on the path.
$env:PATH = "$downloadPathFolder;$env:PATH"

View File

@@ -0,0 +1,60 @@
# Tool taken from dotnet/runtime
# https://github.com/dotnet/runtime/blob/a8158c170b694f8c1dbae114c63c346b38244901/eng/formatting/download-tools.sh
#!/usr/bin/env bash
set -ue
source="${BASH_SOURCE[0]}"
# resolve $source until the file is no longer a symlink
while [[ -h "$source" ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"
# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
function DownloadClangTool {
clangVersion="17.0.6"
clangToolsRootUrl="https://clrjit2.blob.core.windows.net/clang-tools"
clangPlatform="$(dotnet --info | grep 'RID:')"
clangPlatform="${clangPlatform##*RID:* }"
echo "dotnet RID: ${clangPlatform}"
# override common RIDs with compatible version so we don't need to upload binaries for each RID
case $clangPlatform in
ubuntu.*-x64)
clangPlatform=linux-x64
;;
esac
toolUrl="${clangToolsRootUrl}/${clangVersion}/${clangPlatform}/$1"
toolOutput=$2/$1
echo "Downloading $1 from ${toolUrl} to ${toolOutput}"
if [[ ! -x "$toolOutput" ]]; then
curl --silent --retry 5 --fail -o "${toolOutput}" "$toolUrl"
chmod 751 $toolOutput
fi
if [[ ! -x "$toolOutput" ]]; then
echo "Failed to download $1"
exit 1
fi
}
engFolder="$(cd -P "$( dirname "$scriptroot" )" && pwd )"
downloadPathFolder="$(cd -P "$( dirname "$engFolder" )" && pwd )/artifacts/tools"
mkdir -p "$downloadPathFolder"
DownloadClangTool "clang-format" "$downloadPathFolder"
export PATH=$downloadPathFolder:$PATH

29
eng/formatting/format.sh Normal file
View File

@@ -0,0 +1,29 @@
# Tool taken from dotnet/runtime
# https://github.com/dotnet/runtime/blob/a8158c170b694f8c1dbae114c63c346b38244901/eng/formatting/format.sh
#!/bin/sh
LC_ALL=C
# Select files to format
NATIVE_FILES=$(git diff --cached --name-only --diff-filter=ACM "*.h" "*.hpp" "*.c" "*.cpp" "*.inl" | sed 's| |\\ |g')
MANAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM "*.cs" "*.vb" | sed 's| |\\ |g')
exec 1>&2
if [ -n "$NATIVE_FILES" ]; then
# Format all selected files
echo "$NATIVE_FILES" | cat | xargs | sed -e 's/ /,/g' | xargs "./artifacts/tools/clang-format" -style=file -i
# Add back the modified files to staging
echo "$NATIVE_FILES" | xargs git add
fi
if [ -n "$MANAGED_FILES" ]; then
# Format all selected files
echo "$MANAGED_FILES" | cat | xargs | sed -e 's/ /,/g' | dotnet format whitespace --include - --folder
# Add back the modified files to staging
echo "$MANAGED_FILES" | xargs git add
fi
exit 0

71
eng/install/install.ps1 Normal file
View File

@@ -0,0 +1,71 @@
# Install script that downloads Metamod:Source and Counter-Strike Sharp (with runtime)
$MM_DOWNLOAD_URL = "https://mms.alliedmods.net/mmsdrop/2.0/mmsource-2.0.0-git1286-windows.zip"
$TARGET_DIR = "./game/csgo"
$GAMEINFO_FILE = Join-Path $TARGET_DIR "gameinfo.gi"
$ProgressPreference = 'SilentlyContinue'
# Verification
if (-not (Test-Path $GAMEINFO_FILE)) {
Write-Error "Error: $GAMEINFO_FILE does not exist in the specified directory."
exit 1
}
# GitHub API for Counter-Strike Sharp Releases
$RELEASE_INFO = (Invoke-WebRequest -Uri "https://api.github.com/repos/roflmuffin/CounterStrikeSharp/releases/latest").Content | ConvertFrom-Json
# Filtering download URLs
$CSSHARP_DOWNLOAD_URL = $RELEASE_INFO.assets |
Where-Object { $_.browser_download_url -like '*windows*.zip*' -and $_.browser_download_url -notlike '*with-runtime*' } |
Select-Object -First 1 -ExpandProperty browser_download_url
$CSSHARP_RUNTIME_DOWNLOAD_URL = $RELEASE_INFO.assets |
Where-Object { $_.browser_download_url -like '*windows*.zip*' -and $_.browser_download_url -like '*with-runtime*' } |
Select-Object -First 1 -ExpandProperty browser_download_url
### METAMOD:SOURCE ###
Write-Output "Downloading Metamod:Source..."
Invoke-WebRequest -Uri $MM_DOWNLOAD_URL -OutFile metamod.zip
Write-Output "Extracting Metamod:Source to $TARGET_DIR..."
Expand-Archive -Force -Path metamod.zip -DestinationPath $TARGET_DIR
Remove-Item metamod.zip
### GAMEINFO.GI UPDATE ###
$NEW_ENTRY = " Game csgo/addons/metamod"
$FILE_CONTENT = Get-Content $GAMEINFO_FILE
Write-Output "Updating $GAMEINFO_FILE..."
if ($FILE_CONTENT -contains $NEW_ENTRY) {
Write-Output "The entry '$NEW_ENTRY' already exists in $GAMEINFO_FILE. No changes were made."
} else {
$Pattern = "Game_LowViolence"
$Modified = $false
$NewContent = @()
foreach ($line in $FILE_CONTENT) {
if ($line -match $Pattern -and -not $Modified) {
$NewContent += $line
$NewContent += $NEW_ENTRY
$Modified = $true
} else {
$NewContent += $line
}
}
$NewContent | Set-Content $GAMEINFO_FILE
Write-Host "The file $GAMEINFO_FILE has been modified successfully. '$NEW_ENTRY' has been added."
}
### COUNTER-STRIKE SHARP ###
Write-Output "Downloading Counter-Strike Sharp (with runtime)..."
# Determine if runtime needs to be downloaded
if (-not (Test-Path "./game/csgo/addons/CounterStrikeSharp/dotnet/dotnet.exe")) {
$CSSHARP_DOWNLOAD_URL = $CSSHARP_RUNTIME_DOWNLOAD_URL
}
Invoke-WebRequest -Uri $CSSHARP_DOWNLOAD_URL -OutFile cssharp.zip
Write-Output "Extracting Counter-Strike Sharp to $TARGET_DIR..."
Expand-Archive -Force -Path cssharp.zip -DestinationPath $TARGET_DIR
Remove-Item cssharp.zip

72
eng/install/install.sh Executable file
View File

@@ -0,0 +1,72 @@
#!/bin/bash
# Install script that downloads Metamod:Source and Counter-Strike Sharp (with runtime)
MM_DOWNLOAD_URL="https://mms.alliedmods.net/mmsdrop/2.0/mmsource-2.0.0-git1286-linux.tar.gz"
TARGET_DIR="./game/csgo"
GAMEINFO_FILE="${TARGET_DIR}/gameinfo.gi"
if [ ! -f "${GAMEINFO_FILE}" ]; then
printf "Error: %s does not exist in the specified directory.\n" "$GAMEINFO_FILE"
exit 1
fi
RELEASE_INFO=$(curl -s https://api.github.com/repos/roflmuffin/CounterStrikeSharp/releases/latest)
# Filter and store download URLs
CSSHARP_DOWNLOAD_URL=$(echo "$RELEASE_INFO" | grep -o "browser_download_url.*linux.*\.zip" | cut -d '"' -f 3 | grep -v "with-runtime")
CSSHARP_RUNTIME_DOWNLOAD_URL=$(echo "$RELEASE_INFO" | grep -o "browser_download_url.*linux.*\.zip" | cut -d '"' -f 3 | grep "with-runtime")
### METAMOD:SOURCE ###
printf "Downloading Metamod:Source...\n"
curl -s -L -o metamod.tar.gz "$MM_DOWNLOAD_URL"
if [ $? -eq 0 ]; then
printf "Extracting Metamod:Source to %s...\n" "$TARGET_DIR"
tar -xzf metamod.tar.gz -C "$TARGET_DIR"
rm metamod.tar.gz
else
echo "Download failed. Please check the URL and your connection."
fi
### GAMEINFO.GI UPDATE ###
NEW_ENTRY=" Game csgo/addons/metamod"
printf "Updating %s...\n" "$GAMEINFO_FILE"
if grep -Fxq "$NEW_ENTRY" "$GAMEINFO_FILE"; then
echo "The entry '$(echo $NEW_ENTRY | xargs)' already exists in ${GAMEINFO_FILE}. No changes were made."
else
awk -v new_entry="$NEW_ENTRY" '
BEGIN { found=0; }
// {
if (found) {
print new_entry;
found=0;
}
print;
}
/Game_LowViolence/ { found=1; }
' "$GAMEINFO_FILE" > "$GAMEINFO_FILE.tmp" && mv "$GAMEINFO_FILE.tmp" "$GAMEINFO_FILE"
printf "The file %s has been modified successfully. '%s' has been added.\n" "$GAMEINFO_FILE" "$(echo $NEW_ENTRY | xargs)"
fi
printf "Downloading Counter-Strike Sharp (with runtime)...\n"
# If ./game/csgo/addons/CounterStrikeSharp/dotnet/dotnet does not exist, use the runtime download url
if [ ! -f "./game/csgo/addons/CounterStrikeSharp/dotnet/dotnet" ]; then
CSSHARP_DOWNLOAD_URL="$CSSHARP_RUNTIME_DOWNLOAD_URL"
fi
curl -s -L -o cssharp.zip "$CSSHARP_DOWNLOAD_URL"
if [ $? -eq 0 ]; then
printf "Extracting Counter-Strike Sharp to %s...\n" "$TARGET_DIR"
unzip -q -o cssharp.zip -d "$TARGET_DIR"
rm cssharp.zip
else
echo "Download failed. Please check the URL and your connection."
fi

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

View File

@@ -0,0 +1,11 @@
namespace MySharedTypes.Contracts;
public interface IBalanceHandler
{
decimal Balance { get; }
// These are just here to show that you can have methods on your shared types.
// You could also add a Setter to the Balance property.
public decimal Add(decimal amount);
public decimal Subtract(decimal amount);
}

View File

@@ -0,0 +1,6 @@
namespace MySharedTypes.Contracts;
public interface IBalanceService
{
public void ClearAllBalances();
}

View File

@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -16,6 +16,7 @@
using System;
using System.Drawing;
using System.Numerics;
using WarcraftPlugin.Effects;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Events;
@@ -67,10 +68,10 @@ namespace WarcraftPlugin.Races
private void Dash(float distance)
{
var directionVec = new Vector();
var directionVec = new Vector3();
NativeAPI.AngleVectors(Player.PlayerPawn.Value.EyeAngles.Handle, directionVec.Handle, IntPtr.Zero,
IntPtr.Zero);
// NativeAPI.AngleVectors(&Player.PlayerPawn.Value.EyeAngles, directionVec.Handle, IntPtr.Zero,
// IntPtr.Zero);
// Always shoot us up a little bit if were on the ground and not aiming up.
if (Player.GroundEntity.IsValid != null && directionVec.Z < 0.275)
@@ -80,9 +81,7 @@ namespace WarcraftPlugin.Races
directionVec *= distance;
Player.PlayerPawn.Value.AbsVelocity.X = directionVec.X;
Player.PlayerPawn.Value.AbsVelocity.Y = directionVec.Y;
Player.PlayerPawn.Value.AbsVelocity.Z = directionVec.Z;
Player.PlayerPawn.Value.AbsVelocity = directionVec;
}
private void PlayerHurtOther(GameEvent obj)
@@ -196,4 +195,4 @@ namespace WarcraftPlugin.Races
Console.WriteLine("Freeze finished");
}
}
}
}

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

View File

@@ -0,0 +1,2 @@
# With CheckTransmit
This example shows how to work with the `CheckTransmit` listener.

View File

@@ -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>

View File

@@ -0,0 +1,115 @@
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!";
private Dictionary<int, bool> ShouldSeeDoors = new Dictionary<int, bool>();
public override void Load(bool hotReload)
{
// This command is related to the following example.
AddCommand("nodoors", "Toggle door transmit", (player, info) =>
{
if (player == null)
return;
if (ShouldSeeDoors.ContainsKey(player.Slot))
{
ShouldSeeDoors[player.Slot] = !ShouldSeeDoors[player.Slot];
} else
{
ShouldSeeDoors.Add(player.Slot, false);
}
info.ReplyToCommand($"You should {(ShouldSeeDoors[player.Slot] ? "see" : "not see")} doors");
});
// In this example, we will hide every door for players that have enabled the option with the command 'nodoors'
RegisterListener<Listeners.CheckTransmit>((CCheckTransmitInfoList infoList) =>
{
// Get the list of the currently available doors (prop_door_rotating)
IEnumerable<CPropDoorRotating> doors = Utilities.FindAllEntitiesByDesignerName<CPropDoorRotating>("prop_door_rotating");
// Do nothing if there is none.
if (!doors.Any())
return;
// Go through every received info
foreach ((CCheckTransmitInfo info, CCSPlayerController? player) in infoList)
{
// If no player is found, we can continue
if (player == null)
continue;
// Otherwise, lets do the work:
// Check if we should clear or not:
// If we have no data saved for this player, then we should not continue
if (!ShouldSeeDoors.ContainsKey(player.Slot))
continue;
// If this value is true, then this player should see doors
if (ShouldSeeDoors[player.Slot])
continue;
// Otherwise, lets remove the door entity indexes from the info list so they won't be transmitted
foreach (CPropDoorRotating door in doors)
{
info.TransmitEntities.Remove(door);
}
// NOTE: this is a barebone example, saving data and doing sanity checks is up to you.
}
});
// In this example, we will hide other players in the same team as the player.
// NOTE: 'Hiding' players requires extra work to do, killing non-transmitted players results in crash.
RegisterListener<Listeners.CheckTransmit>((CCheckTransmitInfoList infoList) =>
{
// Get the list of the current players, we only work with this value later on
List<CCSPlayerController> players = Utilities.GetPlayers();
// Go through every received info
foreach ((CCheckTransmitInfo info, CCSPlayerController? player) in infoList)
{
// If no player is found, we can continue
if (player == null)
continue;
// 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 &&
// we shouldn't hide ourselves
p.Slot != player.Slot &&
// is the player is in the same team
p.Team == player.Team &&
// is alive
p.PlayerPawn.Value?.LifeState == (byte)LifeState_t.LIFE_ALIVE
);
foreach (CCSPlayerController targetPlayer in targetPlayers)
{
// Calling 'Remove' will clear the entity index of the target player pawn from the transmission list
// so it won't be transmitted for the 'player'.
info.TransmitEntities.Remove(targetPlayer.Pawn.EntityIndex);
}
}
});
}
}

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

View File

@@ -1,38 +1,60 @@
using System.Text.Json.Serialization;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
namespace WithConfig;
public class SampleConfig : BasePluginConfig
{
[JsonPropertyName("ChatPrefix")] public string ChatPrefix { get; set; } = "My Cool Plugin";
[JsonPropertyName("ChatInterval")] public float ChatInterval { get; set; } = 60;
}
[MinimumApiVersion(80)]
public class WithConfigPlugin : BasePlugin, IPluginConfig<SampleConfig>
{
public override string ModuleName => "Example: With Config";
public override string ModuleVersion => "1.0.0";
public SampleConfig Config { get; set; }
public void OnConfigParsed(SampleConfig config)
{
// Do manual verification of the config and override any invalid values
if (config.ChatInterval > 60)
{
config.ChatInterval = 60;
}
if (config.ChatPrefix.Length > 25)
{
throw new Exception($"Invalid value has been set to config value 'ChatPrefix': {config.ChatPrefix}");
}
// Once we've validated the config, we can set it to the instance
Config = config;
}
}
using System.Text.Json.Serialization;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Admin;
using CounterStrikeSharp.API.Modules.Commands;
using CounterStrikeSharp.API.Modules.Config;
using CounterStrikeSharp.API.Modules.Extensions;
namespace WithConfig;
public class SampleConfig : BasePluginConfig
{
[JsonPropertyName("ChatPrefix")] public string ChatPrefix { get; set; } = "My Cool Plugin";
[JsonPropertyName("ChatInterval")] public float ChatInterval { get; set; } = 60;
}
[MinimumApiVersion(80)]
public class WithConfigPlugin : BasePlugin, IPluginConfig<SampleConfig>
{
public override string ModuleName => "Example: With Config";
public override string ModuleVersion => "1.0.0";
public SampleConfig Config { get; set; }
public void OnConfigParsed(SampleConfig config)
{
// Do manual verification of the config and override any invalid values
if (config.ChatInterval > 60)
{
config.ChatInterval = 60;
}
if (config.ChatPrefix.Length > 25)
{
throw new Exception($"Invalid value has been set to config value 'ChatPrefix': {config.ChatPrefix}");
}
// Once we've validated the config, we can set it to the instance
Config = config;
}
[ConsoleCommand("css_reload_config", "Reloads the plugin config")]
public void OnReloadConfig(CCSPlayerController? player, CommandInfo commandInfo)
{
commandInfo.ReplyToCommand("Chat Interval before reload: " + Config.ChatInterval);
Config.Reload();
commandInfo.ReplyToCommand("Chat Interval after reload: " + Config.ChatInterval);
}
[ConsoleCommand("css_reset_config", "Resets the plugin config")]
public void OnResetConfig(CCSPlayerController? player, CommandInfo commandInfo)
{
commandInfo.ReplyToCommand("Chat Interval before reset: " + Config.ChatInterval);
Config.ChatInterval = 60;
Config.Update();
commandInfo.ReplyToCommand("Chat Interval after reset: " + Config.ChatInterval);
}
}

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

View File

@@ -0,0 +1,33 @@
using CounterStrikeSharp.API.Core;
using MySharedTypes.Contracts;
namespace WithSharedTypes;
public class BalanceHandler : IBalanceHandler
{
private readonly CCSPlayerController _player;
// This could be a database, a file, or a dictionary like this.
internal static readonly Dictionary<CCSPlayerController, decimal> Balances = new();
public BalanceHandler(CCSPlayerController player)
{
_player = player;
}
public decimal Balance
{
get => Balances.TryGetValue(_player, out var balance) ? balance : 0;
set => Balances[_player] = value;
}
public decimal Add(decimal amount)
{
return Balance += amount;
}
public decimal Subtract(decimal amount)
{
return Balance -= amount;
}
}

View File

@@ -0,0 +1,11 @@
using MySharedTypes.Contracts;
namespace WithSharedTypes;
public class BalanceService : IBalanceService
{
public void ClearAllBalances()
{
BalanceHandler.Balances.Clear();
}
}

View File

@@ -0,0 +1,5 @@
# With Shared Types (Capabilities)
An example plugin that exposes a balance contract library, to use as a shared library between multiple plugins.
This allows one plugin to expose a capability for a player or plugin, and other plugins to use the exposed API.

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\managed\CounterStrikeSharp.API\CounterStrikeSharp.API.csproj" />
<ProjectReference Include="..\MySharedTypes.Contracts\MySharedTypes.Contracts\MySharedTypes.Contracts.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,57 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Core.Capabilities;
using MySharedTypes.Contracts;
namespace WithSharedTypes;
[MinimumApiVersion(184)]
public class WithSharedTypesPlugin : BasePlugin
{
public override string ModuleName => "Example: Shared Types";
public override string ModuleVersion => "1.0.0";
public override string ModuleAuthor => "CounterStrikeSharp & Contributors";
public override string ModuleDescription => "A simple plugin that shares types between multiple plugins";
// Declares a player capability, that stores some sort of functionality for a player.
// In this case, it's a balance handler, which is used to store a player's balance.
// Note that we use the same name for the capability as the one in the other plugin.
// IBalanceHandler is defined in MySharedTypes.Contracts, which is a shared library and placed in the `shared/` subfolder.
public static PlayerCapability<IBalanceHandler> BalanceCapability { get; } = new("myplugin:balance");
// Declares a player capability of a primitive type, in this case, a decimal.
public static PlayerCapability<Decimal> BalanceCapabilityDecimal { get; } = new("myplugin:balance_decimal");
// Plugin capabilities are similar to player capabilities, but they are not tied to a player, and are just generic APIs
// that are exposed by a plugin. In this case, we expose a balance service, which is used to clear all balances.
public static PluginCapability<IBalanceService> BalanceServiceCapability { get; } = new("myplugin:balance_service");
public override void Load(bool hotReload)
{
// Register the capability implementations here. Note that plugins don't need to register an implementation if it is already implemented in another plugin.
Capabilities.RegisterPlayerCapability(BalanceCapability, player => new BalanceHandler(player));
Capabilities.RegisterPluginCapability(BalanceServiceCapability, () => new BalanceService());
Capabilities.RegisterPlayerCapability(BalanceCapabilityDecimal, (player) => new BalanceHandler(player).Balance);
AddCommand("css_balance", "Gets your current balance", (player, info) =>
{
if (player == null) return;
player.PrintToChat($"Your balance is {BalanceCapability.Get(player)?.Balance}");
});
AddCommand("css_give", "Gives you money", (player, info) =>
{
if (player == null) return;
var balance = BalanceCapability.Get(player);
if (balance == null) return;
balance.Add(100);
player.PrintToChat($"Your balance is now {balance.Balance}");
});
}
public override void Unload(bool hotReload)
{
}
}

View File

@@ -0,0 +1,2 @@
# With Shared Types (Consumer Plugin)
Uses the decimal balance shared library.

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\managed\CounterStrikeSharp.API\CounterStrikeSharp.API.csproj" />
<ProjectReference Include="..\MySharedTypes.Contracts\MySharedTypes.Contracts\MySharedTypes.Contracts.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,56 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Core.Capabilities;
using CounterStrikeSharp.API.Core.Plugin;
using MySharedTypes.Contracts;
namespace WithSharedTypesConsumer;
[MinimumApiVersion(184)]
public class WithSharedTypesConsumerPlugin : BasePlugin
{
public override string ModuleName => "Example: Shared Types (Consumer)";
public override string ModuleVersion => "1.0.0";
public override string ModuleAuthor => "CounterStrikeSharp & Contributors";
public override string ModuleDescription => "A simple plugin that utilises the balance api from another plugin";
public static PlayerCapability<IBalanceHandler> BalanceCapability { get; } = new("myplugin:balance");
public static PlayerCapability<Decimal> BalanceCapabilityDecimal { get; } = new("myplugin:balance_decimal");
public static PluginCapability<IBalanceService> BalanceServiceCapability { get; } = new("myplugin:balance_service");
public override void Load(bool hotReload)
{
AddCommand("css_subtract", "Subtracts 50 from your balance", (player, info) =>
{
if (player == null) return;
var balance = BalanceCapability.Get(player);
if (balance == null) return;
balance.Subtract(50);
player.PrintToChat($"Your balance is now {balance.Balance}");
});
AddCommand("css_clearbalances", "Clears all balances", (player, info) =>
{
if (player == null) return;
var service = BalanceServiceCapability.Get();
if (service == null) return;
service.ClearAllBalances();
var balance = BalanceCapability.Get(player);
if (balance == null) return;
player.PrintToChat($"Your balance is now {balance.Balance}");
});
AddCommand("css_decimalbalance", "Gets your current balance", (player, info) =>
{
if (player == null) return;
player.PrintToChat($"Your balance is {BalanceCapabilityDecimal.Get(player)}");
});
}
public override void Unload(bool hotReload)
{
}
}

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

View File

@@ -1,4 +1,4 @@
using System.Globalization;
using System.Globalization;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
@@ -22,18 +22,29 @@ public class WithTranslationsPlugin : BasePlugin
// A global `Localizer` is provided on the plugin instance.
// You can also use dependency injection to inject `IStringLocalizer` in your own services.
Logger.LogInformation("This message is in the server language: {Message}", Localizer["test.translation"]);
// IStringLocalizer can accept standard string format arguments.
// "This number has 2 decimal places {0:n2}" -> "This number has 2 decimal places 123.55"
Logger.LogInformation(Localizer["test.format", 123.551]);
// This message has colour codes
Server.PrintToChatAll(Localizer["test.colors"]);
// This message has colour codes and formatted values
Server.PrintToChatAll(Localizer["test.colors.withformat", 123.551]);
// This prints the message to all players in their respective language
PrintToAllPlayersLocalized("test.format", 123.456);
}
void PrintToAllPlayersLocalized(string key, params object[] args)
{
foreach (var player in Utilities.GetPlayers().Where(x => x.IsValid))
{
player.PrintToChat(Localizer.ForPlayer(player, key, args));
}
}
[ConsoleCommand("css_replylanguage", "Test Translations")]
public void OnCommandReplyLanguage(CCSPlayerController? player, CommandInfo command)
{

View File

@@ -0,0 +1,2 @@
# With User Messages
This is example shows how you can hook, interrupt and send User Messages.

View File

@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\managed\CounterStrikeSharp.API\CounterStrikeSharp.API.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,84 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Commands;
using CounterStrikeSharp.API.Modules.UserMessages;
using Microsoft.Extensions.Logging;
namespace WithUserMessages;
[MinimumApiVersion(80)]
public class WithUserMessagesPlugin : BasePlugin
{
public override string ModuleName => "Example: With User Messages";
public override string ModuleVersion => "1.0.0";
public override string ModuleAuthor => "CounterStrikeSharp & Contributors";
public override string ModuleDescription => "A simple plugin that hooks and sends User Messages";
public override void Load(bool hotReload)
{
// Hooks can be added using the user message ID. In this case it's the ID for `CMsgTEFireBullets`.
HookUserMessage(452, um =>
{
// Sets all weapon sounds to the sound of a silenced usp.
um.SetUInt("weapon_id", 0);
um.SetInt("sound_type", 9);
um.SetUInt("item_def_index", 61);
return HookResult.Continue;
}, HookMode.Pre);
HookUserMessage(118, um =>
{
var author = um.ReadString("param1");
var message = um.ReadString("param2");
Logger.LogInformation("Chat message from {Author}: {Message}", author, message);
for (var i = 0; i < um.Recipients.Count; i++)
{
Logger.LogInformation("Recipient {Index}: {Name}", i, um.Recipients[i].PlayerName);
}
if (message.Contains("stop"))
{
return HookResult.Stop;
}
if (message.Contains("skip"))
{
um.Recipients.Clear();
}
return HookResult.Continue;
});
}
[ConsoleCommand("css_shake")]
public void OnCommandShake(CCSPlayerController? player, CommandInfo command)
{
if (player == null) return;
// UserMessage.FromPartialName is a helper method that creates a UserMessage object from a partial network name.
// In this case, it will resolve to `CUserMessageShake`.
var message = UserMessage.FromPartialName("Shake");
message.SetFloat("duration", 2);
message.SetFloat("amplitude", 5);
message.SetFloat("frequency", 10f);
message.SetInt("command", 0);
if (command.GetArg(1) == "all")
{
message.Recipients.AddAllPlayers();
}
else
{
message.Recipients.Add(player);
}
message.Send();
// You can also use an overload of `Send` to send the message to a specific player without manually creating a recipient filter.
// message.Send(player);
}
}

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

1
libraries/Protobufs Submodule

Submodule libraries/Protobufs added at 7af53a5e1c

12818
libraries/httplib/httplib.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,4 @@
#set(_ITERATOR_DEBUG_LEVEL 2)
add_definitions(-D_LINUX -DPOSIX -DLINUX -DGNUC -DCOMPILER_GCC -DPLATFORM_64BITS)
add_definitions(-D_LINUX -DPOSIX -DLINUX -DGNUC -DCOMPILER_GCC -DPLATFORM_64BITS -D_FILE_OFFSET_BITS=64 -D_GLIBCXX_USE_CXX11_ABI=0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dstrnicmp=strncasecmp -D_snprintf=snprintf")
@@ -16,16 +14,18 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof -Wno-reorder")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse -msse -fno-strict-aliasing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics -v -fvisibility=default")
SET(
COUNTER_STRIKE_SHARP_LINK_LIBRARIES
${SOURCESDK_LIB}/linux64/libtier0.so
${SOURCESDK_LIB}/linux64/tier1.a
${SOURCESDK_LIB}/linux64/interfaces.a
${SOURCESDK_LIB}/linux64/mathlib.a
spdlog
dynload_s
dyncall_s
distorm
funchook-static
dynohook
)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs=libprotobuf.a")
set(
COUNTER_STRIKE_SHARP_LINK_LIBRARIES
${SOURCESDK_LIB}/linux64/libtier0.so
${SOURCESDK_LIB}/linux64/tier1.a
${SOURCESDK_LIB}/linux64/interfaces.a
${SOURCESDK_LIB}/linux64/mathlib.a
spdlog
dynload_s
dyncall_s
distorm
funchook-static
dynohook
)

59
makefiles/protobuf.cmake Normal file
View File

@@ -0,0 +1,59 @@
# Credit for this protobuf generation cmake file goes to Poggicek.
# Based on their work at https://github.com/Poggicek/StickerInspect
set(PROTO_TARGETS
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/network_connection.proto
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/networkbasetypes.proto
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/cs_gameevents.proto
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/engine_gcmessages.proto
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/gcsdk_gcmessages.proto
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/cstrike15_gcmessages.proto
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/cstrike15_usermessages.proto
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/netmessages.proto
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/steammessages.proto
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/usermessages.proto
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/gameevents.proto
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/clientmessages.proto
${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo/te.proto
)
if(UNIX)
set(PROTOC_EXECUTABLE ${PROJECT_SOURCE_DIR}/libraries/hl2sdk-cs2/devtools/bin/linux/protoc)
elseif(WIN32)
set(PROTOC_EXECUTABLE ${PROJECT_SOURCE_DIR}/libraries/hl2sdk-cs2/devtools/bin/protoc.exe)
endif()
foreach(PROTO_TARGET ${PROTO_TARGETS})
get_filename_component(PROTO_FILENAME ${PROTO_TARGET} NAME_WLE)
list(APPEND PROTO_OUTPUT ${PROTO_FILENAME}.pb.cc ${PROTO_FILENAME}.pb.h)
list(APPEND PROTO_INPUT ${PROTO_FILENAME}.proto)
get_filename_component(PROTO_PATH ${PROTO_TARGET} DIRECTORY)
list(APPEND PROTO_PATHS "--proto_path=${PROTO_PATH}")
endforeach()
list(REMOVE_DUPLICATES PROTO_PATHS)
list(TRANSFORM PROTO_OUTPUT PREPEND ${CMAKE_CURRENT_BINARY_DIR}/protobufcompiler/)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/protobufcompiler)
add_custom_command(
OUTPUT ${PROTO_OUTPUT}
COMMAND "${PROTOC_EXECUTABLE}" -I ${PROJECT_SOURCE_DIR}/libraries/hl2sdk-cs2/thirdparty/protobuf-3.21.8/src --proto_path=${PROJECT_SOURCE_DIR}/libraries/Protobufs/csgo ${PROTO_PATHS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR}/protobufcompiler ${PROTO_INPUT}
COMMENT "Generating protobuf file"
)
add_library(Protobufs STATIC
${PROTO_OUTPUT}
)
target_include_directories(Protobufs
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/protobufcompiler
PUBLIC ${PROJECT_SOURCE_DIR}/libraries/hl2sdk-cs2/thirdparty/protobuf-3.21.8/src
)
if(WIN32)
target_link_libraries(Protobufs PUBLIC ${PROJECT_SOURCE_DIR}/libraries/hl2sdk-cs2/lib/public/win64/2015/libprotobuf.lib)
elseif(UNIX)
target_link_libraries(Protobufs PUBLIC ${PROJECT_SOURCE_DIR}/libraries/hl2sdk-cs2/lib/linux64/release/libprotobuf.a)
endif()
set_target_properties(Protobufs PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(Protobufs PROPERTIES FOLDER SDK)

View File

@@ -1,8 +1,8 @@
if (UNIX AND NOT APPLE)
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()
if (WIN32 AND NOT MSVC)
if(WIN32 AND NOT MSVC)
message(FATAL "MSVC restricted.")
endif()
@@ -11,23 +11,39 @@ set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING
FORCE
)
# TODO: Use C++20 instead.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
if (LINUX)
if(LINUX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif()
set(CMAKE_STATIC_LIBRARY_PREFIX "")
set(LIBRARIES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libraries)
set(SOURCESDK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libraries/hl2sdk-cs2)
set(METAMOD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libraries/metamod-source)
set(SOURCESDK ${SOURCESDK_DIR}/${BRANCH})
set(SOURCESDK_LIB ${SOURCESDK}/lib)
add_definitions(-DMETA_IS_SOURCE2)
add_definitions(-DMETA_IS_SOURCE2 -D_ITERATOR_DEBUG_LEVEL=0)
if(DEFINED ENV{GITHUB_SHA_SHORT})
add_definitions(-DGITHUB_SHA="$ENV{GITHUB_SHA_SHORT}")
else()
add_definitions(-DGITHUB_SHA="Local")
endif()
if(DEFINED ENV{SEMVER})
add_definitions(-DSEMVER="$ENV{SEMVER}")
else()
add_definitions(-DSEMVER="Local")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
endif()
include_directories(
${SOURCESDK}
@@ -42,7 +58,7 @@ include_directories(
${SOURCESDK}/public/tier1
${SOURCESDK}/public/entity2
${SOURCESDK}/public/game/server
${SOURCESDK}/public/entity2
${SOURCESDK}/public/schemasystem
${METAMOD_DIR}/core
${METAMOD_DIR}/core/sourcehook
libraries/dyncall/dynload
@@ -51,7 +67,10 @@ include_directories(
libraries/tl
libraries/funchook/include
libraries/DynoHook/src
libraries/moodycamel
libraries
)
include(${CMAKE_CURRENT_LIST_DIR}/metamod/configure_metamod.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/metamod/configure_metamod.cmake)

View File

@@ -6,6 +6,7 @@ add_definitions(
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4819 /wd4828 /wd5033 /permissive- /utf-8 /wd4005 /MP")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt")
set(COUNTER_STRIKE_SHARP_LINK_LIBRARIES
${SOURCESDK_LIB}/public/win64/tier0.lib
@@ -18,4 +19,4 @@ set(COUNTER_STRIKE_SHARP_LINK_LIBRARIES
distorm
funchook-static
dynohook
)
)

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

View File

@@ -13,4 +13,14 @@ public class Api
{
return Assembly.GetAssembly(typeof(BasePlugin))!.GetName().Version!.Build;
}
/// <summary>
/// Returns the assembly version of CounterStrikeSharp running on the server as a string including git commit hash
/// </summary>
/// <example>1.0.0+9d8b6be</example>
public static string GetVersionString()
{
return Assembly.GetAssembly(typeof(BasePlugin))!.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!
.InformationalVersion;
}
}

Binary file not shown.

View File

@@ -11,8 +11,10 @@ using CounterStrikeSharp.API.Core.Plugin;
using CounterStrikeSharp.API.Core.Plugin.Host;
using CounterStrikeSharp.API.Core.Translations;
using CounterStrikeSharp.API.Modules.Admin;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Serilog;
@@ -44,7 +46,11 @@ public static class Bootstrap
services.AddSingleton<IPluginManager, PluginManager>();
services.AddSingleton<IPlayerLanguageManager, PlayerLanguageManager>();
services.AddScoped<IPluginContextQueryHandler, PluginContextQueryHandler>();
services.AddSingleton<ICommandManager, CommandManager>();
services.AddSingleton<ICommandManager, CommandManager>();
services.TryAddSingleton<IStringLocalizerFactory, CoreJsonStringLocalizerFactory>();
services.TryAddTransient(typeof(IStringLocalizer<>), typeof(StringLocalizer<>));
services.TryAddTransient(typeof(IStringLocalizer), typeof(StringLocalizer));
services.Scan(i => i.FromCallingAssembly()
.AddClasses(c => c.AssignableTo<IStartupService>())
@@ -71,4 +77,4 @@ public static class Bootstrap
return 0;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -17,6 +17,7 @@
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CounterStrikeSharp.API.Core.Commands;
using CounterStrikeSharp.API.Core.Hosting;
using CounterStrikeSharp.API.Core.Plugin;
@@ -28,6 +29,7 @@ using CounterStrikeSharp.API.Modules.Entities;
using CounterStrikeSharp.API.Modules.Menu;
using CounterStrikeSharp.API.Modules.Utils;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
namespace CounterStrikeSharp.API.Core
@@ -35,6 +37,8 @@ namespace CounterStrikeSharp.API.Core
public sealed class Application
{
private static Application _instance = null!;
public static IStringLocalizer Localizer => Instance._localizer;
public ILogger Logger { get; }
public static Application Instance => _instance!;
@@ -48,11 +52,12 @@ namespace CounterStrikeSharp.API.Core
private readonly IPluginContextQueryHandler _pluginContextQueryHandler;
private readonly IPlayerLanguageManager _playerLanguageManager;
private readonly ICommandManager _commandManager;
private readonly IStringLocalizer _localizer;
public Application(ILoggerFactory loggerFactory, IScriptHostConfiguration scriptHostConfiguration,
GameDataProvider gameDataProvider, CoreConfig coreConfig, IPluginManager pluginManager,
IPluginContextQueryHandler pluginContextQueryHandler, IPlayerLanguageManager playerLanguageManager,
ICommandManager commandManager)
ICommandManager commandManager, IStringLocalizer localizer)
{
Logger = loggerFactory.CreateLogger("Core");
_scriptHostConfiguration = scriptHostConfiguration;
@@ -62,11 +67,28 @@ namespace CounterStrikeSharp.API.Core
_pluginContextQueryHandler = pluginContextQueryHandler;
_playerLanguageManager = playerLanguageManager;
_commandManager = commandManager;
_localizer = localizer;
_instance = this;
}
public void Start()
{
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
if ((e.ExceptionObject as Exception) is PluginTerminationException pluginEx)
{
return;
}
};
TaskScheduler.UnobservedTaskException += (sender, e) =>
{
if (e.Exception.InnerExceptions.Any(ex => ex is PluginTerminationException))
{
e.SetObserved();
}
};
Logger.LogInformation("CounterStrikeSharp is starting up...");
_coreConfig.Load();
@@ -106,13 +128,13 @@ namespace CounterStrikeSharp.API.Core
[RequiresPermissions("@css/generic")]
private void OnCSSCommand(CCSPlayerController? caller, CommandInfo info)
{
var currentVersion = Api.GetVersion();
var versionString = $"v{Api.GetVersion()} ({Api.GetVersionString()})";
info.ReplyToCommand(
" CounterStrikeSharp was created and is maintained by Michael \"roflmuffin\" Wilson.\n" +
" Counter-Strike Sharp uses code borrowed from SourceMod, Source.Python, FiveM, Saul Rennison, source2gen and CS2Fixes.\n" +
" See ACKNOWLEDGEMENTS.md for more information.\n" +
" Current API Version: " + currentVersion);
" Current API Version: " + versionString);
return;
}
@@ -122,120 +144,135 @@ namespace CounterStrikeSharp.API.Core
switch (info.GetArg(1))
{
case "list":
{
info.ReplyToCommand(
$" List of all plugins currently loaded by CounterStrikeSharp: {_pluginManager.GetLoadedPlugins().Count()} plugins loaded.");
foreach (var plugin in _pluginManager.GetLoadedPlugins())
{
var sb = new StringBuilder();
sb.AppendFormat(" [#{0}:{1}]: \"{2}\" ({3})", plugin.PluginId,
plugin.State.ToString().ToUpper(), plugin.Plugin.ModuleName,
plugin.Plugin.ModuleVersion);
if (!string.IsNullOrEmpty(plugin.Plugin.ModuleAuthor))
sb.AppendFormat(" by {0}", plugin.Plugin.ModuleAuthor);
if (!string.IsNullOrEmpty(plugin.Plugin.ModuleDescription))
{
sb.Append("\n");
sb.Append(" ");
sb.Append(plugin.Plugin.ModuleDescription);
}
info.ReplyToCommand(sb.ToString());
}
break;
}
case "start":
case "load":
{
if (info.ArgCount < 3)
{
info.ReplyToCommand(
"Valid usage: css_plugins start/load [relative plugin path || absolute plugin path] (e.g \"TestPlugin\", \"plugins/TestPlugin/TestPlugin.dll\")\n");
$" List of all plugins currently loaded by CounterStrikeSharp: {_pluginManager.GetLoadedPlugins().Count()} plugins loaded.");
foreach (var plugin in _pluginManager.GetLoadedPlugins())
{
var sb = new StringBuilder();
sb.AppendFormat(" [#{0}:{1}]: \"{2}\" ({3})", plugin.PluginId,
plugin.State.ToString().ToUpper(), plugin.Plugin?.ModuleName ?? "Unknown",
plugin.Plugin?.ModuleVersion ?? "Unknown");
if (!string.IsNullOrEmpty(plugin.Plugin?.ModuleAuthor))
sb.AppendFormat(" by {0}", plugin.Plugin.ModuleAuthor);
if (!string.IsNullOrEmpty(plugin.Plugin?.ModuleDescription))
{
sb.Append("\n");
sb.Append(" ");
sb.Append(plugin.Plugin.ModuleDescription);
}
if (plugin.State == PluginState.Unloaded && !string.IsNullOrEmpty(plugin.TerminationReason))
{
sb.Append("\n");
sb.AppendFormat(" Termination Reason: {0}", plugin.TerminationReason);
}
info.ReplyToCommand(sb.ToString());
}
break;
}
// If our arugment doesn't end in ".dll" - try and construct a path similar to PluginName/PluginName.dll.
// We'll assume we have a full path if we have ".dll".
var path = info.GetArg(2);
if (!path.EndsWith(".dll"))
case "start":
case "load":
{
path = Path.Combine(_scriptHostConfiguration.RootPath, $"plugins/{path}/{path}.dll");
}
else
{
path = Path.Combine(_scriptHostConfiguration.RootPath, path);
}
var plugin = _pluginContextQueryHandler.FindPluginByModulePath(path);
if (plugin == null)
{
try
if (info.ArgCount < 3)
{
_pluginManager.LoadPlugin(path);
info.ReplyToCommand(
"Valid usage: css_plugins start/load [relative plugin path || absolute plugin path] (e.g \"TestPlugin\", \"plugins/TestPlugin/TestPlugin.dll\")\n");
break;
}
catch (Exception e)
{
info.ReplyToCommand($"Could not load plugin \"{path}\"");
Logger.LogError(e, "Could not load plugin \"{Path}\"", path);
}
}
else
{
plugin.Load(false);
}
break;
}
// If our argument doesn't end in ".dll" - try and construct a path similar to PluginName/PluginName.dll.
// We'll assume we have a full path if we have ".dll".
var path = info.GetArg(2);
path = Path.Combine(
_scriptHostConfiguration.RootPath,
!path.EndsWith(".dll")
? $"plugins/{path}/{Path.GetFileName(path)}.dll"
: path
);
var plugin = _pluginContextQueryHandler.FindPluginByModulePath(path);
if (plugin == null)
{
try
{
_pluginManager.LoadPlugin(path);
plugin = _pluginContextQueryHandler.FindPluginByModulePath(path);
plugin.Plugin.OnAllPluginsLoaded(false);
}
catch (Exception e)
{
info.ReplyToCommand($"Could not load plugin \"{path}\"");
Logger.LogError(e, "Could not load plugin \"{Path}\"", path);
}
}
else
{
plugin.Load(false);
plugin.Plugin.OnAllPluginsLoaded(false);
}
break;
}
case "stop":
case "unload":
{
if (info.ArgCount < 3)
{
info.ReplyToCommand(
"Valid usage: css_plugins stop/unload [plugin name || #plugin id] (e.g \"TestPlugin\", \"1\")\n");
if (info.ArgCount < 3)
{
info.ReplyToCommand(
"Valid usage: css_plugins stop/unload [plugin name || #plugin id] (e.g \"TestPlugin\", \"1\")\n");
break;
}
var pluginIdentifier = info.GetArg(2);
string path;
path = Path.Combine(_scriptHostConfiguration.RootPath,
!pluginIdentifier.EndsWith(".dll") ? $"plugins/{pluginIdentifier}/{pluginIdentifier}.dll" : pluginIdentifier);
var plugin = _pluginContextQueryHandler.FindPluginByIdOrName(pluginIdentifier)
?? _pluginContextQueryHandler.FindPluginByModulePath(path);
if (plugin == null)
{
info.ReplyToCommand($"Could not unload plugin \"{pluginIdentifier}\"");
break;
}
plugin.Unload(false);
break;
}
var pluginIdentifier = info.GetArg(2);
IPluginContext? plugin = _pluginContextQueryHandler.FindPluginByIdOrName(pluginIdentifier);
if (plugin == null)
{
info.ReplyToCommand($"Could not unload plugin \"{pluginIdentifier}\"");
break;
}
plugin.Unload(false);
break;
}
case "restart":
case "reload":
{
if (info.ArgCount < 3)
{
info.ReplyToCommand(
"Valid usage: css_plugins restart/reload [plugin name || #plugin id] (e.g \"TestPlugin\", \"#1\")\n");
if (info.ArgCount < 3)
{
info.ReplyToCommand(
"Valid usage: css_plugins restart/reload [plugin name || #plugin id] (e.g \"TestPlugin\", \"#1\")\n");
break;
}
var pluginIdentifier = info.GetArg(2);
var plugin = _pluginContextQueryHandler.FindPluginByIdOrName(pluginIdentifier);
if (plugin == null)
{
info.ReplyToCommand($"Could not reload plugin \"{pluginIdentifier}\"");
break;
}
plugin.Unload(true);
plugin.Load(true);
plugin.Plugin.OnAllPluginsLoaded(true);
break;
}
var pluginIdentifier = info.GetArg(2);
var plugin = _pluginContextQueryHandler.FindPluginByIdOrName(pluginIdentifier);
if (plugin == null)
{
info.ReplyToCommand($"Could not reload plugin \"{pluginIdentifier}\"");
break;
}
plugin.Unload(true);
plugin.Load(true);
break;
}
default:
info.ReplyToCommand("Valid usage: css_plugins [option]\n" +
" list - List all plugins currently loaded.\n" +
@@ -245,7 +282,7 @@ namespace CounterStrikeSharp.API.Core
break;
}
}
private void OnLangCommand(CCSPlayerController? player, CommandInfo command)
{
if (player == null) return;
@@ -301,4 +338,4 @@ namespace CounterStrikeSharp.API.Core
});
}
}
}
}

View File

@@ -0,0 +1,9 @@
using System;
namespace CounterStrikeSharp.API.Core.Attributes.Registration;
[AttributeUsage(AttributeTargets.Method)]
public class ListenerHandlerAttribute<T> : Attribute
where T: Delegate
{
}

View File

@@ -30,6 +30,7 @@ using CounterStrikeSharp.API.Modules.Timers;
using CounterStrikeSharp.API.Modules.Config;
using CounterStrikeSharp.API.Modules.Cvars;
using CounterStrikeSharp.API.Modules.Entities;
using CounterStrikeSharp.API.Modules.UserMessages;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
@@ -52,20 +53,27 @@ namespace CounterStrikeSharp.API.Core
public abstract string ModuleName { get; }
public abstract string ModuleVersion { get; }
public virtual string ModuleAuthor { get; }
public virtual string ModuleDescription { get; }
public string ModulePath { get; set; }
public string ModuleDirectory => Path.GetDirectoryName(ModulePath);
public ILogger Logger { get; set; }
public ICommandManager CommandManager { get; set; }
public IStringLocalizer Localizer { get; set; }
internal Plugin.ISelfPluginControl SelfControl { get; set; }
public void TerminateSelf(string reason)
{
SelfControl?.TerminateSelf(reason);
}
public virtual void Load(bool hotReload)
{
}
@@ -74,6 +82,10 @@ namespace CounterStrikeSharp.API.Core
{
}
public virtual void OnAllPluginsLoaded(bool hotReload)
{
}
public class CallbackSubscriber : IDisposable
{
private Delegate _underlyingMethod;
@@ -112,15 +124,9 @@ namespace CounterStrikeSharp.API.Core
public readonly Dictionary<Delegate, CallbackSubscriber> Handlers =
new Dictionary<Delegate, CallbackSubscriber>();
public readonly Dictionary<Delegate, CallbackSubscriber> CommandHandlers =
new Dictionary<Delegate, CallbackSubscriber>();
public readonly Dictionary<Delegate, CallbackSubscriber> CommandListeners =
new Dictionary<Delegate, CallbackSubscriber>();
public readonly Dictionary<Delegate, CallbackSubscriber> ConvarChangeHandlers =
new Dictionary<Delegate, CallbackSubscriber>();
public readonly Dictionary<Delegate, CallbackSubscriber> Listeners =
new Dictionary<Delegate, CallbackSubscriber>();
@@ -130,8 +136,10 @@ namespace CounterStrikeSharp.API.Core
internal readonly Dictionary<Delegate, EntityIO.EntityOutputCallback> EntitySingleOutputHooks =
new Dictionary<Delegate, EntityIO.EntityOutputCallback>();
public readonly List<CommandDefinition> CommandDefinitions = new List<CommandDefinition>();
public readonly List<Timer> Timers = new List<Timer>();
public delegate HookResult GameEventHandler<T>(T @event, GameEventInfo info) where T : GameEvent;
private void RegisterEventHandlerInternal<T>(string name, GameEventHandler<T> handler, bool post)
@@ -156,6 +164,22 @@ namespace CounterStrikeSharp.API.Core
RegisterEventHandlerInternal(name, handler, hookMode == HookMode.Post);
}
/// <summary>
/// De-registers a game event handler.
/// </summary>
/// <inheritdoc cref="RegisterEventHandler{T}"/>
public void DeregisterEventHandler<T>(GameEventHandler<T> handler, HookMode hookMode = HookMode.Post) where T : GameEvent
{
var name = typeof(T).GetCustomAttribute<EventNameAttribute>()!.Name;
if (!Handlers.TryGetValue(handler, out var subscriber)) return;
NativeAPI.UnhookEvent(name, subscriber.GetInputArgument(), hookMode == HookMode.Post);
FunctionReference.Remove(subscriber.GetReferenceIdentifier());
Handlers.Remove(handler);
}
[Obsolete("Use the generic version of this method")]
public void DeregisterEventHandler(string name, Delegate handler, bool post)
{
if (!Handlers.TryGetValue(handler, out var subscriber)) return;
@@ -175,14 +199,22 @@ namespace CounterStrikeSharp.API.Core
public void AddCommand(string name, string description, CommandInfo.CommandCallback handler)
{
var definition = new CommandDefinition(name, description, handler);
CommandManager.RegisterCommand(definition);
}
private void AddCommand(CommandDefinition definition)
{
CommandDefinitions.Add(definition);
CommandManager.RegisterCommand(definition);
}
private void AddCommand(CommandDefinition definition)
{
CommandDefinitions.Add(definition);
CommandManager.RegisterCommand(definition);
}
/// <summary>
/// Adds a command listener which will be called before or after the command is executed on the server by a player.
/// </summary>
/// <param name="name">Name of the command, e.g. `jointeam`</param>
/// <param name="handler">Code to run when command is executed. Return <see cref="HookResult.Handled"/> or higher to prevent command execution.</param>
/// <param name="mode">Whether to hook before or after the command is executed.</param>
public void AddCommandListener(string? name, CommandInfo.CommandListenerCallback handler, HookMode mode = HookMode.Pre)
{
var wrappedHandler = new Func<int, IntPtr, HookResult>((i, ptr) =>
@@ -198,19 +230,27 @@ namespace CounterStrikeSharp.API.Core
CommandListeners[handler] = subscriber;
}
/// <summary>
/// Removes a server command.
/// </summary>
/// <param name="name">The name of the command.</param>
/// <param name="handler">The callback function to be invoked when the command is executed.</param>
public void RemoveCommand(string name, CommandInfo.CommandCallback handler)
{
if (CommandHandlers.ContainsKey(handler))
var definition = CommandDefinitions.FirstOrDefault(
definition => definition.Name == name && definition.Callback == handler);
if (definition != null)
{
var subscriber = CommandHandlers[handler];
NativeAPI.RemoveCommand(name, subscriber.GetInputArgument());
FunctionReference.Remove(subscriber.GetReferenceIdentifier());
CommandHandlers.Remove(handler);
CommandDefinitions.Remove(definition);
CommandManager.RemoveCommand(definition);
}
}
/// <summary>
/// Remove a command listener.
/// </summary>
/// <inheritdoc cref="AddCommandListener"/>
public void RemoveCommandListener(string name, CommandInfo.CommandListenerCallback handler, HookMode mode)
{
if (CommandListeners.ContainsKey(handler))
@@ -224,39 +264,24 @@ namespace CounterStrikeSharp.API.Core
}
}
/*
public void HookConVarChange(ConVar convar, ConVar.ConVarChangedCallback handler)
{
var wrappedHandler = new Action<IntPtr, string, string>((ptr, oldVal, newVal) =>
{
handler?.Invoke(new ConVar(ptr), oldVal, newVal);
});
var subscriber = new CallbackSubscriber(convar, handler, wrappedHandler);
NativeAPI.HookConvarChange(convar.Handle, subscriber.GetInputArgument());
ConvarChangeHandlers[handler] = subscriber;
}
public void UnhookConVarChange(ConVar convar, ConVar.ConVarChangedCallback handler)
{
if (ConvarChangeHandlers.ContainsKey(handler))
{
var subscriber = ConvarChangeHandlers[handler];
NativeAPI.UnhookConvarChange(convar.Handle, subscriber.GetInputArgument());
FunctionReference.Remove(subscriber.GetReferenceIdentifier());
CommandHandlers.Remove(handler);
}
}*/
// Adds global listener, e.g. OnTick, OnClientConnect
/// <summary>
/// Registers a global listener, e.g. <see cref="Listeners.OnTick"/>, <see cref="Listeners.OnClientConnect"/>.
/// </summary>
/// <param name="handler"></param>
/// <typeparam name="T">Listener delegate type</typeparam>
/// <exception cref="ArgumentException">Invalid listener <see cref="T"/> provided</exception>
/// <example>
/// <code lang="C#">
/// RegisterListener&lt;Listeners.OnTick&gt;(OnTick);
/// </code>
/// </example>
public void RegisterListener<T>(T handler) where T : Delegate
{
var listenerName = typeof(T).GetCustomAttribute<ListenerNameAttribute>()?.Name;
if (string.IsNullOrEmpty(listenerName))
{
throw new Exception("Listener of type T is invalid and does not have a name attribute");
throw new ArgumentException("Listener of type T is invalid and does not have a name attribute",
nameof(T));
}
var parameterTypes = typeof(T).GetMethod("Invoke").GetParameters().Select(p => p.ParameterType).ToArray();
@@ -287,6 +312,34 @@ namespace CounterStrikeSharp.API.Core
Listeners[handler] = subscriber;
}
/// <summary>
/// Removes a global listener.
/// </summary>
/// <param name="handler"></param>
/// <typeparam name="T"></typeparam>
/// <exception cref="ArgumentException">Invalid listener <see cref="T"/> provided</exception>
public void RemoveListener<T>(T handler) where T : Delegate
{
var listenerName = typeof(T).GetCustomAttribute<ListenerNameAttribute>()?.Name;
if (string.IsNullOrEmpty(listenerName))
{
throw new ArgumentException("Listener of type T is invalid and does not have a name attribute",
nameof(T));
}
if (!Listeners.TryGetValue(handler, out var subscriber)) return;
NativeAPI.RemoveListener(listenerName, subscriber.GetInputArgument());
FunctionReference.Remove(subscriber.GetReferenceIdentifier());
Listeners.Remove(handler);
}
/// <summary>
/// Removes a global listener.
/// </summary>
/// <param name="name"></param>
/// <param name="handler"></param>
[Obsolete("Use the generic version of this method")]
public void RemoveListener(string name, Delegate handler)
{
if (!Listeners.TryGetValue(handler, out var subscriber)) return;
@@ -296,6 +349,14 @@ namespace CounterStrikeSharp.API.Core
Listeners.Remove(handler);
}
/// <summary>
/// Adds a timer that will call the given callback after the specified amount of seconds.
/// By default will only run once unless the <see cref="TimerFlags.REPEAT"/> flag is set.
/// </summary>
/// <param name="interval">Interval/Delay in seconds</param>
/// <param name="callback">Code to run when timer elapses</param>
/// <param name="flags">Controls if the timer is a one-off, repeat or stops on map change etc.</param>
/// <returns>An instance of the <see cref="Timer"/></returns>
public Timer AddTimer(float interval, Action callback, TimerFlags? flags = null)
{
var timer = new Timer(interval, callback, flags ?? 0);
@@ -303,7 +364,11 @@ namespace CounterStrikeSharp.API.Core
return timer;
}
/// <summary>
/// Registers all attribute handlers on the given instance.
/// Can be used to register event handlers, console commands, entity outputs etc. from classes that are not derived from `BasePlugin`.
/// </summary>
/// <param name="instance"></param>
public void RegisterAllAttributes(object instance)
{
this.RegisterAttributeHandlers(instance);
@@ -338,20 +403,26 @@ namespace CounterStrikeSharp.API.Core
}
/// <summary>
/// Registers all game event handlers that are decorated with the `[GameEventHandler]` attribute.
/// Registers all game event handlers that are decorated with the <see cref="GameEventHandlerAttribute"/> and <see cref="ListenerHandlerAttribute{T}"/> attribute.
/// </summary>
/// <param name="instance">The instance of the object where the event handlers are defined.</param>
public void RegisterAttributeHandlers(object instance)
{
var eventHandlers = instance.GetType()
.GetMethods()
var methods = instance.GetType().GetMethods();
var eventHandlers = methods
.Where(method => method.GetCustomAttribute<GameEventHandlerAttribute>() != null)
.Where(method =>
method.GetParameters().FirstOrDefault()?.ParameterType.IsSubclassOf(typeof(GameEvent)) == true)
.ToArray();
var method = typeof(BasePlugin).GetMethod("RegisterEventHandlerInternal", BindingFlags.NonPublic |
var listenerHandlers = methods
.Where(method => method.GetCustomAttribute(typeof(ListenerHandlerAttribute<>)) != null)
.ToArray();
var registerEvent = typeof(BasePlugin).GetMethod(nameof(RegisterEventHandlerInternal), BindingFlags.NonPublic |
BindingFlags.Instance)!;
var registerListener = GetType().GetMethod(nameof(RegisterListener))!;
foreach (var eventHandler in eventHandlers)
{
@@ -363,11 +434,29 @@ namespace CounterStrikeSharp.API.Core
var actionType = typeof(GameEventHandler<>).MakeGenericType(parameterType);
var action = Delegate.CreateDelegate(actionType, instance, eventHandler);
var generic = method.MakeGenericMethod(parameterType);
generic.Invoke(this, new object[] { eventName, action, hookMode == HookMode.Post });
var registerEventGeneric = registerEvent.MakeGenericMethod(parameterType);
registerEventGeneric.Invoke(this, [eventName, action, hookMode == HookMode.Post]);
}
foreach (var listnerHandler in listenerHandlers)
{
var attribute = listnerHandler.GetCustomAttribute(typeof(ListenerHandlerAttribute<>))!;
var listenerType = attribute.GetType().GetGenericArguments().First();
if (listenerType.GetCustomAttribute<ListenerNameAttribute>() == null)
throw new ArgumentException("Listener of type T is invalid and does not have a name attribute",
listenerType.Name);
var listenerDelegate = Delegate.CreateDelegate(listenerType, instance, listnerHandler);
registerListener.MakeGenericMethod(listenerType).Invoke(this, [listenerDelegate]);
}
}
/// <summary>
/// Registers all console command handlers that are decorated with the <see cref="ConsoleCommandAttribute"/> attribute.
/// </summary>
/// <param name="instance">The instance of the object where the console command handlers are defined.</param>
public void RegisterConsoleCommandAttributeHandlers(object instance)
{
var eventHandlers = instance.GetType()
@@ -395,6 +484,10 @@ namespace CounterStrikeSharp.API.Core
}
}
/// <summary>
/// Registers all entity output handlers that are decorated with the <see cref="EntityOutputHookAttribute"/> attribute.
/// </summary>
/// <param name="instance">The instance of the object where entity output hook handlers are defined.</param>
public void RegisterEntityOutputAttributeHandlers(object instance)
{
var handlers = instance.GetType()
@@ -416,29 +509,29 @@ namespace CounterStrikeSharp.API.Core
{
var convars = type
.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)
.Where(prop => prop.FieldType.IsGenericType &&
.Where(prop => prop.FieldType.IsGenericType &&
prop.FieldType.GetGenericTypeDefinition() == typeof(FakeConVar<>));
foreach (var prop in convars)
{
object propValue = prop.GetValue(instance); // FakeConvar<?> instance
var propValueType = prop.FieldType.GenericTypeArguments[0];
var name = prop.FieldType.GetProperty("Name", BindingFlags.Public | BindingFlags.Instance)
.GetValue(propValue);
var description = prop.FieldType.GetProperty("Description", BindingFlags.Public | BindingFlags.Instance)
.GetValue(propValue);
MethodInfo executeCommandMethod = prop.FieldType
.GetMethod("ExecuteCommand", BindingFlags.Instance | BindingFlags.NonPublic);
this.AddCommand((string)name, (string) description, (caller, command) =>
this.AddCommand((string)name, (string)description, (caller, command) =>
{
executeCommandMethod.Invoke(propValue, new object[] {caller, command});
executeCommandMethod.Invoke(propValue, new object[] { caller, command });
});
}
}
/// <summary>
/// Used to bind a fake ConVar to a plugin command. Only required for ConVars that are not public properties of the plugin class.
/// </summary>
@@ -449,6 +542,12 @@ namespace CounterStrikeSharp.API.Core
RegisterFakeConVars(instance.GetType(), instance);
}
/// <summary>
/// Hooks an <a href="https://developer.valvesoftware.com/wiki/Inputs_and_Outputs">entity output</a>.
/// </summary>
/// <param name="classname">Classname to hook, or `*` for wildcard</param>
/// <param name="outputName">Output name to hook, or `*` for wildcard</param>
/// <param name="handler">Handler to call</param>
public void HookEntityOutput(string classname, string outputName, EntityIO.EntityOutputHandler handler, HookMode mode = HookMode.Pre)
{
var subscriber = new CallbackSubscriber(handler, handler,
@@ -458,6 +557,28 @@ namespace CounterStrikeSharp.API.Core
EntityOutputHooks[handler] = subscriber;
}
public void HookUserMessage(int messageId, UserMessage.UserMessageHandler handler, HookMode mode = HookMode.Pre)
{
var subscriber = new CallbackSubscriber(handler, handler,
() => UnhookUserMessage(messageId, handler));
NativeAPI.HookUsermessage(messageId, subscriber.GetInputArgument(), mode);
Handlers[handler] = subscriber;
}
public void UnhookUserMessage(int messageId, UserMessage.UserMessageHandler handler, HookMode mode = HookMode.Pre)
{
if (!Handlers.TryGetValue(handler, out var subscriber)) return;
NativeAPI.UnhookUsermessage(messageId, subscriber.GetInputArgument(), mode);
FunctionReference.Remove(subscriber.GetReferenceIdentifier());
Handlers.Remove(handler);
}
/// <summary>
/// Unhooks an entity output.
/// </summary>
/// <inheritdoc cref="HookEntityOutput"/>
public void UnhookEntityOutput(string classname, string outputName, EntityIO.EntityOutputHandler handler, HookMode mode = HookMode.Pre)
{
if (!EntityOutputHooks.TryGetValue(handler, out var subscriber)) return;
@@ -467,6 +588,12 @@ namespace CounterStrikeSharp.API.Core
EntityOutputHooks.Remove(handler);
}
/// <summary>
/// Hooks an entity output for a single entity instance.
/// </summary>
/// <param name="entityInstance">Entity instance to hook</param>
/// <param name="outputName">Output name to hook, or `*` for wildcard</param>
/// <param name="handler">Handler to call</param>
public void HookSingleEntityOutput(CEntityInstance entityInstance, string outputName, EntityIO.EntityOutputHandler handler)
{
// since we wrap around the plugin handler we need to do this to ensure that the plugin callback is only called
@@ -490,6 +617,10 @@ namespace CounterStrikeSharp.API.Core
EntitySingleOutputHooks[handler] = new EntityIO.EntityOutputCallback(entityInstance.DesignerName, outputName, internalHandler);
}
/// <summary>
/// Unhooks an entity output for a single entity instance.
/// </summary>
/// <inheritdoc cref="HookSingleEntityOutput"/>
public void UnhookSingleEntityOutput(CEntityInstance entityInstance, string outputName, EntityIO.EntityOutputHandler handler)
{
UnhookSingleEntityOutputInternal(entityInstance.DesignerName, outputName, handler);
@@ -518,20 +649,11 @@ namespace CounterStrikeSharp.API.Core
subscriber.Dispose();
}
foreach (var subscriber in CommandHandlers.Values)
{
subscriber.Dispose();
}
foreach (var subscriber in CommandListeners.Values)
{
subscriber.Dispose();
}
foreach (var kv in ConvarChangeHandlers)
{
}
foreach (var subscriber in Listeners.Values)
{
subscriber.Dispose();
@@ -542,6 +664,11 @@ namespace CounterStrikeSharp.API.Core
subscriber.Dispose();
}
foreach (var definition in CommandDefinitions)
{
CommandManager.RemoveCommand(definition);
}
foreach (var timer in Timers)
{
timer.Kill();
@@ -550,4 +677,4 @@ namespace CounterStrikeSharp.API.Core
_disposed = true;
}
}
}
}

View File

@@ -0,0 +1,25 @@
namespace CounterStrikeSharp.API.Core.Capabilities;
public static class Capabilities
{
public static void RegisterPluginCapability<T>(PluginCapability<T> capability, Func<T> supplier)
{
if (!PluginCapability<T>.Providers.ContainsKey(capability.Name))
{
PluginCapability<T>.Providers.Add(capability.Name, new());
}
PluginCapability<T>.Providers[capability.Name].Add(supplier);
}
public static void RegisterPlayerCapability<T>(PlayerCapability<T> capability,
Func<CCSPlayerController, T> supplier)
{
if (!PlayerCapability<T>.Providers.ContainsKey(capability.Name))
{
PlayerCapability<T>.Providers.Add(capability.Name, new());
}
PlayerCapability<T>.Providers[capability.Name].Add(supplier);
}
}

View File

@@ -0,0 +1,24 @@
using System.Collections.Generic;
namespace CounterStrikeSharp.API.Core.Capabilities;
public sealed class PlayerCapability<T>
{
public string Name { get; }
internal static readonly Dictionary<string, List<Func<CCSPlayerController, T>>> Providers = new();
public PlayerCapability(string name)
{
Name = name;
}
public T? Get(CCSPlayerController entity)
{
foreach (var provider in Providers[Name])
{
return provider(entity);
}
return default;
}
}

Some files were not shown because too many files have changed in this diff Show More