Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Bad Names Kick Plugin v3.0
#61
Forgot to include the fixed source Tongue here it is!
This for banning
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Addon;

namespace ClassLibrary1
{
    public class Class1 : CPlugin
    {
        string file = "forbidden.txt";
        List<string> fwords = new List<string>();
        public override void OnServerLoad()
        {
            ServerPrint("BadNames Plugin By OzonE V3 -fixed by DidUknowiPwn and master131 Loaded!");
            try
            {

                ServerPrint("Forbidden Names: ");
                refreshwords();
            }
            catch { ServerPrint(file + " not found"); }
        }

        public override void OnPlayerConnect(ServerClient Client)
        {

            string[] cn = Client.Name.Split(' ');
            foreach (string x in cn)
            {
                if (fwords.Contains(x))
                {
                    ServerSay("^1Prevented connection of a ^5Badnamed player!", true);
                    ServerCommand("banclient " + Client.ClientNum);
                }
            }

        }


        public override ChatType OnSay(string Message, ServerClient Client)
        {
            string[] msg = Message.Split(' ');
            try
            {
                if (msg[0] == "!badname" && !fwords.Contains(msg[1]))
                {
                    string old = ReadFile(file);
                    WriteFile(file, old + " " + msg[1]);
                    TellClient(Client.ClientNum, msg[1] + " added.", true);
                    refreshwords();
                    return ChatType.ChatNone;
                }
                if (msg[0] == "!show")
                    printwords();
            }
            catch { ServerSay(file + " File Is Not Found", true); }
            return ChatType.ChatAll;
        }
        void refreshwords()
        {
            try
            {
                string[] words = ReadFile(file).Split(' ');
                foreach (string x in words)
                {
                    ServerPrint(x + "\n");
                    fwords.Add(x);
                }
            }
            catch { ServerPrint(file + " Not Found"); }
        }
        void printwords()
        {
            ServerSay("Forbidden Names: ", true);
            foreach (string x in fwords)
            {
                ServerSay(x, true);
            }
        }

        public string ReadFile(String sFilename) //
        {
            string sContent = "";

            if (File.Exists(sFilename))
            {
                StreamReader myFile = new StreamReader(sFilename, System.Text.Encoding.Default);
                sContent = myFile.ReadToEnd();
                myFile.Close();
            }
            return sContent;
        }
        public void WriteFile(String sFilename, String sLines)
        {
            StreamWriter myFile = new StreamWriter(sFilename);
            myFile.Write(sLines);
            myFile.Close();
        }

    }
}

This is for kicking
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Addon;

namespace ClassLibrary1
{
    public class Class1 : CPlugin
    {
        string file = "forbidden.txt";
        List<string> fwords = new List<string>();
        public override void OnServerLoad()
        {
            ServerPrint("BadNames Plugin By OzonE V3 -fixed by DidUknowiPwn and master131 Loaded!");
            try
            {

                ServerPrint("Forbidden Names: ");
                refreshwords();
            }
            catch { ServerPrint(file + " not found"); }
        }

        public override void OnPlayerConnect(ServerClient Client)
        {

            string[] cn = Client.Name.Split(' ');
            foreach (string x in cn)
            {
                if (fwords.Contains(x))
                {
                    ServerSay("^1Prevented connection of a ^5Badnamed player!", true);
                    ServerCommand("dropclient " + Client.ClientNum);
                }
            }

        }


        public override ChatType OnSay(string Message, ServerClient Client)
        {
            string[] msg = Message.Split(' ');
            try
            {
                if (msg[0] == "!badname" && !fwords.Contains(msg[1]))
                {
                    string old = ReadFile(file);
                    WriteFile(file, old + " " + msg[1]);
                    TellClient(Client.ClientNum, msg[1] + " added.", true);
                    refreshwords();
                    return ChatType.ChatNone;
                }
                if (msg[0] == "!show")
                    printwords();
            }
            catch { ServerSay(file + " File Is Not Found", true); }
            return ChatType.ChatAll;
        }
        void refreshwords()
        {
            try
            {
                string[] words = ReadFile(file).Split(' ');
                foreach (string x in words)
                {
                    ServerPrint(x + "\n");
                    fwords.Add(x);
                }
            }
            catch { ServerPrint(file + " Not Found"); }
        }
        void printwords()
        {
            ServerSay("Forbidden Names: ", true);
            foreach (string x in fwords)
            {
                ServerSay(x, true);
            }
        }

        public string ReadFile(String sFilename) //
        {
            string sContent = "";

            if (File.Exists(sFilename))
            {
                StreamReader myFile = new StreamReader(sFilename, System.Text.Encoding.Default);
                sContent = myFile.ReadToEnd();
                myFile.Close();
            }
            return sContent;
        }
        public void WriteFile(String sFilename, String sLines)
        {
            StreamWriter myFile = new StreamWriter(sFilename);
            myFile.Write(sLines);
            myFile.Close();
        }

    }
}
Reply

#62
Something I noticed is that if I use the !badname command in-game, it doesn't put the bad name on a new line in the restricted.txt. Instead it puts it next to the last name.

For example, if I !badname player1, player2 and player3, it puts them like this:

player1 player2 player3

Instead of like this:

player1
player2
player3

Will this effect how it works?
[Image: tanksignature.jpg]
Reply

#63
That's how writing in a .txt file is normally. Don't know if you can actually make it go by rows...
Do not take life too seriously. You will never get out of it alive.
[Image: UGPjFJa.jpg]
Reply

#64
you can type in a GetServerCFG line and make it for admins to choose whether kicking or banning function is used, i think this is much better than making two plugins.
Reply

#65
(05-04-2012, 06:13)OzonE Wrote: you can type in a GetServerCFG line and make it for admins to choose whether kicking or banning function is used, i think this is much better than making two plugins.

New update coming out xP?
Do not take life too seriously. You will never get out of it alive.
[Image: UGPjFJa.jpg]
Reply

#66
OzonE you think it's possible to edit the plugin so that the names in the forbidden.txt will be broken by a comma and not a space? Because some people have a space in between their names and we can't use the plugin to ban them :L or how about it would be read like this:
Herp
Derp Lerp
Megustaface
so that each line is a new person, is it possible?
Do not take life too seriously. You will never get out of it alive.
[Image: UGPjFJa.jpg]
Reply

#67
Yes I thinks its Possible, Should'nt be so hard.
Reply

#68
can this be used to kick players with $ or & in their name ? as the mod i'm using isn't working propley.

EDIT
nm, it doesn't
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#69
it does'nt?
Reply

#70
(05-13-2012, 12:54)OzonE Wrote: it does'nt?

no, if i have say Gunner$ as a name it doesn't kick, i'm guessing that this is for inputting whole name in like Gunner$ for example rather than looking for an invalid letter as in $.

BRB just gonna test it with latest update of @Nukems.

Nope, seems just looking for a whole name and not individual invalid letters.
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Wink Plugin with !ban !kick and !tampban clemi555 3 4,169 11-09-2013, 09:21
Last Post: clemi555
  AntiNoScope Plugin clemi555 5 4,748 11-08-2013, 19:13
Last Post: clemi555
  [Release] Bunker Plugin 1.3 archit 68 41,581 10-30-2013, 11:59
Last Post: clacki
  Help Modifying plugin maverigh 5 5,672 10-19-2013, 10:29
Last Post: Nekochan
Shocked [Request] Switch plugin axel-le-meilleur 6 5,180 10-19-2013, 06:59
Last Post: iRoNinja
  [Request] Anoying and bad names kicker! Misterio 1 2,477 10-15-2013, 09:41
Last Post: Nekochan
  [Release] Yurio Map Plugin Yurio 101 62,330 09-26-2013, 13:38
Last Post: First_Semyon
Brick [Release] v1.1 ChangeMap/NextMap Plugin without any configuration milchshake 23 18,653 09-23-2013, 13:18
Last Post: SgtLegend
  Help !say Plugin (like the !say from GodPlugin) Hallla 0 2,712 09-13-2013, 09:31
Last Post: Hallla
Rainbow [Release] MW3: Random Weapon Plugin V1 Nekochan 50 33,305 09-11-2013, 15:11
Last Post: EnVi Sweden Rocks

Forum Jump:


Users browsing this thread:
3 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.