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

Packet Editing


Zamin
 Share

Recommended Posts

Hello

Someone please make a tutorial on how to add/remove/edit packets in both client and server side. Please, I am having lots of trouble understanding how to use them.

Many questions are popping up like wtf is Parse(1) and Parse(2). I guess the 1 and 2 are like paremeters, no? What is the difference between packets in client and packets saved in server side. If possible, how can we coordinate between packets saved in client and server side. do we need to.

Please, someone make a good tutorial on packets. Please, I am dieing  :lipsrsealed:

EDIT: Please answer this question as well if possible:
If your in Form1, is it possible to call a Public function/sub of Form2?
Ex: In form 1:
```
Call Form2.FunctionName
```Is this possible? Also. After when the function/sub is finished in Form2, do you go back to the line of the function/sub in Form1 which called the function/sub of Form2?

-Thanks in advance.
Link to comment
Share on other sites

Parse(1) and Parse(2) are all a word split into an array

Like

Dim Parse as string

Parse = Split("Hello what is your name!")

And you go Msgbox(Parse(3))

That would msgbox the forth word. aka your

Else you could do like

Dim Parse as string

Parse = Split("12/13/10", "/")

Msgbox(Parse(2))

That would msgbox "10"

So it splits the string by "/"

Ok?

Another thing.

Editing Packets

In the client (Reciving data side at the moment )

In Sub HandleData Make a Space under one the packet recivers

And put

```
If (CaseString="Hello") Then
Dim par
Dim par1
Par = Parse(1) ' Would be the attached string ("free")
Par1 = Parse(2) ' Would be the attached string ("yo")
Msgbox(Par1 & Par)
End If

```
In The client anysub

put

```
Call SendData("Hello" & SEP_CHAR & "free" & SEP_CHAR & "yo" & END_CHAR)

```
SEP_CHAR = The Split handler

as you can see in HandleData

```

Parse = Split(Data, SEP_CHAR)

```
EDIT, I did this out of pure knowledge, don't have no source atm, so might have some errors, Prolly not thougjh
Link to comment
Share on other sites

@Captain:

> Parse = Split("Hello what is your name!")
>
> And you go Msgbox(Parse(3))
>
> That would msgbox the forth word. aka your

So (Parse(0)) Will give me: "Hello"?.

@Captain:

> Parse = Split("12/13/10", "/")
>
> Msgbox(Parse(2))

And in this case (Parse(0)) Will give me: "12"?.

OK, and I got the rest. I was looking at the 'weather' packet. One more thing, when you make packets. Your not like 'saving' info or anything right. All this is doing is checking whenever you send in info with a certain packet name. Or the packet saves info in each char .dat somehow? So many questions lol
Link to comment
Share on other sites

@Zamin:

> @Captain:
>
> > Parse = Split("Hello what is your name!")
> >
> > And you go Msgbox(Parse(3))
> >
> > That would msgbox the forth word. aka your
>
> So (Parse(0)) Will give me: "Hello"?.
>
> @Captain:
>
> > Parse = Split("12/13/10", "/")
> >
> > Msgbox(Parse(2))
>
> And in this case (Parse(0)) Will give me: "12"?.
>
> OK, and I got the rest. I was looking at the 'weather' packet. One more thing, when you make packets. Your not like 'saving' info or anything right. All this is doing is checking whenever you send in info with a certain packet name. Or the packet saves info in each char .dat somehow? So many questions lol

Yes parse(0) = Hello
and yes again, 12

And no it does not save data. It just gets called when server sends data.
Link to comment
Share on other sites

@Zamin:

> OK, and I got the rest. I was looking at the 'weather' packet. One more thing, when you make packets. Your not like 'saving' info or anything right. All this is doing is checking whenever you send in info with a certain packet name. Or the packet saves info in each char .dat somehow? So many questions lol

The data is written to the .dat files by the SaveChar() command.  I don't have my code handy, so I can't give you any highspeed scripts.

However, while EBs description of Parse() is accurate, I have an analogy I like to use comparing it to Medevacs.  A Medevac is a report sent in by an infantryman requesting an Airlift for a hurt soldier, and it is 9 consecutive lines of data that work like this:

Line 1\. Location of the pick-up site.

Line 2\. Radio frequency, call sign.

Line 3\. Number of patients by precedence:

Line 4\. Special equipment required:

Line 5\. Number of patients:

Line 6\. Security at pick-up site:

Line 7\. Method of marking pick-up site:

Line 8\. Patient nationality and status:

Line 9\. NBC Contamination:

Well, when you send up a medevac, you only give them the data, separated by BREAK.  So an example would be this

MEDEVAC AS FOLLOWS BREAK L05040221E54478965 BREAK 35000 hz, Fox1 BREAK B BREAK D BREAK A BREAK X BREAK C BREAK A BREAK NONE OVER

This is a REALLY good example.  In code, it would look like this:

```
Sub Packet_Medevac
Dim Packet As String
    Packet = "MEDEVAC AS FOLLOWS" & SEP_CHAR & GetSoldierLocation(Index) & SEP_CHAR & GetRadioFreqCallsign(Index, Myindex) & SEP_CHAR & GetPatients(Index) & SEP_CHAR & GetEquipment(Index) & SEP_CHAR & GetNumPatients(Index) & SEP_CHAR & GetSitREP(Index) & SEP_CHAR & GetSignalling(Index) & SEP_CHAR & GetNationality(Index) & SEP_CHAR & GetContamination(Index) & END_CHAR

Call SendData(Index, Packet)
```
Now I'm sure I messed that up since I did it from memory, but the IMPORTANT thing is that you know that SEP_CHAR is like BREAK, it tells you where the data is divided, and where to Parse at, and END_CHAR is like OVER.  This is what the helicopter pilot (the Server) would look like in code:

```
'this would be modServerTCP
'whatever whatever blah blah blah loop loop loop
Case = MEDEVAC AS FOLLOWS
    Location = Parse(1)
    FreqCallSign = Parse(2)
    Priority = Parse(3)
    Equipment = Parse(4)
    Number = Parse(5)
    Security = Parse(6)
    Marking = Parse(7)
    Nationality = Parse(8)
    Contamination = Parse(9)

    MedevacIndex = 10

```
Or something like that.  I only know what I've picked up since I started studying the Eclipse code in December, but the Medevac comparison works to describe packets and parsing.  I'm thinking of writing a tut…
Link to comment
Share on other sites

OK, kinda hard to grasp this so quickly. You mentioned all type of data is saved in .dat by the SaveChar() command.

I am basically trying to eliminate .ini's. So how can I use this to save a certain amount of information (constants/strings) for every user.

If not then how can I make the client to communicate with the server and ask it to read certain information from a certain .ini file which is located on the server side.

I hope you know what I am trying to get at.

-Thanks in advance
Link to comment
Share on other sites

hrm so you want it per-strict .ini? 

Crypto ~9line Medevac brings back memorys, boy does it.
perfect answer. IMO.

Simple way for those who catch on pretty quick: Just think as parse as a container which holds the information of a value,string or input…

a secure way to doing that would be to have it randomly generate a file each time the server is started, and hold the information within a "temporary container"  which could be set on yourside as your "ini"

so you could look into where its saving the info into... bad thing into making everything into one ini is when you go to open it, it will be pretty large and long wait to open...also loads stuff slower. now since your wanting it to do constants/strings... it may be quicker for the first 100 users, but it could generally dwindle into more memory useage.

you could however get it to call and write to it all within a .pak file which could send a crypt key~de-crypt key to and fro allowing all the information on the data files to be locked... could easily have one for each user, specifying one for constant, one for string and one for everything else... it could lock to the users account name serverside...

bahhh sorry I think too much...  this probably made 0 sense, oh well ;p
Link to comment
Share on other sites

I think either my question was confusing or you are. lol

Wheat I have is everything saved in .ini's on server side. My questions are.

1\. Can I somehow ask the server from client to open those .ini (saved on server side) and get some information from there?

or

2\. Can I somehow eliminate the entire .ini concept and have all the information saved in a .dat file on client side or something like this? A permanent saving procedure. From which the client can easily open the .dat file and access all the needed information, edit/delete all necessary stuff.

Sorry if confusing again.
-Thanks in advance.
Link to comment
Share on other sites

The commands for .dat are kinda confusing to me too.  I'm not 100% sure how they work, but I will research it later tonight once the resident major and lieutenant colonel leave.

I could write some code that would stash all the variables in .ini's on the server side, and then retrieve all the data from there, but that could get…convoluted.  And also slow.

Is this all some method you're developing as a hacking deterrant?

Also @Gungho Yeah I know right?  I had Robin explain parse to me, and I had to read the PM three or four times before it sunk in, but the 9line Medevac is a REALLY good analogy.
Link to comment
Share on other sites

Hello guys,

I am trying to do something and failing at the moment. Hoping I can get some help.

What I am trying to do is that, ust testing for the moment. Please don't ask me why. I am trying to do that when a player (access>5) presses F1, the cPanel opens. But along with that it gets a integer value from a .ini file from the server side. Please bare with me, I will post the code. It gives me a connection failed error message, please help  :embarrassed:

OK. Here is what I did.

Client, In frmStable:
Under:
```
If KeyCode = vbKeyF1 Then
        If Player(MyIndex).Access > 0 Then
            frmAdmin.Visible = False
            frmAdmin.Visible = True

```I added:
```
Call SendData("Test" & END_CHAR)
```So sending a packet to Server.

Server, In modHandleData:
I added:
```
Case "Test"
            Call Packet_Test(index)
            Exit Sub

```This checks the packet being sent from Client side.

And at the end of modHandleData:
I added:
```
Public Sub Packet_Test(ByVal index As Long)
    Dim Amount As Integer
    Amount = 0
    Amount = Int(GetVar(App.Path & "\Test.ini", "Test", "Amount"))
    Call GlobalMsg(Amount)
    Call SendDataTo(index, "Test2" & SEP_CHAR & Amount & END_CHAR)
End Sub

```This will get the integer value saved in 'Test.ini' under header 'Test' and name 'Amount'. It should be '2'.
After saving the integer (2) in the variable Amount. Server will send data back to Client, along with the Amount. Right?

Client, In modHandleData:
I added:
```
Case "Test2"
            Call Packet_Test2(Parse(1))
            Exit Sub

```This will check the packet sent from the Sevrer, right?

THen at the end of modHandleData:
I added:
```
Public Sub Packet_Test2(ByVal Amount As Long)
    Call GlobalMsg(Amount)
End Sub

```This will get the Amount from packet sent from Server and output it as a Global Message.

All this should work, right? I think so. But it doesn't. What happens is as soon as I press the 'F1' button, it gives me a connection lost 'OK' error message, and it exists the client (not the server if it matters)

Any help please. Please!!!!  :lipsrsealed:

-Thanks in Advance :)
Link to comment
Share on other sites

There are a couple of small problems here. First, you didn't actually get an integer value from the INI file. You've just used the **Int()** expression. Using **GetVar** takes the variable as a string, so using **Int()** before would be useless. What you need to do is convert it to an integer by using the **CInt()** expression like so:

```
Public Sub Packet_Test(ByVal index As Long)
    Dim Amount As Integer
    Amount = 0
    Amount = CInt(GetVar(App.Path & "\Test.ini", "Test", "Amount"))
    Call GlobalMsg(Amount)
    Call SendDataTo(index, "Test2" & SEP_CHAR & Amount & END_CHAR)
End Sub
```
Second, you've apparently confused the Server **GlobalMsg** syntax with the one in the **Client**. The Server syntax requires a message as well as a color value, while the Client syntax simply requires a message. You should change the previous code to this:

```
Public Sub Packet_Test(ByVal index As Long)
    Dim Amount As Integer
    Amount = 0
    Amount = CInt(GetVar(App.Path & "\Test.ini", "Test", "Amount"))
    Call GlobalMsg(Amount, WHITE)
    Call SendDataTo(index, "Test2" & SEP_CHAR & Amount & END_CHAR)
End Sub
```
That's fine. I see something else in your code that may cause problems, but try changing your old code to see if it works properly first. If it does, then there's no need to change anything else.
Link to comment
Share on other sites

Actually, **CInt()** literally converts the expression into an integer. I've had plenty of experience with it to find that out myself, even though I had known that before, lol. In addition, **Int()** does indeed make the number a whole number, but it does this by rounding the number up to the nearest integer, regardless of what the decimal is. Ex: Int(4.2) = 5
Link to comment
Share on other sites

Ok Kimimaru. I made the edits you said above. But I still get the same error message. I am guessing I messed up on the Client side?

Thanks for the help. I hope This sample works. I really would appreciate all the help I can get.

-Thanks in advance (again) :p
Link to comment
Share on other sites

@Zamin:

> OK, for some reason. If I keep all the packet names lowercase. It works. But if I make any name caps, or all. It gives me a connection lost error. Is this suppose to happen?
>
> -Thanks

Yes, it is. You can send packets to the Server in all caps, though. For example: Call SendData("TEST2" & END_CHAR)

That would work fine, but when you send a packet to the **Client**, it must be in lowercase because it's case sensitive.
Link to comment
Share on other sites

@Kimimaru:

> Yes, it is. You can send packets to the Server in all caps, though. For example: Call SendData("TEST2" & END_CHAR)
>
> That would work fine, but when you send a packet to the **Client**, it must be in lowercase because it's case sensitive.

Er, not sure I'm trackin', like, it won't take it in any case other than lowercase? Or will it still function as long as you're consistant IE Call SendData("MuLtIpLeCaSeS" & END_CHAR) would work if your client is looking for Case "MuLtIpLeCaSeS"
Link to comment
Share on other sites

This may only be happening to me because I'm still using **Eclipse Evolution 2.7**, which uses **casestrings** instead of **Cases**. For example, in my Client **modHandleData**, my packets are received like so:

```
If casestring = "test2" Then
```
In Eclipse Stable, the Client **modHandleData** has been modified, so this has been changed to a case:

```
Case "test2"
```
This may account for the differences in our code.
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...