Author Topic: WriteINI from Client to the Server. (Solved)  (Read 626 times)

0 Members and 1 Guest are viewing this topic.

Offline Ertzel

  • Active Member
  • ***
  • Posts: 480
    • View Profile
WriteINI from Client to the Server. (Solved)
« on: December 01, 2009, 10:56:05 AM »
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.
Code: [Select]
Private Sub Command1_Click()
' GMOTD change
    Call WriteINI("GuildMessage", GetPlayerGuild(MyIndex), txtGMOTD, (App.path & "\GMOTD.ini"))

    FrmGMOTD.Visible = False
    FrmGuildOwner.Visible = True
   
End Sub

« Last Edit: December 04, 2009, 05:19:47 AM by [SB]Ertzel »

Offline Xeross

  • Veteran
  • Teh Uberleet
  • *
  • Posts: 2138
    • View Profile
    • TheElitist
Re: WriteINI from Client to the Server.
« Reply #1 on: December 01, 2009, 11:25:31 AM »
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.

Offline DrNova

  • When I crash and burn, I want it to at least be Spectacular
  • Donated
  • Demi God
  • *
  • Posts: 4744
  • And boom goes the dynamite
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #2 on: December 01, 2009, 11:52:29 AM »
Way, way simple to do that with a few easy lines of sadscript
Humankind didnt rise to control the world because we are the smartes, or the strongest. We rose to the top because we are the most insane, murderous bastards on the planet.


Offline Ertzel

  • Active Member
  • ***
  • Posts: 480
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #3 on: December 01, 2009, 12:02:22 PM »
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.

Offline Soul

  • Global Moderator
  • Teh Uberleet
  • *
  • Posts: 2844
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #4 on: December 01, 2009, 12:29:06 PM »
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"))

Offline Kimimaru

  • Advanced Member
  • ****
  • Posts: 789
    • View Profile
    • A free fanbased Mario Online RPG!
Re: WriteINI from Client to the Server.
« Reply #5 on: December 01, 2009, 12:34:46 PM »
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:

Code: [Select]
Call SendData("guildmotd" & SEP_CHAR & GetPlayerGuild(MyIndex) & SEP_CHAR & txtGMOTD & END_CHAR)
Then in the Server:

Code: [Select]
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.


Server is:

Offline Ertzel

  • Active Member
  • ***
  • Posts: 480
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #6 on: December 01, 2009, 12:40:59 PM »
Code: [Select]
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
Code: [Select]
Sub IncomingData(Socket As JBSOCKETSERVERLib.ISocket, Data As JBSOCKETSERVERLib.IData)but it wouldn't compile.

Offline Soul

  • Global Moderator
  • Teh Uberleet
  • *
  • Posts: 2844
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #7 on: December 01, 2009, 01:00:13 PM »
Search for HandleData?

Just find where packets are handled.

Sorry Kimi, I didn't have the source infront of me.

Offline Ertzel

  • Active Member
  • ***
  • Posts: 480
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #8 on: December 01, 2009, 01:17:52 PM »
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.

Offline Soul

  • Global Moderator
  • Teh Uberleet
  • *
  • Posts: 2844
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #9 on: December 01, 2009, 01:29:02 PM »
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)

Offline Ertzel

  • Active Member
  • ***
  • Posts: 480
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #10 on: December 01, 2009, 01:41:34 PM »
Code: [Select]
Case "readgmotd"
     Gmotd = ReadINI(App.Path & "\GMOTD.ini", "GuildMessage", Parse(1))
Call SendDataTo(index, "gmotdres" & SEP_CHAR & Gmotd & END_CHAR)
Exit Sub

Wont let me compile, it says ReadINI is not a command or w/e.

Offline Robin

  • Head Developer
  • Demi God
  • *
  • Posts: 5988
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #11 on: December 01, 2009, 04:53:28 PM »
Use GetVar.

Offline Kimimaru

  • Advanced Member
  • ****
  • Posts: 789
    • View Profile
    • A free fanbased Mario Online RPG!
Re: WriteINI from Client to the Server.
« Reply #12 on: December 01, 2009, 05:47:37 PM »
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:

Code: [Select]
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.


Server is:

Offline Ertzel

  • Active Member
  • ***
  • Posts: 480
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #13 on: December 02, 2009, 03:37:42 AM »
Do I need to add Souls code to the Client still if I use that Server code Kimiaru? cuz im not getting a message when I login.

Offline Kimimaru

  • Advanced Member
  • ****
  • Posts: 789
    • View Profile
    • A free fanbased Mario Online RPG!
Re: WriteINI from Client to the Server.
« Reply #14 on: December 02, 2009, 04:01:14 AM »
No, you don't need to. Make sure that the GetVar statement I posted is correct.


Server is:

Offline Ertzel

  • Active Member
  • ***
  • Posts: 480
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #15 on: December 02, 2009, 05:08:45 AM »
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
Code: (vb) [Select]
        ' 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.


Offline Kimimaru

  • Advanced Member
  • ****
  • Posts: 789
    • View Profile
    • A free fanbased Mario Online RPG!
Re: WriteINI from Client to the Server.
« Reply #16 on: December 02, 2009, 09:59:23 AM »
Change the code to this:

Code: (vb) [Select]
        ' 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.
« Last Edit: December 02, 2009, 10:00:55 AM by Kimimaru »


Server is:

Offline Ertzel

  • Active Member
  • ***
  • Posts: 480
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #17 on: December 02, 2009, 10:43:34 AM »
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..
Code: (vb) [Select]
       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.
« Last Edit: December 02, 2009, 11:52:27 AM by [SB]Ertzel »

Offline Kimimaru

  • Advanced Member
  • ****
  • Posts: 789
    • View Profile
    • A free fanbased Mario Online RPG!
Re: WriteINI from Client to the Server.
« Reply #18 on: December 02, 2009, 12:59:36 PM »
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?


Server is:

Offline Ertzel

  • Active Member
  • ***
  • Posts: 480
    • View Profile
Re: WriteINI from Client to the Server.
« Reply #19 on: December 02, 2009, 01:25:42 PM »
Yes im sure thats where im putting it, and its not working >.<

I got this to kindda work..
Code: (vb) [Select]
        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.
« Last Edit: December 02, 2009, 02:05:26 PM by [SB]Ertzel »