Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IPconfig
#1
There is a tutorial that grimsk8er posted a long time ago, but it does not work.

Could someone please post a cut & paste tut?

~elec
Reply
#2
I thought you could code?

If nobody posts a solution within the next hour, i'll write it for you.
Reply
#3
I can, and I tried to make it work, but when reading from a file, it only read 127 and stopped at the period.

I am very confuzled.
Reply
#4
post the code =/
Reply
#5
put this in an ini file somewhere:
Code:
[IPCONFIG]
IP=127.0.0.1
PORT=4000

load up the client project.

Somewhere in modDatabase, add this:

Code:
Public Function GetVar(File As String, _
                       Header As String, _
                       Var As String) As String
Dim sSpaces  As String  ' Max string length
Dim szReturn As String  ' Return default value if not found
    szReturn = vbNullString
    sSpaces = Space$(5000)
    GetPrivateProfileString Header, Var, szReturn, sSpaces, Len(sSpaces), File
    GetVar = RTrim$(sSpaces)
    GetVar = Left$(GetVar, Len(GetVar) - 1)
End Function

Code:
Public Sub PutVar(File As String, _
                  Header As String, _
                  Var As String, _
                  Value As String)
    WritePrivateProfileString Header, Var, Value, File
End Sub

That will allow you to read and write to ini files.

In Sub TCPInit, replace this:

Code:
frmMirage.Socket.RemoteHost = GAME_IP
    frmMirage.Socket.RemotePort = GAME_PORT

With this:

Code:
Dim filename As String
    filename = App.Path & "\config.ini"

frmMirage.Socket.RemoteHost = GetVar(filename, "IPCONFIG", "IP")
    frmMirage.Socket.RemotePort = Val(GetVar(filename, "IPCONFIG", "PORT"))

Not tested, so tell me if you get any errors. When you make your IP Config form (If you make one), use the PutVar call to write to the ini file.
Reply
#6
Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)