Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

EO3 Multiple IP's?


IFX
 Share

Recommended Posts

Hello, so basically this is my first question on the Q n A, and I have no idea if it will get read. But here goes. My parents are divorced. And my laptop is the server. So to make it easier on my friends I would like my client to try to connect to one ip, if it cant, then try to connect to another. If both fail, then it will show the error message. 

If anyone can help me with this I would be eternally grateful. Or at least be grateful until the end of the day. 

~IFX
Link to comment
Share on other sites

just wrote this from the top of my head, backup your project and try this:

All client-side

> Go to config.ini and add IP2=[2nd IP here]
>
> Add 'IP2 As String' to the bottom of OptionsRec in modTypes
>
> Add Options.IP2 = GetVar(filename, "Options", "IP2") to the bottom of Sub LoadOptions()
>
> Add Call PutVar(filename, "Options", "IP2", Options.IP2) to the bottom of Sub SaveOptions()
>
> change your ConnectToServer with this one:
>
> ```
>
> Public Function ConnectToServer(Optional i As Long) As Boolean
> Dim Wait As Long
>
>     ' If debug mode, handle error then exit out
>     If Options.Debug = 1 Then On Error GoTo errorhandler
>     
>     ' Check to see if we are already connected, if so just exit
>     If IsConnected Then
>         ConnectToServer = True
>         Exit Function
>     End If
>     
>     Wait = GetTickCount
>     frmMain.Socket.Close
>     frmMain.Socket.Connect
>     
>     SetStatus "Connecting to server 1…"
>     
>     ' Wait until connected or 3 seconds have passed and report the server being down
>     Do While (Not IsConnected) And (GetTickCount <= Wait + 3000)
>         DoEvents
>     Loop
>     
>     ConnectToServer = IsConnected
>     
>     If Not IsConnected then 'try second ip
>         Wait = GetTickCount        
>         frmMain.Socket.Close
>         frmMain.Socket.IP = Options.IP2
>         frmMain.Socket.Connect
>         
>         SetStatus "Connecting to server 2..."
>         
>         ' Wait until connected or 3 seconds have passed and report the server being down
>         Do While (Not IsConnected) And (GetTickCount <= Wait + 3000)
>             DoEvents
>         Loop
>         
>         ConnectToServer = IsConnected
>     End If
>
>     ' Error handler
>     Exit Function
> errorhandler:
>     HandleError "ConnectToServer", "modClientTCP", err.number, err.Description, err.Source, err.HelpContext
>     err.Clear
>     Exit Function
> End Function
> ```
Link to comment
Share on other sites

Method or data member not found on .IP2

Nevermind. I think i forgot something.

Okay, now that thats not erroring i get "method or data member not found" on .IP

 If Not IsConnected Then 'try second ip
        Wait = GetTickCount
        frmMain.Socket.Close
        frmMain.Socket.IP =
Options.IP2
        frmMain.Socket.Connect
Link to comment
Share on other sites

So, the first time i've coded anything outside of a batch file on my own. But i managed to fix it by changing "Socket.IP" to this:

frmMain.Socket.RemoteHost = Options.IP2

I am super beyond proud of myself. Is it possible to use this code to add in 3 or more servers? Because if so that could be super useful down the road.
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
 Share

×
×
  • Create New...