summaryrefslogtreecommitdiff
path: root/gmod/play_sound.cpp
diff options
context:
space:
mode:
authorJustSomePwner <crotchyalt@gmail.com>2018-08-30 14:01:54 +0200
committerJustSomePwner <crotchyalt@gmail.com>2018-08-30 14:01:54 +0200
commit7ccb819f867493f8ec202ea3b39c94c198c64584 (patch)
tree94622e61af0ff359e3d6689cf274d74f60b2492a /gmod/play_sound.cpp
parent564d979b79e8a5aaa5014eba0ecd36c61575934f (diff)
first
Diffstat (limited to 'gmod/play_sound.cpp')
-rw-r--r--gmod/play_sound.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/gmod/play_sound.cpp b/gmod/play_sound.cpp
new file mode 100644
index 0000000..7a701ad
--- /dev/null
+++ b/gmod/play_sound.cpp
@@ -0,0 +1,25 @@
+#include "hooks.hpp"
+
+void __fastcall hooks::play_sound( void* ecx_, void*, const char* file ) {
+ static auto play_sound_o = g_csgo.m_surface->get_old_function< decltype( &play_sound ) >( 82 );
+ static auto is_ready = pattern::first_code_match( g_csgo.m_chl.dll( ), xors( "55 8B EC 83 E4 F8 83 EC 08 56 8B 35 00 00 00 00 57 83 BE" ), 0 );
+ static bool was_played = false;
+ static float played_tick = 0.f;
+
+ play_sound_o( ecx_, 0, file );
+
+ if( !g_settings.misc.auto_accept || g_csgo.m_engine( )->IsInGame( ) ) {
+ was_played = false;
+ return;
+ }
+
+ if( strstr( file, xors( "competitive_accept_beep.wav" ) ) && !was_played ) {
+ was_played = true;
+ played_tick = GetTickCount( ) * 0.001f + g_settings.misc.auto_accept_delay;
+ }
+
+ if( was_played && GetTickCount( ) * 0.001f > played_tick ) {
+ reinterpret_cast< void( __cdecl* )( ) >( is_ready )( );
+ was_played = false;
+ }
+} \ No newline at end of file