-- НАДО ЛИНКОВАТЬ С winmm . dll #include unsigned long current_time ( ) { return timeGetTime ( ) ; } void LayersManager :: DelayCall ( unsigned long delay , std :: function fn ) { m_log . Debug ( "New delay call with target %u" , current_time ( ) + delay ) ; m_delayCalls . push_back ( { current_time ( ) + delay , fn } ) ; } void LayersManager :: _OnProcess ( ) { if ( m_lastSave == 0 ) m_lastSave = current_time ( ) ; for ( auto it = m_pressedKeys . begin ( ) ; it != m_pressedKeys . end ( ) ; ++ it ) { // if (it->frames) keybd_event(it->vkey, 0, KEYEVENTF_KEYUP, 0); // else ++it->frames; keybd_event ( it -> vkey , 0 , KEYEVENTF_KEYUP , 0 ) ; // SendMessageA(sampGetWindowHandle(), WM_KEYUP, VK_SHIFT, 0); m_pressedKeys . erase ( it ) ; -- it ; } std :: vector delayCallsCopy = std :: vector ( m_delayCalls ) ; for ( size_t i = 0 ; i = it -> target_time ) { m_log . Debug ( "Delay call %u executed" , it -> target_time ) ; if ( it -> handler ) it -> handler ( ) ; m_delayCalls . erase ( m_delayCalls . begin ( ) + i ) ; } } if ( current_time ( ) - m_lastSave >= 30000 ) { SaveAll ( ) ; m_lastSave = current_time ( ) ; } for ( auto & l : m_processLayers ) l -> Process ( ) ; }
m_log . Debug ( "Local ping: %u" , sampGetLocalPlayerPing ( ) ) ; sampSetGameKeyState ( 14 , 8 ) ; LayersManager :: Get ( ) . DelayCall ( 50 , [ ] ( ) { BitStream bs ; bs . Write ( ( short ) sampGetLocalPlayerID ( ) ) ; bs . Write ( sizeof ( "MISC" ) - 1 ) ; bs . Write ( "MISC" , sizeof ( "MISC" ) - 1 ) ; bs . Write ( sizeof ( "plyr_shkhead" ) - 1 ) ; bs . Write ( "plyr_shkhead" , sizeof ( "plyr_shkhead" ) - 1 ) ; bs . Write ( 4.0f ) ; bs . Write ( false ) ; bs . Write ( true ) ; bs . Write ( true ) ; bs . Write ( true ) ; bs . Write ( 1 ) ; sampEmulateIncomingRPC ( 86 , & bs ) ; LayersManager :: Get ( ) . DelayCall ( 150 , [ ] ( ) { sampSetGameKeyState ( 14 , 8 ) ; } ) ; } ) ;