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 / Need help with multiplayer specifics using DBC Enhanced.

Author
Message
ghtry
19
Years of Service
User Offline
Joined: 6th Jun 2007
Location:
Posted: 6th Jun 2007 11:26
To begin with I can't express how embarrassing it is for me to post for help while trying to accomplishing a particular task. I have successfully setup a client/server chat program/(game?) which sends messages as expected. My real problem comes in to play while trying to use the NET MESSAGE PLAYER FROM() integer identifier. I am attempting to get the string name of a player who sends a chat string message. The closest I have come to success was using PERFORM CHECKLIST FOR NET PLAYERS with the CHECKLIST STRING$() function. Any help is greatly appreciated.

Always remember: what goes around comes around.

I am attaching my current half-working code. It is well commented in my opinion and hopefully helps whoever to see what I am tryign to accomplish.
SimSmall
21
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 6th Jun 2007 16:43
basically, something like, a message comes in, and you want the server to attach the name of the person who sent it?

net message player from() returns the the checklist value a of the player who sent the message, so you need a loop to search all entires in the checklist for the matching checklist value a - and attach that checklist string instead .. at least, that's what I think you mean
ghtry
19
Years of Service
User Offline
Joined: 6th Jun 2007
Location:
Posted: 7th Jun 2007 05:57
SimSmall: The major issue I am having is with the ID Integer Number getting changed. I kept trying different ways to accomplish keeping the integers in order. Using an array becomes useless when DarkBasic changes the ID value.

EXAMPLE:

* I host a using DarkBASIC marking 'ghtry' as server with ID 1.
* When a new player joins, Let's say they called thirself 'Venom'
The ID of Venom is 1 and ghtry becomes 2. Instead of Venom being
successfully assigned the 2 value.

So if I hada list of names, parsay... DIM namelist$(100), trying to get the name of namelist$(1) would give me "ghtry" when the system has changed this information to reveal Venom.

I tried both 1(p2p) & 2(client/server) CREATE NET GAME modes. The ID behaviour is the same just with mode 2 the server has to have code written that relays data where it needs to be.

I tried using the MultiSync plugin and it works but the server-side programs crash when you try closing them (Not exactly an error but gets annoying). I also seen a tempest plugin which admittedly I have not tried. If there is any fix/method/solution that would allow me to use Native DBCe commands where might I begin searching for them.

Best Regards
Anthony
ghtry
19
Years of Service
User Offline
Joined: 6th Jun 2007
Location:
Posted: 7th Jun 2007 06:13
SimSmall: The major issue I am having is with the ID Integer Number getting changed. I kept trying different ways to accomplish keeping the integers in order. Using an array becomes useless when DarkBasic changes the ID value.

EXAMPLE:

* I host a game using DarkBASIC marking \'ghtry\' as server with ID 1.
* When a new player joins, Let\'s say they called theirself \'Venom\'
The ID of Venom is 1 and ghtry becomes 2. Instead of Venom being
successfully assigned the 2 value.

So if I had a list of names, parsay... DIM namelist$(100), trying to get the name of namelist$(1) would give me \"ghtry\" when the system has changed this information to reveal Venom.

I tried both 1(p2p) & 2(client/server) CREATE NET GAME modes. The ID behaviour is the same just with mode 2 the server has to have code written that relays data where it needs to be.

I tried using the MultiSync plugin and it works but the server-side programs crash when you try closing them (Not exactly an error but gets annoying). I also seen a tempest plugin which admittedly I have not tried. If there is any fix/method/solution that would allow me to use Native DBCe commands, where might I begin searching for them?

Best Regards
Anthony
waffle
23
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 9th Jun 2007 09:28
I remember when this confused me. I found that all players were always player 1. So you need to look at all the numbers ...
There is a LID (local ID) for each user and a GID (global ID).
lets say you have 4 players....

First lets look at the Host ....
LID 1 = Host Player, GID 1
LID 2 = Player 2, GID 2
LID 3 = Player 3, GID 3
LID 4 = Player 4, GID 4

Then, Player 2
LID 1 = Player 2, GID 2
LID 2 = Host, GID 1
LID 3 = Player 3, GID 3
LID 4 = Player 4, GID 4

The Player 4
LID 1= Player 4, GID 4
LID 2= Host, GID 1
LID 3= Player 2, GID 2
LID 4=Player 3, GID 3

NOTE: GID may be any intiger, but the value
will indicate the order the players intered the game.
example: 345 entered before 456

Also, LID increments during game play.
Example:
after player 4 enters the game, Player 2 Leaves.
All IDs remain the same. But when the next player enters,
he will be LID = 5 for the other players,
although still LID = 1 for himself.

I hope this helps remove some confusion.
extra help is here:
http://archonrpg.com/zips/skisource.zip
but you will also need the media here:
http://archonrpg.com/zips/skirace.zip
ghtry
19
Years of Service
User Offline
Joined: 6th Jun 2007
Location:
Posted: 12th Jun 2007 13:09
waffle:

I am aware that there are different Integer Identification Numbers given to players who connect. There is also checklist values A,B,C,D. One gives a general integer ID (The changing confusing one) and the other gives a unique ID which, according to the help, never changes even if the user switches machines. I am having trouble getting a constant ID to associate with an array which would hold data that I can change and use throughout a game session.
As I stated earlier, DarkBASIC first assigns the number 1 when only the host has joined the game. When another player joins, the host ID becomes 2 and the new player gets 1. So when I access the array with the number 1, (Expecting to get host data), I am getting the newly joined player. The ID's work like this (As I have observed):

* Host joins and gets ID 1
* 2nd player joins, gets ID 1, Host gets 2
* 3rd player joins, gets ID 2, Host gets 3
* etc...

I successfully worked a function to scan and verify that my data array is correct but it is just an annoying issue to deal with. I gave 30 USD at Hastings for the DarkBASIC software. Forgive me for saying so but I feel somewhat cheated buying DarkBASIC Professional. I enjoy DarkBASIC and how 1 command does so many C++ commands in the background, but my requirements forced me back to the unforgiving C++ language anyway. The source code and media you posted in your link was extremely useful and showed me a few things I can actually modify and use where I thought not possible in DarkBASIC.
Thanks for all the help and feedback. I wish the game creators luck in their quest to create a great piece of software allowing users to build their own games and fullfill their dreams.

Best Regards
Anthony
ghtry
19
Years of Service
User Offline
Joined: 6th Jun 2007
Location:
Posted: 12th Jun 2007 13:16
waffle:

Sorry about my last post, please disregard it. You're right actually. I was not quite aware of a local and global ID. Just curious though, would you happen to have any source code to easily demonstrate a FLAG=2 (Client/Server) Chat System that I might use. I have tried many languages and DarkBASIC is QBasic friendly in syntax and I found myself quickly productive in it after learning the QBasic language.
Thanks again for the help and next time I will read your posts a bit slower before replying.

Best Regards
Anthony
waffle
23
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 15th Jun 2007 10:20
No, I never did any work (in DBC) using client/server (C/S)...
I stuck with P2P which is very simple in DB.
Although my BumperPool and Tank game are Client/server using TCIP,
but that uses a very different language.

The theory of C/S should be very simular to P2P as long as you only have two players. Once you go to 3+ users, the Host begins doing alot of extra work, Since all global updates need to be sent multiple times (once for each player). Also, for a client to "talk" to another client requires the message go first to host, then the host must decide to resend to the other clients ....

P2P is much easier to manage code wise, all users work the same way.

And thank you for examining my code. It helps me feel usefull whenever someone examins my stuff.
waffle
SimSmall
21
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 15th Jun 2007 12:20
Sorry, I didn't see that you had trouble with what I posted...
Yes, when a new player joins, their position in the checklist is always 1, but the player's checklist value a stays with them until they disconnect.

Lets suppose you create a game, you are currently the only person in it, your checklist value a, is 1. so checklist value a(1) would be 1
Now, I join, I am first in the checklist, you are second in the checklist. checklist value a(1) is now 2 (that's my ID), checklist value a(2) is now 1.

So, when trying to determine a player, suppose you know their name, create a loop which runs as many times are there are entires in the checklist, check the current checklist string, to see if it matches. If it does match, the corresponding checklist value a is the player's ID.

The hardest idea to get around using the built-in multiplayer commands, is that a player's position in the checklist is not necessarily their ID.
waffle
23
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 17th Jun 2007 04:24
Actually, the trickiest part for me was determining
player start positions ....

I solved that by first doing a "chat" room.
This is to handle any number of players, either coming or going.
Then, once the actual game is started,
No other players can join.

Then, I sort the list based on the Player Unique ID
NOT the Player Local ID.

Then, from this list, I determine which is player 1,2,3,4 ...
and can easily assign starting locations, colors and so on.

If A player leaves after game start, that player's data gets
erased and hidden from view. And no longer gets updated.

Thats the method used by Archon3D, BS3, Ski, and DuelPro (for DBPro).

Login to post a reply

Server time is: 2026-07-05 18:38:38
Your offset time is: 2026-07-05 18:38:38