What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

GM Logout

Veviya

New Member
Joined
Apr 20, 2016
Messages
10
Reaction score
0
Put together a quick plugin that will send you a email, and then log you out on GM detection.

Code:
using System;
using System.Drawing;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;
using System.Net.Mail;
using System.Text;

namespace DefaultNameSpace
{
    public class DefaultClass : Core
    {
        // If you don't want the client to be terminated on GM Detection set this to false.
        bool TerminateClient = true;
        
        //Set your email inside of the " ", has to be gmail
        string yourEmail = "[email protected]";

        public void sendEmail()
        {
            string DateTime = System.DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss");
            SmtpClient client = new SmtpClient();
            client.Port = 25;
            //restricted stmp, you can only send emails from this relay to Gmail accounts.
            client.Host = "aspmx.l.google.com";
            client.Timeout = 10000;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            //sender, your email, Subject, body
            MailMessage message = new MailMessage("[email protected]", yourEmail, "GM Detection", "Detected GM at: " + DateTime);
            message.BodyEncoding = UTF8Encoding.UTF8;
            client.Send(message);
        }

        public void termClient()
        {
            if (TerminateClient == true)
            {
                TerminateGameClient();
            }
        }


        public static string GetPluginAuthor()
        {
            return "Veviya";
        }

        public static string GetPluginVersion()
        {
            return "1.0.0.0";
        }

        public static string GetPluginDescription()
        {
            return "Logs you out on GM Detection";
        }

        bool GMDetected;
        
        //Call on plugin start
        public void PluginRun()
        {
            onFoundGameMaster += FoundGameMaster;
            while (true)
            {
                Thread.Sleep(500);
                if(GMDetected == true)
                {
                    break;
                }
            }
           
        }
        //Call on plugin stop
        public void PluginStop()
        {

        }
       
        public void FoundGameMaster(Creature obj)
        {  
            sendEmail();
            termClient();
            GMDetected = true;   
        }

    }
}

Make sure you enable Generate FoundGameMaster event, under general settings tab on Archebuddy.

Don't forget to change "[email protected]" to your emai address (has to be a gmail email).
You can also disable client termination, by setting TerminateClient to false.

If you have any questions feel free to ask, I didn't have a chance to really test it. (Every time I tried no GM was ever detected on my server :/)
 
Last edited:
Does this log you out if a GM is connected to the current server or just any server? :o
 
I'm not 100% sure on Out's implementation of onFoundGameMaster, but from what I could tell it's most likely when they are detected on your specific server.
 
if you don't need the email you could just set it to close client in settings. Also for this to work you have to set a setting in settings as well to tell it to create the event right? maybe should put that info in the description for the plugin?
 
if you don't need the email you could just set it to close client in settings. Also for this to work you have to set a setting in settings as well to tell it to create the event right? maybe should put that info in the description for the plugin?

Thanks for pointing out the setting thing, when I read the original thread talking about implementing the event I didn't realize there was a setting that had to be enabled. Yeah if you don't need the email portion you can just change the setting to log you out when a gm is detected.

The whole usefulness of the plugin was mainly, if you have archebuddy running all the time and you want to know if there's a issue you can easily get a email. (Gmail alert from phone, pretty useful) Since the email is sent through gmail's open relay you don't have to bother configuring the stmp settings in the plugin or anything complicated, just plop your email in and you're set.

Went ahead and made some small changes, there are two variables at the top of the code now where you insert your email address, and can disable client termination.
 
Back
Top