chris330 0 Posted December 25, 2005 I've just posted this at OFPEC, but thought i'd try here too Dear all, I have a question. This is a script I have been writing which works fine on single player but has not been tested on multiplayer. There's no need to get bogged down in the script too much all I need to know is because game logic units are always local to the server, does this mean that their positions are always defined on the server and broadcast to the clients? Or, do I have to instruct the client machine(s) to change the postions of the game logics too, or can I just get away with altering their positions on the server? The following script has been made assuming that the client machine(s) do not have to update the positions of the game logics. Rather it has been made assuming that the positions of the game logics in the mission are determined and broadcast globally by the server. Have a look at it. I have annotated the bits I need some clarification on (they are only small parts of the script). Please note it is a camera script which utilises two game logic units. One named cameraeffect1 and one named cameraeffect2. //I think this bit is now okay as I understand that camcreate //must be executed on the client machines too. _camoffx = _this select 0 _camoffy = _this select 1 _helo = _this select 2 _cam1 = "camera" camcreate [0,0,0] _cam1 cameraeffect ["internal", "back"] _cam1 camsettarget cameraeffect1 _cam1 camsetrelpos [0,0,0] _cam1 camcommit 0 #start //If this is not the server machine then goto the loop that //waits for the server to finish the maths. ?not local server : goto "checkserverready" _BankPitch = _helo call GetBankPitch _Pitch = _BankPitch select 1 _sinangle = sin(_Pitch) _cosangle = cos(_Pitch) ;evaluate where camsetrelpos command should set the camera to for _camoffy e = (_sinangle) * (_camoffy) a = (_cosangle) * (_camoffy) //broadcast the camsetrelpos variables to the client(s). publicvariable "a" publicvariable "e" ;get heading of helicopter and evaluate x and y offsets for the game logics for _camoffx _heading = getdir _helo _angle = 360 - _heading _xa = (cos (_angle)) * _camoffx _ya = (sin (_angle)) * _camoffx ;Get position co-ordinates of helicopter _xh = getpos _helo select 0 _yh = getpos _helo select 1 //The interesting bit. Will this automatically update the //game logics' positions on the client? ;Position the game logics cameraeffect2 setpos [(_xh + _xa),(_yh + _ya),0] _dist = _helo distance cameraeffect2 _height = sqrt ((_dist^2)-(_camoffx^2)) cameraeffect1 setpos [(_xh + _xa),(_yh + _ya),_height] cameraeffect1 setdir _heading logiccomplete = true //Client waits for server to finish then camsetrelpos variables //are issued. #checkserverready ?logiccomplete : goto "camerapositioning" goto "checkserverready" #camerapositioning _cam1 camsetrelpos [0,a,e] _cam1 camcommit 0 ~0.001 logiccomplete = false ?camend : goto "finish" goto "start" #finish _cam1 CameraEffect ["TERMINATE", "BACK"] CamDestroy _cam1 exit Share this post Link to post Share on other sites
killswitch 19 Posted December 25, 2005 There's no need to get bogged down in the script too much all I need to know is because game logic units are always local to the server, does this mean that their positions are always defined on the server and broadcast to the clients? Or, do I have to instruct the client machine(s) to change the postions of the game logics too, or can I just get away with altering their positions on the server? The latter - you only change the position of an entity on the machine said entity is local to. In your case it means - alter the positions only on the server. Share this post Link to post Share on other sites
chris330 0 Posted December 26, 2005 Quality Then that means my script should work (says that knowing really that it won't for some reason) Share this post Link to post Share on other sites