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." ); } }
bool Knowledge::IsReadyForKick(Position current, Position desired, Vector2D ballPos) { double degThreshold = _wm->var[2] / 10; if(fabs((current.dir - desired.dir) * AngleDeg::RAD2DEG) < degThreshold || (360.0 - fabs((current.dir - desired.dir) * AngleDeg::RAD2DEG)) < degThreshold) { return CanKick(current, ballPos); } else { return 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 ); } }
CTetrisBrick* CreateIBrick(CTetris* tetris) { assert(tetris != nullptr); auto brick = new CTetrisBrick(tetris, 4, 4, 2); brick->ModifyRotation(0, 1, 0, 7); brick->ModifyRotation(0, 1, 1, 7); brick->ModifyRotation(0, 1, 2, 7); brick->ModifyRotation(0, 1, 3, 7); brick->ModifyRotation(1, 0, 2, 7); brick->ModifyRotation(1, 1, 2, 7); brick->ModifyRotation(1, 2, 2, 7); brick->ModifyRotation(1, 3, 2, 7); brick->SetCurRotation(0); brick->CanKick(false); return brick; }
void BanRequest::KickNow (int userid, const char * kick_message ) const { if( CanKick () ) { if( userid == -1 ) { g_Logger.Msg<MSG_ERROR> ( "BanRequest::KickNow : Bad userid" ); } else { // test again the validity, because SM is supposed to kick him before PlayerHandler::iterator ph(g_NczPlayerManager.GetPlayerHandlerByUserId(userid)); if (ph) { g_NczPlayerManager.DeclareKickedPlayer(g_NczPlayerManager.GetPlayerHandlerByUserId(userid).GetIndex()); SourceSdk::InterfacesProxy::Call_ServerCommand(Helpers::format("kickid %d [NoCheatZ 4] %s\n", userid, kick_message)); } } } }
void BanRequest::AddAsyncBan ( NczPlayer* player, int ban_time, const char * kick_message ) { if( CanKick () ) { PlayerBanRequestT req; req.userid = SourceSdk::InterfacesProxy::Call_GetPlayerUserid ( player->GetEdict () ); if( m_requests.Find ( req ) == nullptr ) { req.ban_time = ban_time; req.request_time = Tier0::Plat_FloatTime (); req.kick_message = kick_message; strcpy_s ( req.player_name, 24, player->GetName () ); strcpy_s ( req.steamid, 24, player->GetSteamID () ); strcpy_s ( req.ip, 24, player->GetIPAddress () ); strcpy_s ( req.identity, 64, player->GetReadableIdentity ().c_str () ); m_requests.Add ( req ); } AddTimer ( m_wait_time, player->GetName (), true ); } }