void RadarHackBlocker::RT_ProcessOnTick ( float const curtime ) { ProcessFilter::HumanAtLeastConnectedOrBot const filter_class; for( PlayerHandler::const_iterator ph ( &filter_class ); ph != PlayerHandler::end (); ph += &filter_class ) { int const index ( ph.GetIndex () ); ClientRadarData * pData ( GetPlayerDataStructByIndex ( index ) ); if( pData->m_last_spotted_status ) { RT_UpdatePlayerData ( *ph ); RT_ProcessEntity ( ph->GetEdict () ); } else { if( curtime > m_next_process ) { RT_UpdatePlayerData ( *ph ); RT_ProcessEntity ( ph->GetEdict () ); } } } if( curtime > m_next_process ) { m_next_process = curtime + 2.0f; } }
void OnGroundHookListener::HookOnGround ( PlayerHandler::const_iterator ph ) { Assert ( Helpers::isValidEdict ( ph->GetEdict () ) ); void* unk ( ph->GetEdict ()->m_pUnk ); HookInfo info ( unk, ConfigManager::GetInstance ()->vfid_mhgroundentity, ( DWORD ) RT_nNetworkStateChanged_m_hGroundEntity ); HookGuard<OnGroundHookListener>::GetInstance ()->VirtualTableHook ( info ); }
void WeaponHookListener::HookWeapon ( PlayerHandler::const_iterator ph ) { LoggerAssert ( Helpers::isValidEdict ( ph->GetEdict () ) ); void* unk ( ph->GetEdict ()->m_pUnk ); HookInfo info_equip ( unk, ConfigManager::GetInstance ()->vfid_weaponequip, ( DWORD ) RT_nWeapon_Equip ); HookInfo info_drop ( unk, ConfigManager::GetInstance ()->vfid_weapondrop, ( DWORD ) RT_nWeapon_Drop ); HookGuard<WeaponHookListener>::GetInstance ()->VirtualTableHook ( info_equip ); HookGuard<WeaponHookListener>::GetInstance ()->VirtualTableHook ( info_drop ); }
//--------------------------------------------------------------------------------- // Purpose: called when the plugin is unpaused (i.e should start executing again) //--------------------------------------------------------------------------------- void CNoCheatZPlugin::UnPause ( void ) { GlobalTimer::GetInstance ()->EnterSection (); Logger::GetInstance ()->Msg<MSG_CONSOLE> ( "Unpausing ..." ); BaseSystem::InitSystems (); BanRequest::GetInstance ()->Init (); NczPlayerManager::GetInstance ()->LoadPlayerManager (); // Mark any present player as PLAYER_CONNECTED SourceSdk::InterfacesProxy::Call_ServerExecute (); SourceSdk::InterfacesProxy::Call_ServerCommand ( "exec nocheatz.cfg\n" ); SourceSdk::InterfacesProxy::Call_ServerExecute (); for( int i ( 1 ); i < MAX_PLAYERS; ++i ) { PlayerHandler::const_iterator ph ( NczPlayerManager::GetInstance ()->GetPlayerHandlerByIndex ( i ) ); if( ph >= SlotStatus::BOT ) { HookEntity ( ph->GetEdict () ); WeaponHookListener::HookWeapon ( ph ); if( ph >= SlotStatus::PLAYER_CONNECTED ) { HookBasePlayer ( ph ); } } } BaseSystem::ManageSystems (); Logger::GetInstance ()->Msg<MSG_CHAT> ( "Plugin unpaused" ); }
void RadarHackBlocker::RT_ThinkPostCallback ( SourceSdk::edict_t const * const pent ) { ProcessFilter::HumanAtLeastConnectedOrBot const filter_class; for( PlayerHandler::const_iterator ph ( &filter_class ); ph != PlayerHandler::end (); ph += &filter_class ) { int const index ( ph.GetIndex () ); ClientRadarData * pData ( GetPlayerDataStructByIndex ( index ) ); if( pData->m_last_spotted_status != m_players_spotted[ index ] ) { pData->m_last_spotted_status = m_players_spotted[ index ]; if( pData->m_last_spotted_status ) { RT_UpdatePlayerData ( *ph ); RT_ProcessEntity ( ph->GetEdict () ); } else { //pData->m_next_update = curtime + 1.0f; //UpdatePlayerData(ph->playerClass); //ProcessEntity(Helpers::PEntityOfEntIndex(x)); } } } }
//--------------------------------------------------------------------------------- // Purpose: called when a client spawns into a server (i.e as they begin to play) //--------------------------------------------------------------------------------- void CNoCheatZPlugin::ClientActive ( SourceSdk::edict_t *pEntity ) { DebugMessage ( Helpers::format ( "CNoCheatZPlugin::ClientActive (%X -> %s)", pEntity, pEntity->GetClassName () ) ); NczPlayerManager::GetInstance ()->ClientActive ( pEntity ); PlayerHandler::const_iterator ph ( NczPlayerManager::GetInstance ()->GetPlayerHandlerByEdict ( pEntity ) ); if( ph >= SlotStatus::PLAYER_CONNECTED ) HookBasePlayer ( ph ); if( ph >= SlotStatus::BOT ) { WeaponHookListener::HookWeapon ( ph ); HookEntity ( ph->GetEdict () ); } ProcessFilter::HumanAtLeastConnected filter_class; if( NczPlayerManager::GetInstance ()->GetPlayerCount ( &filter_class ) == 1 ) AutoTVRecord::GetInstance ()->SpawnTV (); }
PlayerHandler::const_iterator NczPlayerManager::GetPlayerHandlerByBasePlayer ( void * const BasePlayer ) const { SourceSdk::edict_t * tEdict; for( PlayerHandler::const_iterator it ( PlayerHandler::begin () ); it != PlayerHandler::end (); ++it ) { if( it ) { tEdict = it->GetEdict (); if( Helpers::isValidEdict ( tEdict ) ) { if( tEdict->GetUnknown () == BasePlayer ) return it; } } } return PlayerHandler::end (); }
//--------------------------------------------------------------------------------- // Purpose: called when the plugin is loaded, load the interface we need from the engine //--------------------------------------------------------------------------------- bool CNoCheatZPlugin::Load ( SourceSdk::CreateInterfaceFn _interfaceFactory, SourceSdk::CreateInterfaceFn gameServerFactory ) { GlobalTimer::GetInstance ()->EnterSection (); Logger::GetInstance ()->Msg<MSG_CONSOLE> ( "Loading ..." ); if( !SourceSdk::InterfacesProxy::Load ( gameServerFactory, _interfaceFactory ) ) { Logger::GetInstance ()->Msg<MSG_ERROR> ( "SourceSdk::InterfacesProxy::Load failed" ); return false; } void* pinstance ( SourceSdk::InterfacesProxy::ICvar_FindVar ( "nocheatz_instance" ) ); if( pinstance ) { if( SourceSdk::InterfacesProxy::ConVar_GetBool ( pinstance ) ) { Logger::GetInstance ()->Msg<MSG_ERROR> ( "CNoCheatZPlugin already loaded" ); m_bAlreadyLoaded = true; return false; } Assert ( "Error when testing for multiple instances" && 0 ); } if( !ConfigManager::GetInstance ()->LoadConfig () ) { Logger::GetInstance ()->Msg<MSG_ERROR> ( "ConfigManager::LoadConfig failed" ); return false; } if( SourceSdk::InterfacesProxy::m_game == SourceSdk::CounterStrikeGlobalOffensive ) { ncz_cmd_ptr = new SourceSdk::ConCommand_csgo ( "ncz", BaseSystem::ncz_cmd_fn, "NoCheatZ", FCVAR_DONTRECORD | 1 << 18 ); nocheatz_instance = new SourceSdk::ConVar_csgo ( "nocheatz_instance", "0", FCVAR_DONTRECORD | 1 << 18 ); SourceSdk::ConVar_Register_csgo ( 0 ); } else { // Fix IServerPluginCallbacks vtable, because CSGO added ClientFullyConnect in the middle ... DWORD* vtable ( IFACE_PTR ( this ) ); int id ( 10 ); int const max_id ( 19 ); do { MoveVirtualFunction ( &vtable[ id + 1 ], &vtable[ id ] ); } while( ++id != max_id ); ncz_cmd_ptr = new SourceSdk::ConCommand ( "ncz", BaseSystem::ncz_cmd_fn, "NoCheatZ", FCVAR_DONTRECORD ); nocheatz_instance = new SourceSdk::ConVar ( "nocheatz_instance", "0", FCVAR_DONTRECORD ); SourceSdk::ConVar_Register ( 0 ); } UserMessageHookListener::HookUserMessage (); BaseSystem::InitSystems (); BanRequest::GetInstance ()->Init (); NczPlayerManager::GetInstance ()->LoadPlayerManager (); // Mark any present player as PLAYER_CONNECTED SourceSdk::InterfacesProxy::Call_ServerExecute (); SourceSdk::InterfacesProxy::Call_ServerCommand ( "exec nocheatz.cfg\n" ); SourceSdk::InterfacesProxy::Call_ServerExecute (); for( int i ( 1 ); i < MAX_PLAYERS; ++i ) { PlayerHandler::const_iterator ph ( NczPlayerManager::GetInstance ()->GetPlayerHandlerByIndex ( i ) ); if( ph >= SlotStatus::BOT ) { HookEntity ( ph->GetEdict () ); WeaponHookListener::HookWeapon ( ph ); if( ph >= SlotStatus::PLAYER_CONNECTED ) { HookBasePlayer ( ph ); } } } BaseSystem::ManageSystems (); SourceSdk::InterfacesProxy::ConVar_SetValue<bool> ( nocheatz_instance, true ); Logger::GetInstance ()->Msg<MSG_CHAT> ( "Loaded" ); return true; }
PlayerRunCommandRet EyeAnglesTester::RT_PlayerRunCommandCallback ( PlayerHandler::const_iterator ph, void * const pCmd, void * const old_cmd ) { int const * const flags ( EntityProps::GetInstance ()->GetPropValue<int, PROP_FLAGS> ( ph->GetEdict () ) ); /* FL_FROZEN (1 << 5) FL_ATCONTROLS (1 << 6) */ if( *flags & ( 3 << 5 ) ) return PlayerRunCommandRet::CONTINUE; PlayerRunCommandRet drop_cmd ( PlayerRunCommandRet::CONTINUE ); EyeAngleInfoT* playerData ( GetPlayerDataStructByIndex ( ph.GetIndex () ) ); playerData->x.abs_value = fabs ( playerData->x.value = static_cast< SourceSdk::CUserCmd_csgo* >( pCmd )->viewangles.x ); playerData->y.abs_value = fabs ( playerData->y.value = static_cast< SourceSdk::CUserCmd_csgo* >( pCmd )->viewangles.y ); playerData->z.abs_value = fabs ( playerData->z.value = static_cast< SourceSdk::CUserCmd_csgo* >( pCmd )->viewangles.z ); if( playerData->x.abs_value > 89.0f || playerData->z.abs_value > 1.0f || playerData->y.abs_value > 180.0f ) { if( playerData->ignore_last ) --( playerData->ignore_last ); else drop_cmd = PlayerRunCommandRet::INERT; } if( drop_cmd > PlayerRunCommandRet::CONTINUE ) { if( playerData->x.abs_value > 89.0f ) { ++playerData->x.detectionsCount; if( playerData->x.lastDetectionPrintTime + ANTIFLOOD_LOGGING_TIME < Plat_FloatTime () ) { playerData->x.lastDetectionPrintTime = Plat_FloatTime (); Detection_EyeAngleX pDetection; pDetection.PrepareDetectionData ( playerData ); pDetection.PrepareDetectionLog ( *ph, this ); pDetection.Log (); } } if( playerData->y.abs_value > 180.0f ) { ++playerData->y.detectionsCount; if( playerData->y.lastDetectionPrintTime + ANTIFLOOD_LOGGING_TIME < Plat_FloatTime () ) { playerData->y.lastDetectionPrintTime = Plat_FloatTime (); Detection_EyeAngleY pDetection; pDetection.PrepareDetectionData ( playerData ); pDetection.PrepareDetectionLog ( *ph, this ); pDetection.Log (); } } if( playerData->z.abs_value > 1.0f ) { ++playerData->z.detectionsCount; if( playerData->z.lastDetectionPrintTime + ANTIFLOOD_LOGGING_TIME < Plat_FloatTime () ) { playerData->z.lastDetectionPrintTime = Plat_FloatTime (); Detection_EyeAngleZ pDetection; pDetection.PrepareDetectionData ( playerData ); pDetection.PrepareDetectionLog ( *ph, this ); pDetection.Log (); } } BanRequest::GetInstance ()->AddAsyncBan ( *ph, 0, "Banned by NoCheatZ 4" ); } return drop_cmd; }