Results 1 to 6 of 6

Thread: Sending Types with Winsock

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Posts
    4
    Hi there, any help would be much appreciated...

    i'm programming the network code for a game, and i need to send user defined types using the vb winsock (6.0) control. the senddata function won't let me send a type, it says 'Only public user defined types defined in public object modules can be used as parameters or return types for public procedures of class modules or as fields of public user defined types'

    apparently there's some way to do this using a byte array, but i have no idea how...

    thanks again

    pete
    www.cintelsoftware.co.uk

  2. #2
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355
    hmmmmm i wonder who you could be
    urghhh byte array?
    ur not doing net in a class are u?
    BTW, sII building is 1/2 in

    buzzwords are the language of fools

  3. #3
    New Member
    Join Date
    Jan 2000
    Location
    mount clemens, mi, us
    Posts
    12
    i ran into this too. i had never come across the fact that you can only send standard types until i had almost finsihed a network game (i made the game work as one player then worried about the network part).
    pissed me right off, had to rewrite half the game and still haven't gotten it working well.

    as far as i have been able to find, you can only send standard types and theres no way to force it.

    the way i did it (im sure there is a better one) was to make two functions that would convert the type to a string and back again. the extra processing killed the game, but it worked.

    another thing i did on a different game was make the data_arrival recieve a sort of "script" (the first 3 characters coming in are "mov" so it knows the next x characters are for moving the character. all kinds of fun stuff like that.


    hope something in this mess helps a little


  4. #4
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Hi,

    I'm doing a network game too and I made a script system (A message looks like: "MOVE,Player,10,10"). I also thought about constants for less traffic (Like move = 2, Hit = 3: "2,10,10"). Well, there's no solution to send types directly I think .

    (A way will be to have an array of values instead of named vars... it's very difficult to handle but it would work See some example code:

    Code:
    'Module
    Type tPlayer
       Var( 10 ) As Long
    
       'For example
       '0 = x
       '1 = y
       '2 = Energy
       '3 = Something
       '...
    End Type
    
    Global Player As tPlayer
    
    'Anywhere in Form
    Public Sub SendPlayer
       Dim A As Long
    
       'Send all vars
       For A = 0 to 10
          WS.SendData Player.Var( A )
       Next 
    End Sub
    I think that would work but... ya know

  5. #5
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355
    yeah, that's what he's doing at the moment (we're working on the same game ). But it's soooo much repeated code
    We're thinking of using DirectPlay..
    buzzwords are the language of fools

  6. #6
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Uh, good luck I heared that DPlay is very difficult to use (at least in C)...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width