Hi. Little Question about networking.

Hi how would i create Visible characters In a client-Server connection? so the other clients can see eachother. Sorry i dont realy know how to explain it… Basicly are there any tutorials or samples to creating a Networked game where users can see eachother? Thanks for any help.

Creating networked games is not one of the easy things to do.

If you are up to the challenge, here is how i did a network setup once:

in this example i have 2 clients and 1 server:
client A connects to server
server creates a object for client A
server sends the list all existing objects to client A
client A loads the models

server sends information updates to all clients

client B connects to server
server creates a object for client B
server sends the list of all exsiting objects to client B
server sends the object of client B to all clients except client B (in this case client A)
client A and B update the models

what you actually want to implement is what happens when client B connects. What i did not cover here is what happens if a clients disconnect. But you might get an i idea how to approach network programming.

Creating the basic network code would be the first step. Start by creating a chat client server. Only if this works fine try to handle objects.

Figure out what data you need to transfer (you most probably you dont want to transfer the 3d model and textures over the network, but the position rotation etc.)

There are examples of network codes in the forums, look at them (and try to understand them).

i hope this helps a bit

Thanks. i kinda understand abit more now. Ive already got a chat interface in place and the client loading maps on the servers request now ime gohna try what you did. So each client has its x y z and the server just echos them to all other clients. Little question .how much data can a datagram hold before being completely uselessly slow?

Yes i will just transfer the x y z first then rotation and animation (Walking = true or false) But i just want players able to see eachother first…

Edit: ARGH I hate not understanding a language. how can i for through all non null instances of a object (In java i would do somthing like for (i=0; i<=users; i++) if object[i] != null)

how much data you can pack into a network datagram before it becomes slow is dependant on the network connection. if you have a 56k modem line you will reach the limit pretty soon.

You also have to think about how many packages you want to send per second. MMORPG’s sometimes only send 1pkg/sec, even most fps shooters dont send more then 20pkg/sec (or less). The more data you pack into a package the less packages you can send. (i cant really tell you exactly)

You will notice that if you only send 1pkg/sec you’re character would look heavily lagging. Whatever package rate you use, you will want to have some smoothing applied to the character. this is done using the SmoothMover, you might also want to send a timestamp with the package you send, so the smoothmover uses the correct timestamp to interpolate the movement.

What i forgot in the last example is the client send mechanism. A client does send updates to the server of it’s own object as well, once it’s created… For example a client has 2 lists of objects, 1 for server handled ones, and one for locally handled ones, the server objects receive the pos/rot from the server the local objects are controlled directly and send updates of pos/rot to the server.

# if users is a list
# preferred type to use
for u in users:
  if u is not None:
    pass # do something
    # you should not (afaik) edit the users list in this case

# if users is a dict
for ukey, uvalue in users.items():
  if uvalue is not None:

# if you want a number (index)
for i in xrange(len(users)):
  if users[i] is not None:
    print users[i]

# this is py2.3 compatible code, this will work for 2.4&2.5 as well
for user in users:
    if user != None:
        # do stuff with "user"

or more Pythonic, using generators:

for user in (x in users if x != None):
    # do stuff with "user"