online programing help

hi

This is what i want to do:

im making a simple online game,but the tutorial for winsock only showed how to get a message and put it in a string.

what i need to know is how to know how to put it in diffrent variables.

so lets say that the you send the client his HP(Hit points) that the client knows to put in to the HP vareible

Comments

  • [b][red]This message was edited by DrMarten at 2006-6-13 22:37:36[/red][/b][hr]
    : hi
    :
    : This is what i want to do:
    :
    : im making a simple online game,but the tutorial for winsock only showed how to get a message and put it in a string.
    :
    : what i need to know is how to know how to put it in diffrent variables.
    :
    : so lets say that the you send the client his HP(Hit points) that the client knows to put in to the HP vareible
    ===================================================================

    Hi,

    Without seeing the WINSOCK example, my suggestion is, if you send two items of data then make the first one received the HP variable.

    More than one byte or variable sent is known as a "packet" of data.

    Think of a packet like a box.
    It contains an apple and an orange.

    To make sure the person you send the apple to always gets the apple first, then send the apple first.

    Same goes in terms of online communications.

    Send your HP variable 1st along with all the other bits of data.

    The receiving program picks the items it needs as it knows the order in which they were sent.

    Send 1234 and you know this is in number order as [b]YOU[/b] know. :-)
    A computer is thick, it doesn't know. it might as well be 2431.

    You have to program in the same way you teach a kid to read.
    A step at a time, precisely as YOU want it.
    Think about all the steps to make a cup of tea as an example.

    Hope this helps? :-)


    Regards,

    Dr M.

  • thx dr. thats what i needed, i think but could you post a small code sniplit like for the data arival sub like here is what i have now

    Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
    Dim strData As String
    tcpServer.GetData strData

    End Sub

    yes i know its basic.
    so like how could i do what you said with the code?
  • : thx dr. thats what i needed, i think but could you post a small code sniplit like for the data arival sub like here is what i have now
    :
    : Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
    : Dim strData As String
    : tcpServer.GetData strData
    :
    : End Sub
    :
    : yes i know its basic.
    : so like how could i do what you said with the code?

    Sockets only send streams of bytes back and forth. Interpreting what those bytes "mean" is up to the programs sending and receiving them. That is why various Protocols have been created (TCP/IP, FTP, HTTP, etc). The P in all those names stands for "Protocol".

    Like when you visit a website in your browser, the first three bytes sent to the server are "GET". That way the program on the other side knows what you're asking it to do.

    The point is that you need to come up with some kind of protocol so that your programs can interpret the data sent over the sockets.

    You could, perhaps, decide that any command that starts with "SET" will specify a value to set and the value to set it to. So, to pass your "hit points" value, you could send:

    SET HP=10

    And the receiver of that message could respond with

    100 OK

    Or whatever. Basically you have to define the specific rules by which your clients and server communicate.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]

  • : Send 1234 and you know this is in number order as [b]YOU[/b] know. :-)
    : A computer is thick, it doesn't know. it might as well be 2431.

    Your analogy is terrible. A computer knows very well the difference between 1234 and 2431.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]

  • [b][red]This message was edited by DrMarten at 2006-6-14 9:36:7[/red][/b][hr]
    1234 and "1234" and 1234.00

    Three different types.

    You still have to tell a program what to do.

    Talk to your computer then and ask it what it reckons about>>

    1234 and 2431 , you won't get any response!!

    Computers like those in Sci-Fi movies that talk to you in a
    human-like way....they just don't exist yet, in every home anyway.


    Regards,

    Dr M.



  • [b][red]This message was edited by DrMarten at 2006-6-14 9:47:47[/red][/b][hr]
    : thx dr. thats what i needed, i think but could you post a small code sniplit like for the data arival sub like here is what i have now
    :
    : Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
    : Dim strData As String
    : tcpServer.GetData strData
    :
    : End Sub

    ====================================================================
    Hi,

    What is the format of your strData and what is the bytesTotal?

    Is the bytesTotal constantly 100 bytes or what?

    If strData is more than one byte then split the data into an array>>

    [code]
    [green]'Put the strData bytes into an array.[/green]
    Dim dataArray() As String
    Dim index,stringLength as Integer

    stringLength=Len(strData) ' In VB.Net use strData.Length

    For index=1 to stringLength
    dataArray(index)=Mid(strData,index,1)
    Next

    [/code]

    [b]I need to know the format of your strData before i can do anything else useful with it.

    Is each byte a separate pin number for 3 consecutive bytes or what?
    [/b]


    Regards,

    Dr M.

  • : 1234 and "1234" and 1234.00
    :
    : Three different types.
    :
    : You still have to tell a program what to do.

    Yes, but it still "knows" that those three values are entirely different.

    : Talk to your computer then and ask it what it reckons about>>
    :
    : 1234 and 2431 , you won't get any response!!
    :
    : Computers like those in Sci-Fi movies that talk to you in a
    : human-like way....they just don't exist yet, in every home anyway.

    What does this have to do with anything? :-P


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]

  • Thanks guys i got it to work :)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories