Jump to content

Multiplayer syncing problems


Arska134
 Share

Recommended Posts

This is not quite Leadwerks question, but i hope there is some clever people who can give me some tips to get my code working right. I asked this already in Blitzmax forum, but i can't get answer so i'll try my luck here.

 

So problem is that code works as expected with 2 players, but when third one joins in... Models starts to flickering, because models position changes constantly.

 

Here is multiplayer part of my code:

http://pastebin.com/raw.php?i=TSrmvMSF

 

Here is network variable info:

remoteobj 0 = PlayerID (player's unique ID)
remoteobj 1 = Nickname (player's nickname)

remoteobj 2 = X (player's X coord) 
remoteobj 3 = Y (player's Y coord)
remoteobj 4 = Z (player's Z coord)

remoteobj 5 = RX (player's pitch)
remoteobj 6 = RY (player's roll)
remoteobj 7 = RZ (player's yaw)


remoteobj 8 = health (player's health)
remoteobj 9 = cash (player's cash)

remoteobj 10 = flashlight (player's flaslight status)

remoteobj 11 = connected (player's connection status)

 

I'll ask another question too. I need to sync daytime with all players. I'am using this script:

http://www.leadwerks...y-night-script/

 

 

I really appreciate your help. My project is kinda frozen, because of these problems.

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
Share on other sites

Have you considered using network interpolation. Its tricky to get right but makes things smooth.

 

Have a read here https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

I think i know what is wrong, but i can't come up with any solution to fix it.

 

So now program knows who is local object and who is remote, but when there is 2 remote objects it thinks those are same... I really really appreciate any help you can give me. I am so out of ideas in this one. :/

 

I don't even know is the problem in my dedicated server or client side.

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
Share on other sites

For remoteObj = EachIn objList

 For Local p:PLAYERS = EachIn playerList

Why two cycles?

Hmm.. i don't even noticed that. But thanks. :)

 

Problem still exist, help needed.

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
Share on other sites

Thanks Daimour's help i get some more information about this problem.

 

So problem can be server side too. Here is Dedicated server code:

http://paste.servut.us/plain/gu4s

 

 

Here is some server log:


Player Arska134(0) has joined the game!
Players on server: 1
Player test(1) has joined the game!
Players on server: 2
Player test(0) has disconnected!
Players on server: 1
Player test2(2) has joined the game!
Players on server: 2
Player Arska134(0) has disconnected!
Players on server: 1
Player test2(0) has disconnected!
Players on server: 0

 

As you can see between brackets is player ID and that is different when disconnecting.

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
Share on other sites

I've learned a little about GNet. And I like it very much. It's the simplest thing for networking I've ever seeing.

 

In your case you don't need all that code on the server side. Because all work is going on the client side.

Simplify your code as much as possible for debugging purposes.

 

Try to replace server side code with this:

Local port = 80 ' users would normally choose one allowed through their firewall
Local servername$ = "Freezing_world_server"+Rand(1000, 9999)

Local success
success = GNetListen( host, port )
If Not success Then RuntimeError "Cannot create server!"

Repeat
Delay 10 ' allow other apps some cycles to minimize CPU use
PollEvent
GNetSync host
Until EventID() = EVENT_WINDOWCLOSE

 

So since nothing happens on the server side you can easier debug your client side code.

  • Upvote 1
Link to comment
Share on other sites

Guest Red Ocktober
Because all work is going on the client side.

 

if this is true, that's most likley the cause of your problems...

 

i'm of the faith that all the work should be done on the server, and the (lightweight) client should only take user input, send it to the server and receive the synced values that'll determine the "ghosted" positions and orientations mimicking the synched objects as they appear on the server...

 

--Mike

Link to comment
Share on other sites

I'll start to debuggin as soon as possible when i have time. If i get solution for this, i will post it.

 

If someone solves this problem before me, let me know solution. That would save me lot of time.

 

 

Edit:

It's now fixed. Huge thanks for Daimour.

 

And there is my another question in first post too. To simplify question: How can i output time of the day from script

Edited by Arska134

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
Share on other sites

How can i output time of the day from script

Use SetEntityKey() function to se tup the time. Or GetEntityKey() function to get the time from script.

This script (entity) has 3 keys: "hour", "minutes" and "seconds". So use these keys.

hour = GetEntityKey(daynight, "hour")

SetEntityKey(daynight, "hour", hour)

Link to comment
Share on other sites

Okay, so i almost got daytime syncing working, but another strange problem come up.

 

Here is code:

http://paste.servut.us/plain/udrk

 

First player gets and sets up time of the day right, but second player get time of the day, but not set it up, so sky is black and looks like there is no sky at all.

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...