View Full Version : publicvariables and desync
Jun 11 2009, 03:28
i have a script that counts the number of players in an area and adds that number to a figure every second (its basically a numerical version of a progress bar). this script runs on the server, however i've designed a hud that pops up when the player enters the area that displays the progress of the area cap. of course that means i have to broadcast the progress via publicvariable to the player, and so at the moment im broadcasting the progress every second. my question is, will this cause desync in a multiplayer game?
i could only broadcast every 10 seconds or so etc, but obviously frequent updates are more desirable.
If you can try using the new public broadcast of the setvariable command rather than publicVariable "var". It works the same as this: http://community.bistudio.com/wiki/setVariable_(VBS2) My experience suggests that it can take up to a couple of seconds for a publicVariable to be updated across a network so you probably don't want to be updating the variable any faster than that. Also would it be possible to have the progress bar client side based on a timer for movement. The public Variable would initiate the progress bar but it wouldn't need any new variables to be sent - instead you could check for a second public variable to halt or reset its progress.
Jun 11 2009, 03:54
unfortunately the progress bar isnt as simple as i made it out to be, the increment the progress bar increases by is determined by the number of enemies/friendlies in the area, and as such it would be hard to syncronise this checker across all clients. plus you can leave the area and come back in while the progress still increases on other clients, so its not as simple as just initializing the counter.
so you think using setvariable would be ok if i set it every second? or still maybe increase the interval a bit...
Yeah not sure of the answer to this, I guess the only way to know is to suck it and see (not much help I know). As long as the script is only being run on the server (ie. the pv are being sent from there) and there aren't too many other scripts sending public variables in the background and clogging up bandwidth a shorter time might be oK.
Jun 11 2009, 04:21
ok i'll just use setvariable for the time being, and when we have a proper multiplayer game i'll be sure to post my findings.
thanks for the help :)
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.