1. Соблюдайте Правила форума и проявляйте уважение к другим участникам беседы.

Help причины к банам

Тема в разделе 'Кодинг/Собственные решения', создана пользователем Organated, 22 янв 2013.

  1. Organated Гуру

    Сообщения:
    164
    Спасибы:
    14
    Сборка бота GHost:
    GhostOne 1.7 mod by Org-code
    Дата начала использования бота:
    1.89.89
    Всем привет ! Мне не нравиться то что админы банят игроков по самым разным причинам и причины дают от себя. К примеру VASYA BAN REASON- YA TVAYU MAMU EB..... . Короче суть поста можно ли присвоить значения переменной? ( Я не особо силен в C++) Т.е. Чтобы они банили игроков по уже существующим причинам , а не придумывать а свою . Да конечно тупо будет для них писать !BAN VASYA LIVER поэтому вот код нашел на форуме.Не придирайтесь к моим словам просто не знал как выразиться правильней. Да и чтоб бот не банил если они будут свои причины давать

    Код:
     
    if (Reason=="l" || Reason=="leaver")
                Reason = "Leaver";
     
            if (Reason=="i" || Reason =="idiot")
                Reason = "Idiot";
     
            if (Reason=="r")
                Reason = "Rager";
     
            if (Reason=="lag" || Reason == "lagger")
                Reason = "Lagger";
     
            if (Reason=="f" || Reason =="feeder")
                Reason = "Feeder";
     
            if (Reason=="n" || Reason =="noob")
                Reason = "Noob";
             
            if (Reason=="a" || Reason =="afk")
                Reason = "AFK";
     
            if (Reason=="mh" || Reason =="m")
                Reason = "Map Hacker";
  2. rost Гуру

    Сообщения:
    1.258
    Спасибы:
    150
    Сборка бота GHost:
    LtG
    Дата начала использования бота:
    01.11.2010
    Skype:
    Мой статус
    пробни ка так:
    Код:
              if (Reason=="l" || Reason=="leaver")
                Reason = "Leaver";
              else if (Reason=="i" || Reason =="idiot")
                Reason = "Idiot";
              else if (Reason=="r")
                Reason = "Rager";
              else if (Reason=="lag" || Reason == "lagger")
                Reason = "Lagger";
              else  if (Reason=="f" || Reason =="feeder")
                Reason = "Feeder";
              else if (Reason=="n" || Reason =="noob")
                Reason = "Noob";
              else  if (Reason=="a" || Reason =="afk")
                Reason = "AFK";
              else if (Reason=="mh" || Reason =="m")
                Reason = "Map Hacker";
              else
                return HideCommand;
  3. Organated Гуру

    Сообщения:
    164
    Спасибы:
    14
    Сборка бота GHost:
    GhostOne 1.7 mod by Org-code
    Дата начала использования бота:
    1.89.89
    Я попробовал засунуть этот код в game.cpp строка 1630. Попровлял всеравно не то . МБ поможешь.Это сам код
    Код:
    //
                // !ADDBAN
                // !BAN
                // !B
                //
     
                if(!m_GHost->m_ReplaceBanWithWarn)
                if( ( Command == "addban" || Command == "ban" || Command == "b" ) && !Payload.empty( ) && !m_GHost->m_BNETs.empty( ) )
                {
                    if (!CMDCheck(CMD_ban, AdminAccess))
                    {
                        SendChat(player->GetPID(), m_GHost->m_Language->YouDontHaveAccessToThatCommand( ));
                        return HideCommand;
                    }
     
                    // extract the victim and the reason
                    // e.g. "Varlock leaver after dying" -> victim: "Varlock", reason: "leaver after dying"
     
                    string Victim;
                    string Reason;
                    stringstream SS;
                    SS << Payload;
                    SS >> Victim;
     
                    if( !SS.eof( ) )
                    {
                        getline( SS, Reason );
                        string :: size_type Start = Reason.find_first_not_of( " " );
     
                        if( Start != string :: npos )
                            Reason = Reason.substr( Start );
                    }
     
                    if( m_GameLoaded )
                    {
                        string VictimLower = Victim;
                        transform( VictimLower.begin( ), VictimLower.end( ), VictimLower.begin( ), (int(*)(int))tolower );
                        uint32_t Matches = 0;
                        CDBBan *LastMatch = NULL;
     
                        // try to match each player with the passed string (e.g. "Varlock" would be matched with "lock")
                        // we use the m_DBBans vector for this in case the player already left and thus isn't in the m_Players vector anymore
     
                        for( vector<CDBBan *> :: iterator i = m_DBBans.begin( ); i != m_DBBans.end( ); i++ )
                        {
                            string TestName = (*i)->GetName( );
                            transform( TestName.begin( ), TestName.end( ), TestName.begin( ), (int(*)(int))tolower );
     
                            if( TestName.find( VictimLower ) != string :: npos )
                            {
                                Matches++;
                                LastMatch = *i;
                            }
                        }
     
                        if( Matches == 0 )
                            SendAllChat( m_GHost->m_Language->UnableToBanNoMatchesFound( Victim ) );
                        else if( Matches == 1 )
                        {
                            bool isAdmin = IsOwner(LastMatch->GetName());
                            for( vector<CBNET *> :: iterator j = m_GHost->m_BNETs.begin( ); j != m_GHost->m_BNETs.end( ); j++ )
                            {
                                if( (*j)->IsAdmin(LastMatch->GetName() ) || (*j)->IsRootAdmin( LastMatch->GetName() ) )
                                {
                                    isAdmin = true;
                                    break;
                                }
                            }
     
                            if (isAdmin)
                            {
                                SendChat( player->GetPID(), "You can't ban an admin!");
                                return HideCommand;
                            }
     
                            if (IsSafe(LastMatch->GetName()) && m_GHost->m_SafelistedBanImmunity)
                            {
                                SendChat( player->GetPID(), "You can't ban a safelisted player!");
                                return HideCommand;
                            }
     
                            bool isBanned = false;
                            for( vector<CBNET *> :: iterator i = m_GHost->m_BNETs.begin( ); i != m_GHost->m_BNETs.end( ); i++ )
                            {
                                if( (*i)->GetServer( ) == GetCreatorServer( ) )
                                    if ((*i)->IsBannedName(LastMatch->GetName( )))
                                        isBanned = true;
     
                            }
     
                            if (isBanned)
                            {
                                SendChat( player->GetPID(), m_GHost->m_Language->UserIsAlreadyBanned( m_Server, LastMatch->GetName() ));
                                return HideCommand;
                            }
     
                            Reason = CustomReason(Reason, LastMatch->GetName());
     
                            if (m_GHost->m_ReplaceBanWithWarn)
                            {
                                return HideCommand;
                            }
                         
                            uint32_t BanTime = m_GHost->m_BanTime;
                            m_PairedBanAdds.push_back( PairedBanAdd( User, m_GHost->m_DB->ThreadedBanAdd( LastMatch->GetServer(), LastMatch->GetName( ), LastMatch->GetIP( ), m_GameName, User, Reason, BanTime, 0 ) ) );
     
                            uint32_t GameNr = GetGameNr();
     
                            m_GHost->UDPChatSend("|ban "+UTIL_ToString(GameNr)+" "+LastMatch->GetName( ));
                            CONSOLE_Print( "[GAME: " + m_GameName + "] player [" + LastMatch->GetName( ) + "] was banned by player [" + User + "]" );
                         
                            string sBan = m_GHost->m_Language->PlayerWasBannedByPlayer(
                                LastMatch->GetServer(),
                                LastMatch->GetName( )+" ("+LastMatch->GetIP()+")", User, UTIL_ToString(BanTime));
                            string sBReason = sBan + ", "+Reason;
                         
                            if (Reason=="")
                            {
                                SendAllChat( sBan );
                            } else
                            {
                                if (sBReason.length()<220 && !m_GHost->m_TwoLinesBanAnnouncement)
                                    SendAllChat( sBReason );
                                else
                                {
                                    SendAllChat( sBan);
                                    SendAllChat( "Ban reason: " + Reason);
                                }
                            }
                            if (m_GHost->m_NotifyBannedPlayers)
                            {
                                sBReason = "You have been banned";
                                if (Reason!="")
                                    sBReason = sBReason+", "+Reason;
                                for( vector<CBNET *> :: iterator i = m_GHost->m_BNETs.begin( ); i != m_GHost->m_BNETs.end( ); i++ )
                                {
                                    if( (*i)->GetServer( ) == GetCreatorServer( ) )
                                        (*i)->QueueChatCommand( sBReason, LastMatch->GetName(), true );
                                }
                            }
                        }
                        else
                            SendAllChat( m_GHost->m_Language->UnableToBanFoundMoreThanOneMatch( Victim ) );
                    }
                    else
                    {
                        CGamePlayer *LastMatch = NULL;
                        uint32_t Matches = GetPlayerFromNamePartial( Victim, &LastMatch );
     
    //                    if( Matches == 0 )
    //                        SendAllChat( m_GHost->m_Language->UnableToBanNoMatchesFound( Victim ) );
                        if( Matches <= 1 )
                        {
                            string BanPlayer = Victim;
                            if (Matches == 1)
                                BanPlayer = LastMatch->GetName();
                            bool isAdmin = IsOwner(BanPlayer);
                            for( vector<CBNET *> :: iterator j = m_GHost->m_BNETs.begin( ); j != m_GHost->m_BNETs.end( ); j++ )
                            {
                                if((*j)->IsAdmin(BanPlayer ) || (*j)->IsRootAdmin( BanPlayer ) )
                                {
                                    isAdmin = true;
                                    break;
                                }
                            }
     
                            if (isAdmin)
                            {
                                SendChat( player->GetPID(), "You can't ban an admin!");
                                return HideCommand;
                            }
     
                            if (IsSafe(BanPlayer) && m_GHost->m_SafelistedBanImmunity)
                            {
                                SendChat( player->GetPID(), "You can't ban a safelisted player!");
                                return HideCommand;
                            }
     
                            uint32_t BanTime = m_GHost->m_BanTime;
     
                            if (Matches == 1)
                                m_PairedBanAdds.push_back( PairedBanAdd( User, m_GHost->m_DB->ThreadedBanAdd( LastMatch->GetJoinedRealm( ), LastMatch->GetName( ), LastMatch->GetExternalIPString( ), m_GameName, User, Reason, BanTime, 0 ) ) );
                            else
                                m_PairedBanAdds.push_back( PairedBanAdd( User, m_GHost->m_DB->ThreadedBanAdd( m_Server, Victim, "", m_GameName, User, Reason, BanTime, 0 ) ) );
     
                            m_GHost->UDPChatSend("|ban "+Victim);
                            CONSOLE_Print( "[GAME: " + m_GameName + "] player [" + Victim + "] was banned by player [" + User + "]" );
                            string sBan = m_GHost->m_Language->PlayerWasBannedByPlayer(
                                GetCreatorServer(),
                                Victim, User, UTIL_ToString(BanTime));
                            if (Matches == 1)
                                sBan = m_GHost->m_Language->PlayerWasBannedByPlayer(
                                GetCreatorServer(),
                                Victim+" ("+LastMatch->GetExternalIPString()+")", User, UTIL_ToString(BanTime));
                            string sBReason = sBan + ", "+Reason;
     
                            if (Reason=="")
                            {
                                SendAllChat( sBan );
                            } else
                            {
                                if (sBReason.length()<220 && !m_GHost->m_TwoLinesBanAnnouncement)
                                    SendAllChat( sBReason );
                                else
                                {
                                    SendAllChat( sBan);
                                    SendAllChat( "Ban reason: " + Reason);
                                }
                            }
                            if (m_GHost->m_NotifyBannedPlayers)
                            {
                                sBReason = "You have been banned";
                                if (Reason!="")
                                    sBReason = sBReason+", "+Reason;
                                for( vector<CBNET *> :: iterator i = m_GHost->m_BNETs.begin( ); i != m_GHost->m_BNETs.end( ); i++ )
                                {
                                    if( (*i)->GetServer( ) == GetCreatorServer( ) )
                                        (*i)->QueueChatCommand( sBReason, Victim, true );
                                }
                            }
                        }
                        else
                            SendAllChat( m_GHost->m_Language->UnableToBanFoundMoreThanOneMatch( Victim ) );
                    }
                }
    
  4. rost Гуру

    Сообщения:
    1.258
    Спасибы:
    150
    Сборка бота GHost:
    LtG
    Дата начала использования бота:
    01.11.2010
    Skype:
    Мой статус
    Проверяй прям тут на Reason, засунь его прям сюда