| Mirage Source http://miragesource.net/forums/ |
|
| Ip Config (for engines) http://miragesource.net/forums/viewtopic.php?f=210&t=38 |
Page 1 of 2 |
| Author: | grimsk8ter11 [ Thu Jun 01, 2006 8:58 pm ] |
| Post subject: | Ip Config (for engines) |
Difficuly: 2/5 Only Client Side: 1st make a new form and name it frmIpconfig Make 2 txtBoxes named txtIP and txtPort Make 2 picBoxes named picConfirm and picCancel In the code put the following: Code: Option Explicit Private Sub Form_Load() Dim FileName As String FileName = App.Path & "\config.ini" txtIP = ReadINI("IPCONFIG", "IP", FileName) txtPort = ReadINI("IPCONFIG", "PORT", FileName) End Sub Private Sub picCancel_Click() frmMainMenu.Visible = True frmIpconfig.Visible = False End Sub Private Sub picConfirm_Click() Dim IP, Port As String Dim fErr As Integer Dim Texto As String IP = txtIP Port = Val(txtPort) fErr = 0 If fErr = 0 And Len(Trim(IP)) = 0 Then fErr = 1 Call MsgBox("Inform a correct IP.", vbCritical, GAME_NAME) Exit Sub End If If fErr = 0 And Port <= 0 Then fErr = 1 Call MsgBox("Inform a correct Port.", vbCritical, GAME_NAME) Exit Sub End If If fErr = 0 Then ' Rec IP and Port Call WriteINI("IPCONFIG", "IP", txtIP.Text, (App.Path & "\config.ini")) Call WriteINI("IPCONFIG", "PORT", txtPort.Text, (App.Path & "\config.ini")) End If frmMainMenu.Visible = True frmIpconfig.Visible = False End Sub Now lets set the Client to connect to the ip and port in the config.ini In modClientTCP, find: Code: Sub TcpInit() Replace it ALL with: Code: Sub TcpInit() SEP_CHAR = Chr(0) END_CHAR = Chr(237) PlayerBuffer = "" Dim IP As String Dim Port As String Dim FileName As String FileName = App.Path & "\config.ini" If FileExist("config.ini") Then IP = ReadINI("IPCONFIG", "IP", FileName) Port = ReadINI("IPCONFIG", "PORT", FileName) Else IP = "0.0.0.0" Port = 0 Call WriteINI("IPCONFIG", "IP", IP, (App.Path & "\config.ini")) Call WriteINI("IPCONFIG", "PORT", Port, (App.Path & "\config.ini")) End If frmMirage.Socket.Close frmMirage.Socket.RemoteHost = IP frmMirage.Socket.RemotePort = Val(Port) End Sub In frmMainMenu add a picBox named picIpConfig and add this sub: Code: Private Sub picIpConfig_Click()
frmIpconfig.Visible = True Me.Visible = False End Sub This is all, =D |
|
| Author: | Tayuke [ Fri Aug 03, 2007 12:58 am ] |
| Post subject: | Re: Ip Config (for engines) |
Got an Error: using MSE1 In modClientTCP, under the TcpInit Sub, The 'ReadINI' function isn't recognised Help? -Tay |
|
| Author: | Matt [ Fri Aug 03, 2007 1:08 am ] |
| Post subject: | Re: Ip Config (for engines) |
... Go server side, grab the putvar and getvar subs. Add them to the client. Learn to use them. |
|
| Author: | Rian [ Fri Aug 03, 2007 1:42 am ] |
| Post subject: | Re: Ip Config (for engines) |
Bah, noob. He needs the ReadINI and WriteINI functions for this tutorial. Though using getVar and PutVar is easier, since it is already in the server. |
|
| Author: | Tayuke [ Fri Aug 03, 2007 1:48 am ] |
| Post subject: | Re: Ip Config (for engines) |
O.k, so I get rid of that Error, after making those two sub's ReadINI and WriteINI ... but, now its work's fine, but doesn't write the variable's, and still is using the IP and Port set in VB6.... |
|
| Author: | Matt [ Fri Aug 03, 2007 1:55 am ] |
| Post subject: | Re: Ip Config (for engines) |
Sonire wrote: Bah, noob. He needs the ReadINI and WriteINI functions for this tutorial. Though using getVar and PutVar is easier, since it is already in the server. Dude, I know. But getvar and putvar are easier to use for several reasons. You add the subs, and I think 2 lines declaring the file used for them. Then.. It's just ip = getvar(app.path & "/filename.ini", "HEADER", "Data") So.. IP = GetVar(App.Path & "/settings.ini", "IPCONFIG", "IP") |
|
| Author: | Rian [ Fri Aug 03, 2007 1:59 am ] |
| Post subject: | Re: Ip Config (for engines) |
Well, seeing as I'm at work and you're just wasting precious air, I think you should write the kid a new tutorial on using getVar and putVar. |
|
| Author: | Tayuke [ Fri Aug 03, 2007 2:06 am ] |
| Post subject: | Re: Ip Config (for engines) |
Perfekt wrote: Sonire wrote: Bah, noob. He needs the ReadINI and WriteINI functions for this tutorial. Though using getVar and PutVar is easier, since it is already in the server. Dude, I know. But getvar and putvar are easier to use for several reasons. You add the subs, and I think 2 lines declaring the file used for them. Then.. It's just ip = getvar(app.path & "/filename.ini", "HEADER", "Data") So.. IP = GetVar(App.Path & "/settings.ini", "IPCONFIG", "IP") I tried that. The error went away, but it still isn't working. As I said before, its still just using the value's set in the code itself. Its also not even writing the value's into the config.ini. Its not even loading the value's into the form, set in the .ini file itself! |
|
| Author: | Matt [ Fri Aug 03, 2007 2:19 am ] |
| Post subject: | Re: Ip Config (for engines) |
It's simple dude. First off, if it's still using the stuff set in the code itself, you messed something up. As remote_host should be read from the file. Also, same for port. |
|
| Author: | Tayuke [ Fri Aug 03, 2007 2:47 am ] |
| Post subject: | Re: Ip Config (for engines) |
I even did this entire Tut. on a blank copy of MSE1, and after replacing all the ReadINI and WriteINI with GetVar and PutVar, it still isn't making the file, loading the value's up, or saving the vaule's of the IP/Port. Unless this code is revelant to the The GetVar/PutVar: Code: Public Declare Function GetTickCount Lib "kernel32" () As Long *cough*Unlikey*cough* OR I have to remove/replace the IP/Port Value's set in the code, something that hasn't been said yet ...something is stuffed up. |
|
| Author: | Matt [ Fri Aug 03, 2007 3:08 am ] |
| Post subject: | Re: Ip Config (for engines) |
GetTickCount has nothing to do with get/putvar. Show me the code you have setting the variable. The putvar call. |
|
| Author: | Tayuke [ Fri Aug 03, 2007 3:11 am ] |
| Post subject: | Re: Ip Config (for engines) |
Code: Private Sub picConfirm_Click() Dim IP, Port As String Dim fErr As Integer Dim Texto As String IP = txtIP Port = Val(txtPort) fErr = 0 If fErr = 0 And Len(Trim(IP)) = 0 Then fErr = 1 Call MsgBox("Inform a correct IP.", vbCritical, GAME_NAME) Exit Sub End If If fErr = 0 And Port <= 0 Then fErr = 1 Call MsgBox("Inform a correct Port.", vbCritical, GAME_NAME) Exit Sub End If If fErr = 0 Then ' Rec IP and Port Call PutVar("IPCONFIG", "IP", txtIP.Text, (App.Path & "\config.ini")) Call PutVar("IPCONFIG", "PORT", txtPort.Text, (App.Path & "\config.ini")) End If MsgBox ("Done!") frmMainMenu.Visible = True frmIpconfig.Visible = False End Sub EDIT: 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 = "" sSpaces = Space(5000) Call GetPrivateProfileString(Header, Var, szReturn, sSpaces, Len(sSpaces), File) GetVar = RTrim(sSpaces) GetVar = Left(GetVar, Len(GetVar) - 1) End Function Public Sub PutVar(File As String, Header As String, Var As String, Value As String) Call WritePrivateProfileString(Header, Var, Value, File) End Sub |
|
| Author: | Matt [ Fri Aug 03, 2007 3:14 am ] |
| Post subject: | Re: Ip Config (for engines) |
Try this.. Code: Private Sub picConfirm_Click()
Dim IP, Port As String Dim fErr As Integer Dim Texto As String IP = txtIP Port = Val(txtPort) fErr = 0 If fErr = 0 And Len(Trim(IP)) = 0 Then fErr = 1 Call MsgBox("Inform a correct IP.", vbCritical, GAME_NAME) Exit Sub End If If fErr = 0 And Port <= 0 Then fErr = 1 Call MsgBox("Inform a correct Port.", vbCritical, GAME_NAME) Exit Sub End If If fErr = 0 Then ' Rec IP and Port Call PutVar(app.path & "\config.ini", "IPCONFIG", "IP", txtip.text) Call PutVar(app.path & "\config.ini", "IPCONFIG", "PORT", txtport.text) End If MsgBox ("Done!") frmMainMenu.Visible = True frmIpconfig.Visible = False End Sub |
|
| Author: | Tayuke [ Fri Aug 03, 2007 3:31 am ] |
| Post subject: | Re: Ip Config (for engines) |
Still not working |
|
| Page 1 of 2 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|