moar help:D

moar help:D

Postby Warren1001 » 16 Jul 2013, 05:42

I seem to be confusing myself in how this would work out.
So basically, the main problem on Zombie Servers is trying to find the emails to users that hack so they can be banned. They aren't always online when they are going to be banned, which makes it extremely hard. I am making a command that writes all names to a text file when a user joins. I have not yet compiled it and tested it so I have yet to know if it works or not. My current problem is trying to figure out how to make multiple messages appear at once... for instance:
Code: Select all
         foreach (string line in File.ReadAllLines(path1))
         {
            if (line.Contains(message))
            {
               Player.SendMessage(p, line);
            }
         }

On the P.SM, I am wondering how I would make it to where if there were multiple names found (example, someone typed /[command] [part of a name]) and it would show all names that are similar to it. To further explain, we'll use my 3 accounts for example. Let's say I typed /[command] [warren] when all three of my accounts end in some order of numbers. I would like for it to show all 3 users, instead of just the first one that it comes upon.

I haven't tested the command, so if what I'm doing right now works.. then this whole thing was useless. xD
Or if it's impossible... Anyways, is there a way to make it send multiple messages if there are multiple users found?
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: moar help:D

Postby Conor » 18 Jul 2013, 05:11

The usage of the String.Contains method here should work fine for your desired outcome.

If so, once you have compiled and tested, let me know. I will delete this topic <ok>
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: moar help:D

Postby Warren1001 » 18 Jul 2013, 06:10

Conor wrote:The usage of the String.Contains method here should work fine for your desired outcome.

If so, once you have compiled and tested, let me know. I will delete this topic <ok>

Ah, well I have an error... No definition for "p" (p.name) in the Init method...
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: moar help:D

Postby Conor » 18 Jul 2013, 06:48

It's because there is no Player parameter passed through the Init method.

However, I thought you wanted it to add their name on join? If so, this is all you have to do:

Code: Select all
public override void Init()
{
   string Path = "extra/allplayers.txt";

   Player.Joined += (object sender, PlayerEventArgs e) =>
   {
      if (!File.ReadAllText(Path).Contains(e.Player.PublicName))
      {
          File.AppendAllText(Path, Environment.NewLine + e.Player.PublicName);
      }
   };
}


If you do need to access a Player object in the Init method then there are ways to do this. If you explain your problem in more detail I can help you, if needed.
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: moar help:D

Postby Warren1001 » 19 Jul 2013, 00:25

So I've gotten it working etc, but I have a small problem. If I type /[command] warren, my two email usernames 'warren10001@hotmail.com' and 'warren1000001@hotmail.com' show up, but not 'Warren1001'. If I type /[command] Warren, then only 'Warren1001' shows up. How do I make everything written to the text file automatically lowercased?
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: moar help:D

Postby ismellike » 19 Jul 2013, 03:46

if(line.ToLower().Contains(message))
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: moar help:D

Postby Warren1001 » 19 Jul 2013, 04:00

Ty, and one more thing.. how do I make something work for console? x.x I can't remember
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: moar help:D

Postby Warren1001 » 19 Jul 2013, 04:56

Nevermind, I got it :p
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50


Return to Help in Coding

Who is online

Users browsing this forum: No registered users and 4 guests

cron