Jump to content

SA:MP Custom announce.exe that supports secondary IPs


LFA

Recommended Posts

The default announce.exe doesn't support secondary IPs on Windows. This forces you to run your samp servers on the primary IP if you want them to be on the internet servers list.

 

To use the custom announce.exe simply replace the default announce.exe with the one in the zip.

 

To have TCAdmin replace the exe automatically after the game server is created:

 

  • Place announce.exe in the TCAdmin2\Monitor\Tools folder.
  • Create a custom batch script for the after created event with this script:

copy /y %TCAdminFolder%\Monitor\Tools\announce.exe %ThisService_RootDirectory%

 

.NET 3.5 is required. You already have it installed if you are running v2.

announce.zip

Edited by LFA
Link to comment
Share on other sites

No, I just refresh the page it said Invalid thread. I have no PMs, infractions, or emails. It's pretty typical of them. I would ask why but I don't have the slightest clue on how to contact anyone. And a warning for our other members: SAMP has the most highest fraud rate I've ever seen. The only chargebacks I every got was for SAMP services. We're going to start doing it again with manual processing in the future soon.

Link to comment
Share on other sites

Here you go.

 

    class Program
   {
       static string logname="announce.log";
       static void Main(string[] args)
       {
           var prgName = System.Reflection.Assembly.GetExecutingAssembly().Location;
           var path = new System.IO.FileInfo(prgName).DirectoryName;
           System.IO.Directory.SetCurrentDirectory(path);

           WriteLog("TCAdmin - The Game Hosting Control Panel");
           WriteLog(string.Empty);

           if (File.Exists(logname))
               File.Delete(logname);

           var port = 0;
           if (args.Length == 1 && int.TryParse(args[0], out port))
           {
               var sampver = GetSampVersion();
               WriteLog("SA-MP    : v{0}", sampver);
               var request = (HttpWebRequest)HttpWebRequest.Create(string.Format("http://server.sa-mp.com/{0}/announce/{1}", sampver, port));
               request.ServicePoint.BindIPEndPointDelegate = new BindIPEndPoint(BindIPEndPointCallback);
               request.Referer = "http://Bonus";
               request.UserAgent = "SAMP/0.30";
               request.Accept = "*/*";
               request.ProtocolVersion = new Version("1.0");
               request.KeepAlive = false;
               
               HttpWebResponse response = (HttpWebResponse)request.GetResponse();
               WriteLog("Response : {0}", response.StatusDescription);
           }
           else
           {
               WriteLog("Usage: announce.exe <port>");
               System.Threading.Thread.Sleep(5000);
           }
       }

       public static IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount)
       {
           var config = "server.cfg";
           if (retryCount > 0)
           {
               WriteLog("Error    : Bind to the IP in {0} failed", config);
               return null;
           }

           if (File.Exists(config))
           {
               using (var reader = new StreamReader(new FileStream(config, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
               {
                   var contents = reader.ReadToEnd();
                   var regex = new Regex(@"^[\s]*bind[\s]+(?<bind>\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                   var match = regex.Match(contents);
                   if (match.Success)
                   {
                       WriteLog("Bind     : {0}", match.Groups["bind"].Value);
                       return new IPEndPoint(IPAddress.Parse(match.Groups["bind"].Value), new System.Random().Next(5000, 7000));
                   }
                   else
                       WriteLog("Could not find bind in {0}", config);
               }
           }

           return null;
       }

       public static void WriteLog(string output, params object[] arg)
       {
           Console.WriteLine(output, arg);
           File.AppendAllText(logname, string.Format(output, arg) + "\r\n");
       }

       public static string GetSampVersion()
       {
           var executable = "samp-server.exe";
           if (!File.Exists(executable))
           {
               WriteLog("Error    : {0} does not exist", executable);
               return "0.3.4";
           }

           FileVersionInfo sampver = FileVersionInfo.GetVersionInfo(executable);
           var ver = sampver.FileVersion;
           if (ver.EndsWith(".0"))
               ver = ver.Substring(0, ver.LastIndexOf(".0"));

           return ver;
       }
   }

Link to comment
Share on other sites

  • 9 months later...
  • 2 years later...

Nope, using other IP's than the default is still broken on Windows with the standard SA-MP files (although on Linux it works fine.). Even after all these years and several reports they haven't bothered fixing it. :confused:

 

It's good to see that there is a third party fix for this, although I suppose I don't really need it since I've set SA-MP up to use the primary IP.

Edited by gijs007
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Who's Online   0 Members, 0 Anonymous, 7 Guests (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use