Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8802645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:08:12+00:00 2026-06-14T01:08:12+00:00

I am coding a rcon message tool for a game server in C#. However

  • 0

I am coding a rcon message tool for a game server in C#. However I’ve run across a error:

"The name ‘m’ does not exist in the current context"

By now you’re shouting at your screen NOOB! and yes I admit I am; I have little real coding experience.

I’ve played with MFC C++ and OpenGL and I’m a fairly respected cod modder "script is gsc loosely based on c++" so I hope I can learn quickly, basically I tried to access an instance of b. outside of the main loop but it gave me the error:

The name b does not exist in the current context

so I made a new messages function that started a new connection in a new instance. Then I tried the access that in another function stopmessages() but I still get the error.

Sorry for the newb question. I’ve googled long and hard about this and I just don’t understand.

Here’s my code – it uses Nini.dll for config file access and BattleNET.dll for access to rcon for the game –

#region

using System;
using System.Net;
using System.Text;
using BattleNET;
using Nini.Config;
#endregion



namespace BattleNET_client
{

internal class Program
{
    
   private static  void Main(string[] args)
    {
        bool isit_ok = true;
        
        Console.OutputEncoding = Encoding.UTF8;
        Console.Title = "rotceh_dnih's DayZ servermessages";
        BattlEyeLoginCredentials loginCredentials = GetLoginCredentials();
        Console.Title += string.Format(" - {0}:{1}", loginCredentials.Host, loginCredentials.Port);
        IBattleNET b = new BattlEyeClient(loginCredentials);
        b.MessageReceivedEvent += DumpMessage;
        b.DisconnectEvent += Disconnected;
        b.ReconnectOnPacketLoss(true);
        b.Connect();
        
        while (true)
        {
            startmessages();
            string cmd = Console.ReadLine();

            if (cmd == "exit" || cmd == "logout" || cmd == "quit")
            {
                Environment.Exit(0);
            }

            if (cmd == "restart")
            {
                stopmessages();
            }
            if (cmd == "startstuff")
            {
                startmessages();
            }

            if (b.IsConnected())
            {
                if (isit_ok)
                {
                    
                }
                isit_ok = false;
                b.SendCommandPacket(cmd);
            }
            else
            {
                Console.WriteLine("Not connected!");
            }
        }
    }

    private static BattlEyeLoginCredentials GetLoginCredentials()
    {
       
        IConfigSource source = new IniConfigSource("server/admindets.ini");
        string serverip = source.Configs["rconlogin"].Get("ip");
        int serverport = source.Configs["rconlogin"].GetInt("port");
        string password = source.Configs["rconlogin"].Get("rconpwd");
        var loginCredentials = new BattlEyeLoginCredentials
                                   {
                                       Host = serverip,
                                       Port = serverport,
                                       Password = password,
                                   };          
        return loginCredentials;
    }

   public static void startmessages()
    {
       BattlEyeLoginCredentials loginCredentials = GetLoginCredentials();
        IBattleNET m = new BattlEyeClient(loginCredentials);
        m.MessageReceivedEvent += DumpMessage;
        m.DisconnectEvent += Disconnected;
        m.ReconnectOnPacketLoss(true);
        m.Connect();

        IConfigSource messagesource = new IniConfigSource("messages/servermessages.ini");

        int messagewait = messagesource.Configs["timesettings"].GetInt("delay");
        string[] messages = messagesource.Configs["rconmessages"].Get("messages1").Split('|');
    //    for (;;)
      //  {
      
            foreach (string message in messages)
            {
                Console.WriteLine(message);
                 m.SendCommandPacket(EBattlEyeCommand.Say,message);
                 System.Threading.Thread.Sleep(messagewait * 60 * 1000); 
                
            }
     //   }
       
    }


   public static void stopmessages()
   {
       
       m.Disconnect();
   }


    private static void Disconnected(BattlEyeDisconnectEventArgs args)
    {
        Console.WriteLine(args.Message);
    }

    private static void DumpMessage(BattlEyeMessageEventArgs args)
    {
        Console.WriteLine(args.Message);
    }
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:08:13+00:00Added an answer on June 14, 2026 at 1:08 am

    You need to put the declaration of m into the class scope:

    internal class Program
    {
    
        // declare m as field at class level
        private static IBattleNET m;
    
        private static  void Main(string[] args)
        {
            ....
        }
    
    
        public static void startmessages()
        {
           BattlEyeLoginCredentials loginCredentials = GetLoginCredentials();
    
    
            // JUST SET THE VALUE HERE
            m = new BattlEyeClient(loginCredentials);
            m.MessageReceivedEvent += DumpMessage;
            m.DisconnectEvent += Disconnected;
            m.ReconnectOnPacketLoss(true);
            m.Connect();
    
            IConfigSource messagesource = new IniConfigSource("messages/servermessages.ini");
    
            int messagewait = messagesource.Configs["timesettings"].GetInt("delay");
            string[] messages = messagesource.Configs["rconmessages"].Get("messages1").Split('|');
        //    for (;;)
          //  {
    
                foreach (string message in messages)
                {
                    Console.WriteLine(message);
                     m.SendCommandPacket(EBattlEyeCommand.Say,message);
                     System.Threading.Thread.Sleep(messagewait * 60 * 1000); 
    
                }
         //   }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Coding footer naively, if there's not enough content, then there will be empty space
After coding and testing a Java application (lets say with Eclipse, but not necessarily)
Coding Platform: ASP.NET WebForms4.0 VB Installed Facebook and FacebookWeb and when I run the
This coding i got from here. I get error in log cat view like
When coding in C# I like not to handle exceptions because it makes it
Coding across browsers is one of the most desirable of front-end development skills. What
Coding standards in place mean I do not have an option of using ajax
Im coding in Java.. Does anyone know how i can get the content of
When coding up, say, a registration form from scratch, does it make sense to
In coding a physics-based game, I have created everything from subclassed NSObjects. Force vectors

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.