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

WriteINI from Client to the Server. (Solved)


Ertzel
 Share

Recommended Posts

I am working on an advance Guild Message Of The Day code. Right now I have it so the Guild Owner can make the new message of the day by using a new frm I added in, then when they save the new GMOTD it puts it in an INI called GMOTD.ini with the GuildName and then the Message.

The problem is, I can only figure out how to make the new INI file in the Client folder, but I need it to go into the Server Folder instead so I can do the next part of it so everyone in the guild sees.

This would only make the guild Leader beable to see the GMOTD.

Here is my current code that works, but makes the file in the Client Folder.
```
Private Sub Command1_Click()
' GMOTD change
    Call WriteINI("GuildMessage", GetPlayerGuild(MyIndex), txtGMOTD, (App.path & "\GMOTD.ini"))

    FrmGMOTD.Visible = False
    FrmGuildOwner.Visible = True

End Sub
```
Link to comment
Share on other sites

You need to send a packet to the server with the GMOTD data and then make the server parse it and put it into an INI. after this you ofcourse need to add some code to the server to display the gmotd on login.

I don't know a lot about the eclipse packet system so I can't give you any code.
Link to comment
Share on other sites

@DrNova:

> Way, way simple to do that with a few easy lines of sadscript

Yes, but this is not sadscripting, it is sourcing.

I know how to do it with sadscripting, but those codes don't work in vb6 with the client. That is why Im asking how I would do it with source edits, not sadscripts.
Link to comment
Share on other sites

You would have a SendDatato

Call SendDataTo("guildmotd" & SEP_CHAR & GetPlayerGuild(MyIndex) & SEP_CHAR & txtGulid & END_CHAR)

Then in the server (I think IncomingData… Wherever packets are handled (looks like ScriptedItems with a select Case and stuff but with strings as cases).

Case "gulidmotd"
    Call WriteINI("GuildMessage", Parse(1), Parse(2), (App.path & "\GMOTD.ini"))
Link to comment
Share on other sites

@[SB:

> Soul link=topic=54866.msg580847#msg580847 date=1259699346]
> You would have a SendDatato
>
> Call SendDataTo("guildmotd" & SEP_CHAR & GetPlayerGuild(MyIndex) & SEP_CHAR & txtGulid & END_CHAR)
>
> Then in the server (I think IncomingData… Wherever packets are handled (looks like ScriptedItems with a select Case and stuff but with strings as cases).
>
> Case "gulidmotd"
>     Call WriteINI("GuildMessage", Parse(1), Parse(2), (App.path & "\GMOTD.ini"))

This needs a little fixing up:

```
Call SendData("guildmotd" & SEP_CHAR & GetPlayerGuild(MyIndex) & SEP_CHAR & txtGMOTD & END_CHAR)
```
Then in the Server:

```
Case "guildmotd"
    Call PutVar(App.Path & "\GMOTD.ini", "GuildMessage", Parse(1), Trim$(parse(2)))
Exit Sub
```
The Server uses **PutVar** and **GetVar**, while the Client uses **ReadINI** and **WriteINI**, unless you've changed that, of course.
Link to comment
Share on other sites

@Kimimaru:

> ```
> Case "guildmotd"
>     Call PutVar(App.Path & "\GMOTD.ini", "GuildMessage", Parse(1), Trim$(parse(2)))
> Exit Sub
> ```
> The Server uses **PutVar** and **GetVar**, while the Client uses **ReadINI** and **WriteINI**, unless you've changed that, of course.

Where do I put this part?

I tried in
```
Sub IncomingData(Socket As JBSOCKETSERVERLib.ISocket, Data As JBSOCKETSERVERLib.IData)
```but it wouldn't compile.
Link to comment
Share on other sites

Woot, thx both of you, I got that part to work.

Now im having a problem with my next part (Yes, Im a newb at this)  :sad:

How do I make it so when a Player logs into the game now, it displays the Guild Message Of The Day for their guild?

But it would have to check to see if the Players Guild has a MOTD set, so each guild has its own MOTD.

Right now my GMOTD.ini in my Server Folder looks like this

[GuildMessage]
Test=Guild Message Of The Day Test1

Test is the name of my guild. Then after the = is the MOTD for the guild.
Link to comment
Share on other sites

Well, you'd want to do the same thing, except "talk" via server and client.

Like in the server:

Case "readgmotd"
     Gmotd = ReadINI(App.Path & "\GMOTD.ini", "GuildMessage", Parse(1))
Call SendDataTo(index, "gmotdres" & SEP_CHAR & Gmotd & END_CHAR)
Exit Sub

Then in the client

Case "gmotdres"
If Parse(1) <> "" Then
Call PlayerMsg(MyIndex, "Gulid Message of the Day: " & Parse(1), RED)
End If

So somewhere in the client (where it gets connected in frmMirage) you would have:

Call SendData("readgmotd" & SEP_CHAR & GetPlayerGuild(MyIndex) & END_CHAR)
Link to comment
Share on other sites

@[SB:

> Ertzel link=topic=54866.msg580864#msg580864 date=1259702272]
> Woot, thx both of you, I got that part to work.
>
> Now im having a problem with my next part (Yes, Im a newb at this)  :sad:
>
> How do I make it so when a Player logs into the game now, it displays the Guild Message Of The Day for their guild?
>
> But it would have to check to see if the Players Guild has a MOTD set, so each guild has its own MOTD.
>
> Right now my GMOTD.ini in my Server Folder looks like this
>
> [GuildMessage]
> Test=Guild Message Of The Day Test1
>
> Test is the name of my guild. Then after the = is the MOTD for the guild.

You should probably put this part in **Sub JoinGame(Index)** in **modGameLogic** in the **Server** source. It executes faster than sending a packet, and it takes up less code. In the sub, put something like this there:

```
Dim gmotd As String
gmotd = GetVar(App.Path & "\GMOTD.ini", "GuildMessage", GetPlayerGuild(Index))
If gmotd <> vbNullString Then
    Call PlayerMsg(Index, gmotd, YELLOW)
End If
```
That's all you need.
Link to comment
Share on other sites

I think its set up right..

Right now I can make the GMOTD, but it still wont appear anywhere when I login, or when I change it…

When I make the GMOTD it goes into GMOTD.INI in my Server Folder.

Inside the folder looks like this

[GuildMessage]
Test=GMOTD Testing

Test is the guild name, and GMOTD Testing is the Guild Message Of The Day.

In my Server I have this in modGameLogic
```
        ' Send the player the welcome message.
        MOTD = Trim$(GetVar(App.Path & "\MOTD.ini", "MOTD", "Msg"))
        If LenB(MOTD) <> 0 Then
            Call PlayerMsg(index, "MOTD: " & MOTD, 11)
        End If

        ' Send the Guild Message Of The Day
        GMOTD = GetVar(App.Path & "\GMOTD.ini", GetPlayerGuild(index), "GuildMessage")
        If GMOTD <> vbNullString Then
            Call PlayerMsg(index, GMOTD, YELLOW)
        End If
```
I also tried putting the code in the same spot as the normal GMOTD without adding the ' Send the Guild Message Of The Day, but that didn't work either.
Link to comment
Share on other sites

Change the code to this:

```
        ' Send the player the welcome message.
        MOTD = Trim$(GetVar(App.Path & "\MOTD.ini", "MOTD", "Msg"))
        If LenB(MOTD) <> 0 Then
            Call PlayerMsg(index, "MOTD: " & MOTD, 11)
        End If

        ' Send the Guild Message Of The Day
        GMOTD = Trim$(GetVar(App.Path & "\GMOTD.ini", "GuildMessage", GetPlayerGuild(Index)))
        If GMOTD <> vbNullString Then
            Call PlayerMsg(index, GMOTD, YELLOW)
        End If
```
It should work now.
Link to comment
Share on other sites

Nope, not getting a message when I login >.<

Would it be easier to just make the GMOTD display in the Guild screen ingame

I tried to do that, but I would have to make something like this..
```
      GMOTD = ReadINI(App.path & "\GMOTD.ini", "GuildMessage", GetPlayerGuild(MyIndex))
        frmStable.GuildMsg.Caption = GMOTD

```
But ReadIni seems not to be a function in the Client Source, same with GetVar, so I have no clue how to make it display the GuildMsg Caption as the Guild Message Of The Day.
Link to comment
Share on other sites

Well, you'd have to read the INI file from the Server, since it's there, so this part of the code has to be put in the Server, unless you want to send a packet, but that's not necessary. My code should work if the file path, header, and variable is correct in the **GetVar** statement. Are you sure you put it in **Sub JoinGame(Index)** in **modGameLogic** in the **Server** source?
Link to comment
Share on other sites

Yes im sure thats where im putting it, and its not working >.<

I got this to kindda work..
```
        frmStable.GuildMsg.Caption = Trim$(ReadINI("GuildMessage", GetPlayerGuild(MyIndex), App.path & "\GMOTD.ini"))
```
This makes the GMOTD display in a text box in my guild window, which is good enough if I can't get it to display on login.

The only problem is, its looking for GMOTD.ini in the Client Folder not the Server folder >.<

So I need to send the GMOTD from the Server to the frmStable.GuildMsg.Caption =
somehow to make the message show up.
Link to comment
Share on other sites

@[SB:

> Ertzel link=topic=54866.msg581173#msg581173 date=1259789142]
> Yes im sure thats where im putting it, and its not working >.<
>
> I got this to kindda work..
> ```
>         frmStable.GuildMsg.Caption = Trim$(ReadINI("GuildMessage", GetPlayerGuild(MyIndex), App.path & "\GMOTD.ini"))
> ```
> This makes the GMOTD display in a text box in my guild window, which is good enough if I can't get it to display on login.
>
> The only problem is, its looking for GMOTD.ini in the Client Folder not the Server folder >.<
>
> So I need to send the GMOTD from the Server to the frmStable.GuildMsg.Caption =
> somehow to make the message show up.

Well, all right. If the code for popping up your guild window is in the Server, then do this:

Before the guild window code, put this:

```
Dim gmotd As String
gmotd = Trim$(GetVar(App.Path & "\GMOTD.ini", "GuildMessage", GetPlayerGuild(Index)))
Call SendDataTo(Index, "guildmotd" & SEP_CHAR & gmotd & END_CHAR)
```
Then, in the Client modHandleData:

```
If casestring = "gmotd" Then
        frmStable.GuildMsg.Caption = Trim$(parse(1))
Exit Sub
End If
```
If the code for popping up your guild window isn't in the Server, then send a packet to the Server, and from there, retrieve the guild message and then send it back to the Client in a packet like I did.
Link to comment
Share on other sites

To open up the Guild window that has the GuildMsg.Caption part in it, this is the script
```
        If KeyCode = vbKeyG And frmStable.txtMyTextBox.Visible = False Then
          frmStable.lblGuildName.Caption = GetPlayerGuild(MyIndex)
        frmStable.lblGuildRank.Caption = GetPlayerGuildAccess(MyIndex)
        frmStable.GuildMsg = Trim$(ReadINI("GuildMessage", GetPlayerGuild(MyIndex), App.path & "\GMOTD.ini"))

        If GetPlayerGuildAccess(MyIndex) = 4 Then
          frmStable.LabelLeader.Visible = True
                frmStable.picGuildMember.Visible = Not frmStable.picGuildMember.Visible
            Else
                frmStable.picGuildMember.Visible = Not frmStable.picGuildMember.Visible
        End If
    End If
```(This is the one that needs to have GMOTD.ini in the client to use)
Its in modGameLogic in my Client Source
Link to comment
Share on other sites

Okay, so change that code to this:

```
If KeyCode = vbKeyG And frmStable.txtMyTextBox.Visible = False Then
    Call SendData("gmotd" & SEP_CHAR & GetPlayerName(MyIndex) & END_CHAR)
End If
```
Then in the Server **modHandleData**, put this:

```
Case "gmotd"
  Dim gmotd As String
  Dim Name As Long

    Name = FindPlayer(parse(1))
    gmotd = Trim$(GetVar(App.Path & "\GMOTD.ini", "GuildMessage", GetPlayerGuild(Name))
    Call SendDataTo(Name, "gmotd" & SEP_CHAR & gmotd & SEP_CHAR & Name & END_CHAR)
Exit Sub
```
Head to the Client **modHandleData** now, and put this there:

```
If casestring = "gmotd" Then
  Dim gmotd As String
  Dim Name As Long

  gmotd = Trim$(parse(1))
  Name = parse(2)

    frmStable.lblGuildName.Caption = GetPlayerGuild(Name)
    frmStable.lblGuildRank.Caption = GetPlayerGuildAccess(Name)
    frmStable.GuildMsg = gmotd

    If GetPlayerGuildAccess(Name) = 4 Then
      frmStable.LabelLeader.Visible = True
      frmStable.picGuildMember.Visible = Not frmStable.picGuildMember.Visible
    Else
      frmStable.picGuildMember.Visible = Not frmStable.picGuildMember.Visible
    End If

    Exit Sub
End If
```
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...