ItsMods

Full Version: Server TURN OFF plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Help please.
Is there such a ready script or command:
I write in console server (not the game) command: "shutdown" or "off".
Server print on player HUD that round is last.
And when round is finished - turn off the server (close window with dedicated server) ?

Or if this is not complicated, can anyone make such a plugin?
I think many people would have such a script would be useful.
I do not want to hurt the players on and off the server in the middle of the round.

P.S. Sorry for my bad english please.
(04-03-2013, 03:45)vudik Wrote: [ -> ]Help please.
Is there such a ready script or command:
I write in console server (not the game) command: "shutdown" or "off".
Server print on player HUD that round is last.
And when round is finished - turn off the server (close window with dedicated server) ?

Or if this is not complicated, can anyone make such a plugin?
I think many people would have such a script would be useful.
I do not want to hurt the players on and off the server in the middle of the round.

P.S. Sorry for my bad english please.

For in the game is it !rcon killserver
in the server console is it just: killserver

X-Track
(04-03-2013, 13:04)X-Track Wrote: [ -> ]
(04-03-2013, 03:45)vudik Wrote: [ -> ]Help please.
Is there such a ready script or command:
I write in console server (not the game) command: "shutdown" or "off".
Server print on player HUD that round is last.
And when round is finished - turn off the server (close window with dedicated server) ?

Or if this is not complicated, can anyone make such a plugin?
I think many people would have such a script would be useful.
I do not want to hurt the players on and off the server in the middle of the round.

P.S. Sorry for my bad english please.

For in the game is it !rcon killserver
in the server console is it just: killserver

X-Track

Learn2read.

killserver closes server. He needs to warn players before closing, also write it in console.
I will add code. wait

Code:
unsafe string MW3Console
        {
            get
            {
                IntPtr form = FindWindow("IW5 WinConsole", "Call of Duty: Modern Warfare 3 Dedicated Server");
                IntPtr txtbox = FindWindowEx(form,IntPtr.Zero,"Edit",null);
                IntPtr console = FindWindowEx(form, txtbox, "Edit", null);
                StringBuilder sb = new StringBuilder(9999999);
                int result = SendMessageTimeout(
                  console,
                  0x0D /*WM_GETTEXT*/,
                  9999999,
                  sb,
                  10 /*SMTO_ABORTIFHUNG | SMTO_NOTIMEOUTIFNOTHUNG*/,
                  500,
                  IntPtr.Zero);
                return sb.ToString();
            }
        }

        [DllImport("user32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Ansi)]
        public static extern IntPtr FindWindow(string className, string windowName);
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);

        [DllImport("User32.dll", SetLastError = true)]
        public static extern int SendMessageTimeout(
          IntPtr hWnd,
          uint uMsg,
          uint wParam,
          StringBuilder lParam,
          uint fuFlags,
          uint uTimeout,
          IntPtr lpdwResult);

Then use "
Code:
if(MW3Console == "quitit")
{
foreach(ServerClient c in GetClients())
iprintlnbold(c, "Server will quit in some seconds");
// do wait, threading, stopwatch.... whatever
Environment.Quit(0);
}
Wouldn't MW3Console return the entire server content?
(04-03-2013, 14:12)archit Wrote: [ -> ]Wouldn't MW3Console return the entire server content?

Uh, i forgot. But you can just skip \r\n and get last line.
Thanks a lot for something that is not left unattended.
Even though I have minimal representation of what is done (write plugins for different server), but do not quite understand ...
From the first section of code I Compile an executable file, and the second section of the code I compile a class library?
both parts of the card are for same assembly that is a class library