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.

Newcomers DBPro Corner / multiplayer q

Author
Message
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 1st May 2003 01:39
hey guys i just got dbpro as a gift, so anyways im exploring multiplayer commands and, not having any experience with multiplayer i have a few questions
probly easy ones but oh well

anyways first off, if i am making a game that uses client/server connections, and i write a program to be the server, how can i send a message to the server so it can decide what to do with it?

do i just make the server the first player in every game?

the question might not make sense but it makes sense to me so pls help out
thanks guys

p.s. ill post more questions as i progress through the help files
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st May 2003 02:24
Have you read the 'Multiplayer secrets' tutorial? Although it's a bit vague in places, I managed to work it out using the tips in there.

You'll find it here on your machine:
C:\Program Files\Dark Basic Software\Dark Basic Professional\Help\documents

If you need any help after reading it I'll be glad to help
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 1st May 2003 08:12
ok so im using the command send net message string$

but its returning the error
"Parameters do not match 'Player Number, String' at Line x"

Player Number is a, which = the value of a for/next loop
string$ = net message string$()
Nilrem
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 1st May 2003 11:03
I haven't read the tutorial, but from my experiences of the net send command it is net send ip# message, but your message part is string$ and your string$ isn't a string is it though....

Hope I'm making sense I'm very new to DBP too.

I hear and I forget. I see and I remember. I do and I understand.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st May 2003 20:50
Can you actually show me code that you are using (just a short snippit)?
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 1st May 2003 21:48 Edited at: 1st May 2003 21:48
sure

fyi im using a client/server type connection and i have a program for the server and a different program for the client

when the server is running, the client can connect to it and as of right now thats it

im trying to get the client to send a message to the server, which then decides what to do with it

for some reason though, the message either isnt going through, or the server isnt picking it up properly

heres the 2 code snippits that handle sending/recieving

client side


the server code that recieves the message is in the source box
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd May 2003 01:24
I don't think you need anything so complex in your server code. This version of 'direct_message' would do the correct job:



But I don't think that is where the problem is. In your client code, you are using a variable mystring$ - have you made it a global variable? Are you calling the function within a loop?

I think I'm going to need to see a bit more of the code. Can you post it here? Or if you prefer, zip it up and email me
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 2nd May 2003 05:44
one sec, ill post the code
i just have to edit out my ip
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 2nd May 2003 05:46
server code


client code
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 2nd May 2003 05:47
actually i dont even know if im using the client/server thing right....

ive never done any multiplayer programming before so this is all new to me
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd May 2003 15:12
Ok, I'll have another look this evening at home
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 2nd May 2003 18:00
cool thanks
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd May 2003 22:22
Here you go

It's a bit different from what you started with I'm afraid. For a start, I've put both pieces of code into a single program for easier editing - you should find it easy enough to split them apart if you need to, and the main loops are completely rewritten.

Just change the IP in each section (an isolated home network) and off you go. Just make sure to give the server plenty of time to start up before you try to connect with the client.
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 3rd May 2003 00:22
thanks alot man
i coudnt figure out what i was doing wrong
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 3rd May 2003 00:29
another question i have is how can i handle different messages of the same type?

lets say i want the player joining to braodcast their alias to everyone else when they join and store it in an array on each client computer, how can i differentiate between that and any regular message?

sorry for having dumb questions
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd May 2003 04:13
Each player passes their name already when they connect using JOIN NET GAME. This is accessible to everyone connected already - just use PERFORM CHECKLIST FOR NET PLAYERS to get the name in the checklist.

Just use something like this to get the name (untested code) :



Then you can find out any players name like this:

matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 3rd May 2003 21:39
oh ok i had tried doing that but it returned an error, but now that i think about it the error was for something else

lol sorry guys
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 3rd May 2003 23:07
ok so along with my last question, is there a trick to sending different messages of the same type and interpreting them differently?

like say im gonna send the coordinates of a player using a real number, now i want to send the rotation of the player using a real number

then i want to send the amount of damage done by a player using integers, then i want to send the amount of gold a player has as an integer, how can i format all these net sends so that the program will be able to differentiate between which message is the attack damage and which is the gold carried etc...
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 3rd May 2003 23:41
another thing i just noticed, when im connecting clients to my server, the server counts as player 1, and each consecutive connection should be one higher, but what i found is that the first player after the server is still considered player 1, and the next player after that is player 3...

for some reason it is skipping player 2...
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd May 2003 23:54
You don't

To be honest, the integer/float send message commands are not really a lot of use. You should stick to using strings/memblocks to send your information.

My *feeling* on this is that you should use strings for 'chat', and memblocks for everything else. Although you could use either one for either purpose - it's up to you.

Also, bear in mind that you are only allowed to send 1 message per sync. If you try to send more, your extra messages will be queued until the next sync. So you need to try and pack as much information into as little space for each send as possible.

Also, if you don't move, you don't need to send new coords. If you aren't buying or picking up gold, then your gold value isn't changing, so you don't need to send that. It pays to put a lot of thopught and effort into your network code
matt rochon
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: Canada
Posted: 4th May 2003 00:47 Edited at: 4th May 2003 00:48
ok that makes sense

i figure ill just desing a memblock with all the information needed for each update

thanks alot

EDIT: will "fastsync" send the messages too?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th May 2003 01:29
It seems to work OK with the chat program.
Xlimun
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 5th May 2003 21:21
I also havn't done anything like this yet but I was wondering, does the server/client use a default port and can it be changed?

Try not to become a man of success, but rather try to become a man of value.
--Albert Einstein

Login to post a reply

Server time is: 2024-09-20 07:48:48
Your offset time is: 2024-09-20 07:48:48