Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Breaking Down Packets

Author
Message
Penguin Boy
19
Years of Service
User Offline
Joined: 22nd Apr 2006
Location:
Posted: 20th Sep 2006 07:25
Ok, reading through the multiplayer tutorial for DBP it mentions somthing about "Breaking down packets".

It states:
So the player sending their data would have a packet string that looks like this (using "*" as a divider between each value):

packet$=playername$+"*"+str$(camera position x())+"*"+str$(camera position y())+"*"+str$(camera position z())+"*"+str$(camera angle x())+"*"+str$(camera angle y())+"*"+str$(camera angle z())+"*"+speed$+"*"+fireweapon$+"*"+ping$

The receiving player would then see something like this in the received string when the packet is detected:

"Bill10424*543.1122*58.2311*801.8790*44.3250*172.0093*94.2210*15*0*2480"

The received string can then be broken down within the program using the "*" dividers and assign the values to the needed variables. This can be done by getting each digit using the mid$() command until the value equals "*", then advance to the next needed value.


I looked up the mid$() command, but i still don't understand how to actually "break it down", can somone please explain how to do this to me? Even better could somone please post a code snippet?

God you're ugly...
Sonic 91 Software
20
Years of Service
User Offline
Joined: 19th Mar 2005
Location: In a Cryptic Crossworld!
Posted: 20th Sep 2006 09:36
Quote: "Ok, reading through the multiplayer tutorial for DBP"

this is the DB forum, not the DBP forum.

I am a Christian and I know that God loves me. That is what makes my life so great!
Penguin Boy
19
Years of Service
User Offline
Joined: 22nd Apr 2006
Location:
Posted: 20th Sep 2006 09:52
Whoops!

God you're ugly...
Ginga
18
Years of Service
User Offline
Joined: 3rd Jul 2006
Location: Dorset, England
Posted: 20th Sep 2006 13:17
hey penguin. The process would be the same for either version.

Theres 2 ways i use to do it, which way you should use depends on if you know how many variables are within the packet.

First Way - Knowing how many

The Second way - Not knowing the total variables
Its pretty much the same, but you need to count the "*"s first

Login to post a reply

Server time is: 2025-05-26 00:22:28
Your offset time is: 2025-05-26 00:22:28