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 AppGameKit Corner / Problem with Network local variables

User Offline
Joined: 2nd Mar 2023
Posted: 17th Jul 2023 10:37
I want to make my game a multiplayer mode. I tried making messages between devices but it didn't work well and it even seemed easier to code using network network local integers. So I tried it but it doesn't work for some reason.
In my example program seem to be working fine, it connects (every device says it's connected) but they don't get the variables, and it always prints 0. I attached the code I'm usig. I already asked it on Discord but did not get the answer to get it to work.


Login to view attachments
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 4th Aug 2023 02:27
so your network name is "network name on your local network and your computers name is hostname?"

User Offline
Joined: 2nd Mar 2023
Posted: 12th Aug 2023 14:03
Yes, it was a placeholder for testing. If you think it is the root of the problem then I will try to change it, but I assumed that it would not cause any error if i use temporary values for testing.
DBPro Master
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Nov 2023 00:28 Edited at: 18th Nov 2023 00:29
The problem is your code structure is completely fubar. Let's start with the host portion. After it creates the network and listens for clients, it'll go on to an infinite do-loop. There is no condition where it will ever exit that loop and therefore you won't be able to press the other virtual button. It's the same story for "join" portion of your code. And you've used NetID for the serve and client. Use separate variables.

I've never used the networking commands before, and frankly it confuses me. The way the help files make it sound like, you have to grab all clients before you can do anything after creating the network. Which to me is strange behavior as how can any clients connect before the network has been established?

From what I've read in the help docs about these commands and looking at your code, I'd say the client never gets the variable from the server because you're setting "var" before any clients have connected. So unless the server has persistent data and pushes old values to new clients (highly doubt it) then "var" simply doesn't exist when you try to read it. I don't really like how GetNetworkClientInteger() returns 0 if there's nothing to read. What if I wanted to send a value of 0 to clients?

This is untested and I barely have an understanding of the multiplayer commands, but I *think* this would work.

Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2023-12-04 19:30:34
Your offset time is: 2023-12-04 19:30:34