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 / The Mid Function(For Multiplayer)...

Author
Message
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 23rd Jul 2004 16:03
I Don't Understand What The Mid Function Does, And How I Can Use It In A Multiplayer Game To Send Multiple Parameters In One String.
I'm Trying To Make A Chatroom That Allows Players To Set A Color For The Messages That They Send. I Plan To Add More.

Here Is The Code So Far:


There Is Another Problem : The Messages Are Printed May Times Instead Of Once. How Can I Solve These Problems.

Here Is What Help Said About The Mid Function:

MID$
This command will extract a character from the string provided. The return string will contain a single character extracted from the
string specified. The value provided should be an integer value.

SYNTAX
Return String=MID$(String,Value)

So What's Value?

Also, I'm New To Multiplayer In Darkbasic Pro, Not Darkbasic Pro, And I Used A Certain Code To Get Multiplayer To Work. The Author Should Be Able To Recognize It Because Of The Input Command Under The Wait Key.

-Ilya
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Jul 2004 16:52
The value is the position of the character you want to extract e.g




y$ will be "N"

BatVink
http://biglaugh.co.uk/catalog AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 23rd Jul 2004 22:37
if you want a proper mid function, as well as a slew of other proper string and file functions check out out plugin - thanks


DBP_NETLIB_v1.4.3 - 65 FREE Functions * Click Logo
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 24th Jul 2004 02:46
Ok. I Think I Know How To Add Multiple Varibles In A String.
But How Do I Stop The Text From Being Printed Multiple Times.

-Ilya
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 24th Jul 2004 03:08
How Do I Convert A String To An Integer?

-Ilya
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 24th Jul 2004 03:29
str to integer in dbp is VAL()


DBP_NETLIB_v1.4.3 - 65 FREE Functions * Click Logo
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 24th Jul 2004 03:33
I Get The Error: Subscript Must Be An Integer Or DWord When Refrencing An Array On Line 47 With This Code:


-Ilya
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 24th Jul 2004 06:57
[BUMP]

-Ilya
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 24th Jul 2004 10:45
okay, MID$(A$,X) a character of A$ at column location X. That's all it does. If you want to like, tokenize the string, you need a starting value, it's length, and the token separator character to create a "parse" routine like Next_word(string, value).

Tell us what you're after and I'm sure we can help...
S.

Any truly great code should be indisguishable from magic.
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 24th Jul 2004 11:03
In The Multiplayer Technical Document, It Sais You Can Put Multiple Values In One String, And Extract Them With MID When They Are Recieved. I Am Trying To Make A Chat With Diffrent Colored Text Using The DBPro Multiplayer Commands. Each User Choses A Color, Then Dicides If He Is A Server Or Client, Then Starts Chatting. When He Sends A Message, It Should Be A Certain Color On The Reciver's Machine(The Color That The Sender Choses). When He Recieves A Message, It Should Be The Color The Sender Choses. The Sender's PC Sends 2 Varibles In One String, And The Reciever's PC Recievs The String And Extracts The Varibles. One Is An Integer And One Is A String. Then The Ink Command Is Called With The Parameters: The Integer,0. Then The Text Is Printed Once. The Problem Is I Don't Know How To Send Two Varibles In One String, Then Unpack Them And The Message Is Printed Multiple Times.

-Ilya
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 24th Jul 2004 18:38
Hmm....

That is very interesting. For if it is correct, then MID$ should do the tokenizing for you. Somehow, given what the local operation does, I find this difficult to accept. It would mean that two different operations are under the same programming token, so there would be a confuston about the two. Perhaps MID$() isn't the function quoted? Was it MID() as in a function call to a code segment to a token routine? I cannot see doing token extraction timely using mid$(), but it is possible if the main loop was short. I'd use blocks myself, but that's me. Do you have any comments?
S.

Any truly great code should be indisguishable from magic.
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 25th Jul 2004 02:45
In The Technical Document:
Quote: "
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 Must've Missed That Part.

-Ilya
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 25th Jul 2004 02:52
Oh goodness! You have to make the parser yourself. That's going to be fun...
S.

Any truly great code should be indisguishable from magic.
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 25th Jul 2004 03:11
Works Now!


-Ilya
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 25th Jul 2004 04:08
Doesn't Work On LAN For Some Reason. Someone Know How To Get It To Work On LAN?

-Ilya
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 25th Jul 2004 13:08
[BUMP2]

-Ilya

Login to post a reply

Server time is: 2024-11-27 02:22:04
Your offset time is: 2024-11-27 02:22:04