Skip to content

Commit 2280f55

Browse files
authored
Merge pull request #1 from CS2ModServer/dev
Dev
2 parents 0abf44e + 5a83445 commit 2280f55

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2380
-291
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ bld/
2323
/configs/maplist.cfg
2424
/configs/admins.cfg
2525
/data/infractions.txt
26+
dump
27+
Adventure

CS2Fixes.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.3.32825.248
4+
VisualStudioVersion = 17.12.35707.178
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CS2Fixes", "CS2Fixes.vcxproj", "{2A734041-5881-4EA1-BF05-46F361443AF3}"
77
EndProject
@@ -26,6 +26,6 @@ Global
2626
HideSolutionNode = FALSE
2727
EndGlobalSection
2828
GlobalSection(ExtensibilityGlobals) = postSolution
29-
SolutionGuid = {12C11272-4784-4DD0-A905-B564ECADA421}
29+
SolutionGuid = {B6F3ACAE-5F98-35F2-85C4-16713E0FC2A2}
3030
EndGlobalSection
3131
EndGlobal

CS2Fixes.vcxproj

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@
7373
<PropertyGroup Label="UserMacros" />
7474
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
7575
<TargetName>cs2fixes</TargetName>
76-
<LibraryPath>sdk\lib\public\win64;vendor/funchook/lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
76+
<LibraryPath>sdk\lib\public\win64;vendor/funchook/lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);vendor/nlohmann;vendor</LibraryPath>
7777
<OutDir>$(SolutionDir)/build/package/addons/cs2fixes/bin/win64/</OutDir>
7878
<IntDir>$(SolutionDir)/build/$(ShortProjectName)\$(Platform)\$(Configuration)\</IntDir>
7979
</PropertyGroup>
8080
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
8181
<TargetName>cs2fixes</TargetName>
82-
<LibraryPath>sdk\lib\public\win64;vendor/funchook/lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
82+
<LibraryPath>sdk\lib\public\win64;vendor/nlohmann;vendor/funchook/lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
8383
<OutDir>$(SolutionDir)/package/addons/cs2fixes/bin/win64/</OutDir>
8484
</PropertyGroup>
8585
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -125,7 +125,7 @@
125125
<PrecompiledHeader>NotUsing</PrecompiledHeader>
126126
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
127127
<LanguageStandard>stdcpp20</LanguageStandard>
128-
<AdditionalIncludeDirectories>protobuf/generated;src/utils;src/cs2_sdk;sdk/public;sdk/public/tier0;sdk/game/shared;sdk/game/server;sdk/public/tier1;sdk/public/mathlib;minhook/include;../metamod-source/core;../metamod-source/core/sourcehook;vendor/subhook;vendor/funchook/include;sdk/public/entity2;sdk/public/game/server;sdk/thirdparty/protobuf-3.21.8/src;$(SolutionDir);vendor/funchook/lib;C:/Python312/include;vendor/pybind11/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
128+
<AdditionalIncludeDirectories>protobuf/generated;src/utils;src/cs2_sdk;sdk/public;sdk/public/tier0;sdk/game/shared;sdk/game/server;sdk/public/tier1;sdk/public/mathlib;minhook/include;../metamod-source/core;../metamod-source/core/sourcehook;vendor/subhook;vendor/funchook/include;sdk/public/entity2;sdk/public/game/server;sdk/thirdparty/protobuf-3.21.8/src;$(SolutionDir);vendor/funchook/lib;C:/Python312/include;vendor/pybind11/include;vendor/nlohmann/;%(AdditionalIncludeDirectories);../vendor/nlohmann/;../menu_system/public;../menu_system/public/imenusystem</AdditionalIncludeDirectories>
129129
<UndefinePreprocessorDefinitions>%(UndefinePreprocessorDefinitions)</UndefinePreprocessorDefinitions>
130130
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
131131
<MultiProcessorCompilation>true</MultiProcessorCompilation>
@@ -151,7 +151,7 @@
151151
<PrecompiledHeader>NotUsing</PrecompiledHeader>
152152
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
153153
<LanguageStandard>stdcpp20</LanguageStandard>
154-
<AdditionalIncludeDirectories>protobuf/generated;src/utils;src/cs2_sdk;sdk/public;sdk/public/tier0;sdk/game/shared;sdk/game/server;sdk/public/tier1;sdk/public/mathlib;minhook/include;../metamod-source/core;../metamod-source/core/sourcehook;vendor/subhook;vendor/funchook/include;sdk/public/entity2;sdk/public/game/server;sdk/thirdparty/protobuf-3.21.8/src;$(SolutionDir);vendor/funchook/lib;C:/Python312/include;vendor/pybind11/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
154+
<AdditionalIncludeDirectories>protobuf/generated;src/utils;src/cs2_sdk;sdk/public;sdk/public/tier0;sdk/game/shared;sdk/game/server;sdk/public/tier1;sdk/public/mathlib;minhook/include;../metamod-source/core;../metamod-source/core/sourcehook;vendor/subhook;vendor/funchook/include;sdk/public/entity2;sdk/public/game/server;sdk/thirdparty/protobuf-3.21.8/src;$(SolutionDir);vendor/funchook/lib;C:/Python312/include;vendor/pybind11/include;vendor/nlohmann/;vendor;%(AdditionalIncludeDirectories);../vendor/nlohmann/</AdditionalIncludeDirectories>
155155
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
156156
<UndefinePreprocessorDefinitions>%(UndefinePreprocessorDefinitions)</UndefinePreprocessorDefinitions>
157157
<MultiProcessorCompilation>true</MultiProcessorCompilation>
@@ -163,7 +163,7 @@
163163
<GenerateDebugInformation>true</GenerateDebugInformation>
164164
<EnableUAC>false</EnableUAC>
165165
<AdditionalDependencies>interfaces.lib;mathlib.lib;tier0.lib;tier1.lib;psapi.lib;funchook.lib;distorm.lib;steam_api64.lib;vendor/protobuf-lib/Release/libprotobuf.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
166-
<AdditionalLibraryDirectories>sdk/lib/public/win64;vendor/funchook/lib/Release;/NODEFAULTLIB;%(AdditionalLibraryDirectories);C:/Python312/libs</AdditionalLibraryDirectories>
166+
<AdditionalLibraryDirectories>sdk/lib/public/win64;vendor/funchook/lib/Release;/NODEFAULTLIB;%(AdditionalLibraryDirectories);C:/Python312/libs;vendor/nlohmann/</AdditionalLibraryDirectories>
167167
<ShowProgress>
168168
</ShowProgress>
169169
</Link>
@@ -172,6 +172,7 @@
172172
</PostBuildEvent>
173173
</ItemDefinitionGroup>
174174
<ItemGroup>
175+
<ClCompile Include="src\adventuremenu.cpp" />
175176
<ClCompile Include="src\adventuremod.cpp" />
176177
<ClCompile Include="src\buttonwatch.cpp" />
177178
<ClCompile Include="protobuf\generated\cs_usercmd.pb.cc" />
@@ -226,6 +227,7 @@
226227
<ClCompile Include="src\utils\plat_win.cpp" />
227228
</ItemGroup>
228229
<ItemGroup>
230+
<ClInclude Include="src\adventuremenu.h" />
229231
<ClInclude Include="src\adventuremod.h" />
230232
<ClInclude Include="src\buttonwatch.h" />
231233
<ClInclude Include="src\adminsystem.h" />

CS2Fixes.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@
191191
<ClCompile Include="src\adventuremod.cpp">
192192
<Filter>Source Files</Filter>
193193
</ClCompile>
194+
<ClCompile Include="src\adventuremenu.cpp">
195+
<Filter>Source Files</Filter>
196+
</ClCompile>
194197
</ItemGroup>
195198
<ItemGroup>
196199
<ClInclude Include="src\mempatch.h">
@@ -418,5 +421,8 @@
418421
<ClInclude Include="src\adventuremod.h">
419422
<Filter>Header Files</Filter>
420423
</ClInclude>
424+
<ClInclude Include="src\adventuremenu.h">
425+
<Filter>Header Files</Filter>
426+
</ClInclude>
421427
</ItemGroup>
422428
</Project>

CS2Fixes.vcxproj.user

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
44
<LocalDebuggerCommand>E:/CS2Server\cs2\game\bin\win64\cs2.exe</LocalDebuggerCommand>
5-
<LocalDebuggerCommandArguments>-dedicated -usercon +game_type 0 +game_mode 1 +map de_dust2 -maxplayers_override 64</LocalDebuggerCommandArguments>
5+
<LocalDebuggerCommandArguments>-dedicated</LocalDebuggerCommandArguments>
66
<LocalDebuggerWorkingDirectory>E:/CS2Server\cs2\game\bin\win64</LocalDebuggerWorkingDirectory>
77
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
88
</PropertyGroup>
99
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
1010
<LocalDebuggerCommand>E:/CS2Server\cs2\game\bin\win64\cs2.exe</LocalDebuggerCommand>
11-
<LocalDebuggerCommandArguments>-dedicated -usercon +game_type 0 +game_mode 1 +map de_dust2 -maxplayers_override 64 +login CS2ModServer )+:b9h:S4SZcQuE</LocalDebuggerCommandArguments>
11+
<LocalDebuggerCommandArguments>-insecure -language english -window -dedicated -usercon +game_type 0 +game_mode 1 +map de_dust2 -maxplayers_override 64 +login CS2ModServer )+:b9h:S4SZcQuE</LocalDebuggerCommandArguments>
1212
<LocalDebuggerWorkingDirectory>E:/CS2Server\cs2\game\bin\win64</LocalDebuggerWorkingDirectory>
1313
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
1414
</PropertyGroup>

PyPlugins/SampleEvents.py

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def alog(message: str, callername: bool = True):
1616
pass
1717

1818

19-
#TRISTEN YOU LEFT OFF HERE
19+
2020
try:
2121
from ./tests import dumped_events
2222
except Exception as e:
@@ -27,23 +27,6 @@ def alog(message: str, callername: bool = True):
2727
event_dict_of_dict = dict({})
2828
for k, v in dumped_events.dumped_events.items():
2929
event_dict_of_dict.update(v)
30-
#fake events
31-
'''
32-
"player_hurt":dict({
33-
"userid":"playercontroller",
34-
"userid_pawn":"strict_ehandle",
35-
"attacker":"playercontroller",
36-
"attacker_pawn":"strict_ehandle",
37-
"health":"byte",
38-
"armor":"byte",
39-
"weapon":"string",
40-
"dmg_health":"short",
41-
"dmg_armor":"byte",
42-
"hitgroup":"byte",
43-
}),
44-
'''
45-
event_dict_of_dict.update({"player_hurt_pre":event_dict_of_dict["player_hurt"]})
46-
event_dict_of_dict.update({"player_hurt_post":event_dict_of_dict["player_hurt"]})
4730

4831
class Event(object):
4932
#ev = dict()
@@ -105,14 +88,6 @@ def __init__(self, _event):
10588
alog(traceback.format_exc())
10689
#alog("END\n\n")
10790

108-
events_whitelist = list([
109-
"player_spawn",
110-
"player_shoot",
111-
"player_hurt_pre",
112-
"player_hurt",
113-
"player_hurt_post",
114-
"player_death",
115-
])
11691
empty_events_list = list([])
11792
class SampleEvents:
11893
def __init__(self):
@@ -139,28 +114,6 @@ def player_hurt(self, event):
139114
aPawn = ev["userid_pawn"]
140115
alog("dmg_health is now: " + str(ev["dmg_health"]))
141116
pass
142-
def player_hurt_pre(self, event):
143-
alog("-")
144-
try:
145-
alog("try")
146-
ev = Event(event)
147-
alog("dmg_health was: " + str(ev["dmg_health"]))
148-
ev["dmg_health"] = 99
149-
aPawn = ev["userid_pawn"]
150-
alog("dmg_health is now: " + str(ev["dmg_health"]))
151-
except Exception as e:
152-
alog("exception")
153-
alog(e.message)
154-
alog(e.args)
155-
pass
156-
def player_hurt_post(self, event):
157-
alog("-")
158-
ev = Event(event)
159-
alog("dmg_health was: " + str(ev["dmg_health"]))
160-
ev["dmg_health"] = 99
161-
aPawn = ev["userid_pawn"]
162-
alog("dmg_health is now: " + str(ev["dmg_health"]))
163-
pass
164117
def OnPluginLoad(self, printmymethods: bool = False):
165118
#alog("TEST" + str(dumped_events.dumped_events) + "TEST")
166119

@@ -176,37 +129,3 @@ def OnPluginLoad(self, printmymethods: bool = False):
176129
alog("k: " + str(k) + " v: " + str(v))
177130

178131
pass
179-
def OnPluginUnload(self):
180-
alog("Empty events fired during play: ")
181-
for name in empty_events_list:
182-
alog(str(name))
183-
pass
184-
def _player_spawn(self, ev):
185-
pass
186-
def _player_shoot(self, ev):
187-
pass
188-
def _player_death(self, ev):
189-
pass
190-
def OnGameEvent(self, event):
191-
#alog("pre")
192-
ev = Event(event)
193-
alog(ev["name"])
194-
if (len(ev.__dict__) <= 1):
195-
empty_events_list.append(ev["name"])
196-
elif (ev["name"] in events_whitelist):
197-
temp_method = getattr(self, "_"+ev["name"])
198-
temp_method(self, ev)
199-
#else:
200-
# alog("Ignored event: '" + ev["name"] + "'")
201-
202-
if (ev["name"] == "player_hurt"):
203-
GEKS = Source2Py.GameEventKeySymbol_t("dmg_health")
204-
alog("dmg_health is now: " + str(ev ["dmg_health"]))
205-
event.SetInt(GEKS, 99)
206-
207-
alog("dmg_health finally is: " + str(event.GetInt(GEKS, -1)))
208-
209-
210-
211-
212-

PyPlugins/TestLoadPlugin.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

PyPlugins/pyplugins.ini

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,64 @@
11
# List Python plugins to include here
22

33
#tests/TestLoadPlugin.py
4+
## event 'OnPluginLoad'
5+
## event 'OnPluginUnload'
6+
47
#tests/TestImportsPlugin.py
58
#tests/TestExceptionTracebackPlugin.py
69
#tests/TestLoadAnotherFile.py
7-
tests/TestPlayerHurt.py
8-
#SampleEvents.py
9-
#ManyRaces/AdventureTest.py
10+
11+
#tests/TestPlayerHurt.py
12+
## event 'OnPlayerHurt'
13+
14+
#tests/TestPlayerDeath.py
15+
## event 'OnPlayerDeath'
16+
17+
#tests/TestConnections.py
18+
## event 'OnClientConnected'
19+
## event 'OnClientPutInServer'
20+
## event 'OnClientDisconnect'
21+
22+
#tests/TestPlayerSpawn.py
23+
## event 'OnPlayerSpawn'
24+
## event 'OnPlayerSpawn_post'
25+
26+
#tests/TestPlayerJump.py
27+
## event 'OnPlayerJump'
28+
## event 'OnPlayerLand'
29+
## event 'OnPlayerAirborn'
30+
31+
#tests/TestPlayerInputs.py
32+
## buttons'n'bindings and stuff in here, lets see.
33+
## Check and report button states on player_jump and the following python captures
34+
## python capture 'OnClientCommand' but not as game event
35+
## python capture 'OnClientAbility1' but not as game event
36+
## python capture 'OnClientAbility2' but not as game event
37+
## python capture 'OnClientUltimate' but not as game event
38+
39+
#tests/TestOnAllPluginsLoaded.py
40+
##MenuSystem by Wend4r python interface to CS2Fixes.
41+
##When a player connects UpdatePlayerItems is called by CPP which requests Python to send the players' info
42+
##When a player opens a menu by '!menu' display that info and if stale, update it.
43+
44+
#tests/TestPyMySQL.py
45+
##Check for Database or Add
46+
##Check for Table or Add
47+
##Check for Connecting Player or Add
48+
##Count kills for Player
49+
##Print killcount
50+
51+
52+
Adventure/Adventure.py
53+
54+
55+
###################tests/TestEffects.py
56+
## Here we go, time to make some nifty effects
57+
## playsound
58+
## create sprite
59+
60+
##junk below is old work to pull from while making
61+
##better working examples above
62+
###################SampleEvents.py
63+
###################ManyRaces/AdventureTest.py
64+

PyPlugins/tests/TestConnections.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import Source2Py
2+
import logging, inspect
3+
import traceback
4+
5+
#logging.basicConfig(filename='SampleEvents.log', encoding='utf-8', level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s', datefmt='%H:%M:%S')
6+
logging.basicConfig(filename='tests/TestConnections.log', encoding='utf-8', level=logging.DEBUG, format='[%(asctime)s]%(message)s', datefmt='%H:%M:%S')
7+
log = logging
8+
9+
10+
def alog(message: str, callername: bool = True):
11+
caller = str("")
12+
if (callername):
13+
caller = "[" + str(inspect.stack()[1].function) + "] "
14+
Source2Py.ServerPrint("[TestConnections]" + caller + str(message))
15+
log.info(msg=("[TestConnections]" + caller + str(message)))
16+
pass
17+
18+
alog("START")
19+
class TestConnections:
20+
''' note that python does not need typing in it's method declarations but here it is being used
21+
as a reminder of the incoming type from CPP.
22+
'''
23+
def OnClientConnected(self,
24+
_slot: int,
25+
_name: str,
26+
_xuid: int,
27+
_networkID: str,
28+
_ipAddress: str,
29+
_fake: bool):
30+
#first brush when player connects, no name available yet.
31+
alog("START")
32+
try:
33+
alog("slot: " + str(_slot))
34+
alog(_name + " connected")
35+
alog("xuid: " + str(_xuid))
36+
alog("networkID: " + str(_networkID))
37+
alog("ipAddress: " + str(_ipAddress))
38+
alog("fake: " + str(_fake))
39+
except Exception as e:
40+
alog(e)
41+
alog(traceback.format_exc())
42+
alog("END")
43+
pass
44+
def OnClientPutInServer(self,
45+
_slot: int,
46+
_name: str,
47+
_type: int,
48+
# type values could be:
49+
# 0 - player
50+
# 1 - fake player (bot)
51+
# 2 - unknown
52+
_xuid: int):
53+
alog("START")
54+
try:
55+
alog("slot: " + str(_slot))
56+
alog(_name + " put in server")
57+
alog("type: " + str(_type))
58+
alog("xuid: " + str(_xuid))
59+
except Exception as e:
60+
alog(e)
61+
alog(traceback.format_exc())
62+
alog("END")
63+
pass
64+
def OnClientDisconnect(self,
65+
_slot: int,
66+
_reason: int,
67+
_name: str,
68+
_xuid: int,
69+
_networkID: str):
70+
alog("START")
71+
try:
72+
alog("slot: " + str(_slot))
73+
alog("reason: " + str(_reason))
74+
alog(_name + " disconnected")
75+
alog("xuid: " + str(_xuid))
76+
alog("networkID: " + str(_networkID))
77+
except Exception as e:
78+
alog(e)
79+
alog(traceback.format_exc())
80+
alog("END")
81+
pass
82+

0 commit comments

Comments
 (0)