void BanRequest::RT_TimerCallback ( char const * const timer_name ) { BanRequestListT::elem_t* it ( m_requests.GetFirst () ); double const curtime (Tier0::Plat_FloatTime () ); while( it != nullptr ) { PlayerBanRequestT const & v ( it->m_value ); if( v.request_time + m_wait_time < curtime ) { PlayerHandler::iterator ph = SteamGameServer_BSecure () ? g_NczPlayerManager.GetPlayerHandlerBySteamID ( v.steamid ) : g_NczPlayerManager.GetPlayerHandlerByUserId ( v.userid ); if( CanKick () ) { if( ph > SlotStatus::KICK ) // Still connected { g_NczPlayerManager.DeclareKickedPlayer ( ph->GetIndex () ); } BanInternal ( v.ban_time, v.steamid, v.userid, v.kick_message.c_str(), v.ip ); } it = m_requests.Remove ( it ); } else { it = it->m_next; } } if( !CanKick () ) { g_Logger.Msg<MSG_WARNING> ( "BanRequest::RT_TimerCallback : Cannot process async ban because plugin is set to not kick players." ); } }
//--------------------------------------------------------------------------------- // Purpose: called when a client is authenticated //--------------------------------------------------------------------------------- SourceSdk::PLUGIN_RESULT CNoCheatZPlugin::NetworkIDValidated ( const char *pszUserName, const char *pszNetworkID ) { if( !SteamGameServer_BSecure () ) return SourceSdk::PLUGIN_CONTINUE; ValidationTester::GetInstance ()->AddPendingValidation ( pszUserName, pszNetworkID ); return SourceSdk::PLUGIN_CONTINUE; }
void BanRequest::WriteBansIfNeeded () { if( m_do_writeid && m_can_write_ids) { if( SteamGameServer_BSecure () ) { SourceSdk::InterfacesProxy::Call_ServerCommand ( "writeid\n" ); } SourceSdk::InterfacesProxy::Call_ServerCommand ( "writeip\n" ); m_do_writeid = false; } }
void BanRequest::BanInternal ( int ban_time, char const * steam_id, int userid, char const * kick_message, char const * ip ) { if( CanBan () ) { if( cmd_gb_ban ) { // SourceSdk::InterfacesProxy::Call_ServerCommand(Helpers::format("gb_externalBanUser \"%s\" \"%s\" \"%s\" %d minutes \"%s\"\n", gb_admin_id.c_str(), SteamID, gb_reason_id.c_str(), minutes, this->getName())); } if( cmd_sm_ban ) { if( userid == -1 ) { g_Logger.Msg<MSG_WARNING> ( "BanRequest::BanInternal : Bad userid -> Cannot forward to sm_ban command." ); g_Logger.Msg<MSG_HINT> ( "BanRequest::BanInternal : Using sm_addban ..." ); SourceSdk::InterfacesProxy::Call_ServerCommand ( Helpers::format ( "sm_addban %d \"%s\" \"%s\"\n", m_ban_time, steam_id, kick_message ) ); } else { SourceSdk::InterfacesProxy::Call_ServerCommand ( Helpers::format ( "sm_ban #%d %d \"%s\"\n", userid, m_ban_time, kick_message ) ); } SourceSdk::InterfacesProxy::Call_ServerExecute(); KickNow(userid, kick_message); } else { KickNow(userid, kick_message); if (SteamGameServer_BSecure() && steam_id != nullptr) { SourceSdk::InterfacesProxy::Call_ServerCommand(Helpers::format("banid %d %s\n", m_ban_time, steam_id)); } basic_string ip_stripped(ip); ip_stripped.replace(':', '\0'); if (ip_stripped != "0" && ip_stripped != "127.0.0.1" && ip_stripped != "localhost" && ip_stripped[0] != '=') { SourceSdk::InterfacesProxy::Call_ServerCommand(Helpers::format("addip 1440 \"%s\"\n", ip_stripped.c_str())); } } m_do_writeid = true; //} } else if( CanKick () ) { g_Logger.Msg<MSG_WARNING> ( "BanRequest::BanInternal : Plugin is set to not ban. Player will be kicked instead." ); KickNow ( userid, kick_message ); } }
SB_API bool S_CALLTYPE GameServer_BSecure() { return SteamGameServer_BSecure(); }