Results 1 to 9 of 9

Thread: Scripts on Dedicated Server don't work properly

  1. #1

    Scripts on Dedicated Server don't work properly

    I'm currently trying to port my mission to COOP on a dedicated server. While doing this I encounter that the scripts I wrote for SP oder COOP on a non-dedicated server are not working for the dedicated server.
    One example:
    I'm trying to do a HALO insertion and use an addAction to the airplane my group is in with the following script attached:
    Code:
    if(!isDedicated) then
    {
    	player action [ "eject", vehicle player];
    	sleep 0.1;
    	player setdir 0;
    	[player] exec "ca\air2\halo\data\Scripts\HALO_getout.sqs";
    	player setvelocity [120*0.8,0,0];
    }
    The "sleep 0.1" is mandatory otherwise I fall without a parachute. The setdir and setvelocity have no influence for the dedicated server (which is kinda annoying). When scripting for a non-dedicated server the single line [player, 1950] exec "ca\air2\halo\data\Scripts[CODE]\HALO_init.sqs"; suffices instead of ejecting and HALO_getout.

    While this is strange enough, until now I was not able to convert the following script to a format that is working for a dedicated server

    Version 1:
    Code:
    waitUntil {getPosATL player select 2 < 25};
    if(isServer) then
    {
    _scatterHeight = -20;
    {
    	if(!(isPlayer _x)) then
    	{
    		// stupid AI drifts off several kms if not done
    		_x addEventHandler ["HandleDamage", {false}]; 
    		unassignvehicle _x;
    		_x setpos [ (getMarkerPos "mrkrInsertion" select 0) + (random 40) - 20, (getMarkerPos "mrkrInsertion" select 1) + (random 40) - 20, 100 - _scatterHeight];
    		_x flyinheight (100 - _scatterPos);
    		_x setvelocity [(random 6)-3,(random 6)-3,0]; 
    		[_x, (100 - _scatterHeight)] exec "ca\air2\halo\data\Scripts\HALO_init.sqs";
    		_scatterHeight = _scatterHeight + 10;
    	}
    } forEach units playerGroup;
    }
    Version 2:
    Code:
    if(isServer) then
    {
             _scatterHeight = -20;
    	{
    		if(!(isPlayer _x)) then
    		{
    			// stupid AI drifts off several kms if not done
    			_x addEventHandler ["HandleDamage", {false}]; 
    			unassignVehicle _x;
    			sleep 1;
    			_xChute = createVehicle ["Parachute_US_EP1", [(getMarkerPos "mrkrInsertion" select 0) + (random 40) - 20, (getMarkerPos "mrkrInsertion" select 1) + (random 40) - 20, 50 - _scatterHeight], [], 0, "FLY"];
    			_xChute setPos [(getPos _xChute select 0), (getPos _xChute select 1),  50 - _scatterHeight];
    			_xChute setDir (random 360);
    			_x setPos [(getPos _xChute select 0), (getPos _xChute select 1),  50 - _scatterHeight];
    			_x moveInDriver _xChute;
    			_scatterHeight = _scatterHeight + 10;
    		}
    	} forEach units playerGroup;
    }

    The goal of that script is to drop the AIs of the group near the landing place. Both works well for non-dedicated. For dedicated the chutes drop empty (in Version 2) and the AIs are falling of the airplane wherever the current location of that is.

    I'd really appreciate some help in converting the second part to a dedicated server compatible format.
    I'd also love to get some insight why the scripts for the dedicated server have to differ - is there a point of view making this reasonable?
    Last edited by Behemeth; Aug 21 2012 at 05:46.

  2. #2
    Gunnery Sergeant Mikie boy's Avatar
    Join Date
    Jun 20 2009
    Location
    United Kingdoom
    Posts
    472
    if using from addaction - change player in the script - make it a different variable

    _dude = _this select 0;

    remove (!is dedi) no need in this case - if again using from addaction
    [FOCK] Mikie J

    Looking for New Players at Fockersteam
    http://fockers.moonfruit.com/

    A2/OA
    COOP Most Wanted - [Fockers] Most Wanted Co-x v07-09-2012
    Fock IED - http://www.armaholic.com/page.php?id...highlight=FOCK
    Fock Recruit/Group Management - http://www.armaholic.com/page.php?id=20580

    A3
    TvTCache Hunt - [FOCK]ers Cache Hunt TvT-x [ALPHA]
    Scripting Tutotial -http://www.armaholic.com/page.php?id=20465#comments
    Fock Recruit/Group Management - http://www.armaholic.com/page.php?id=19041

  3. #3
    Private First Class
    Join Date
    Jul 3 2012
    Posts
    23
    Author of the Thread
    Hello Mikie boy,

    Quote Originally Posted by Mikie boy View Post
    if using from addaction - change player in the script - make it a different variable

    _dude = _this select 0;

    remove (!is dedi) no need in this case - if again using from addaction
    thank you. Since the action is attached to the aircraft I need to use _dude = _this select 1 as far as I understood; The first part works with your changes. Yet it didn't yield any improvement: the simple version with the HALO_init.sqf which works on non-dedicated server doesn't work with _dude = _this 1 either, and setVelocity/setDir is still being ignored.

    Any idea on that - and of course on the second part where I place the AI?
    (The second part is not executed via the Action, but when the aircraft activates a trigger by its position)
    Last edited by Behemeth; Aug 21 2012 at 05:47.

  4. #4
    setDir and setVelocity must be local to the unit that you're performing it on. If the player is the leader of a group, the AI is local to him and thus the server cannot do setDir and setVelocity commands on them. What you need to do is make sure that the player runs the script and not the server.

  5. #5
    Private First Class
    Join Date
    Jul 3 2012
    Posts
    23
    Author of the Thread
    Quote Originally Posted by cuel View Post
    setDir and setVelocity must be local to the unit that you're performing it on. If the player is the leader of a group, the AI is local to him and thus the server cannot do setDir and setVelocity commands on them. What you need to do is make sure that the player runs the script and not the server.
    Hello cuel,

    Is this also valid for setPos? This would explain why AI placing didn't work.
    But for setDir and setVelocity: 1) I made sure it's not the dedicated server executing the script. 2) since it gets called by the player (it's an action) the server shouldn't execute it anyway.

    Did I understand something wrong?

  6. #6
    No, setPos does not have to be local to the object you're performing it on.

    If you're talking about the first script, it should work. Have you tried adding a simple hint to see if it actually runs?
    The second script has an if (isServer) then {}; statement.
    You're saying that setDir and setVelocity has no "influence" for the dedicated server, - I'm not quite following.

  7. #7
    Private First Class
    Join Date
    Jul 3 2012
    Posts
    23
    Author of the Thread
    Quote Originally Posted by cuel View Post
    Have you tried adding a simple hint to see if it actually runs?
    I can confirm that both scripts run.

    Quote Originally Posted by cuel View Post
    The second script has an if (isServer) then {}
    I added this to have the AI ejection and placement only executed once. Especially for version 2 I would otherwise execute the script for every player and therefore create too many parachutes

    Quote Originally Posted by cuel View Post
    If you're talking about the first script, it should work (...) You're saying that setDir and setVelocity has no "influence" for the dedicated server, - I'm not quite following.
    The first script does work for SP or non-dedicated server:
    - ejecting, halo, setDir and setVelocity
    for dedicated server
    - ejecting and halo works but I'm always looking in the same direction and having no velocity in x,y no matter what i set the setDir, setVelocity

    The second script (both versions) for SP or non-dedicated server:
    - ejecting, setPos, halo, setVelocity, setDir (all works perfect)
    for dedicated server
    - setPos doesn't work for AI's, they simply eject from the airplane and fall down where they ejected

    Thanks for the help
    Last edited by Behemeth; Aug 22 2012 at 12:27.

  8. #8
    Maybe try this script. It's not ideal but should work and you should be able to combine it with an addAction.

  9. #9
    Private First Class
    Join Date
    Jul 3 2012
    Posts
    23
    Author of the Thread
    OK guys... the first mystery is "solved". It seems that the dedicated server is a rather slow-paced guy.

    Code:
    _requestingUnit = _this select 1;
    
    _requestingUnit action [ "eject", vehicle _requestingUnit];
    sleep 0.1;
    _requestingUnit spawn bis_fnc_halo;
    sleep 0.1;
    _requestingUnit setvelocity [0,120*0.8,0];
    _requestingUnit setdir 0;
    With those sleeps all works as it should. The question why this sleep is needed is open though - and the question whether the script will now work an any dedicated server or if it may happen that some other dedi is slower than mine and would need a longer sleep.
    Summing up it's not a very convenient solution. But better than none.


    Quote Originally Posted by Wolfenswan View Post
    Maybe try this script. It's not ideal but should work and you should be able to combine it with an addAction.
    Sadly that's not what I'm trying to do - this script will just eject the AIs, but I want to use setPos on them in order to avoid broad scattering of the group.

    I will try to add sleeps randomly for the second problem now and see if I reach a constellation for which it works...

Similar Threads

  1. Scripts not working on dedicated server
    By ZenWarrior in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 5
    Last Post: Jul 26 2012, 00:16
  2. Markers not showing up on dedicated server. REspawn not working properly
    By Daimyo21 in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 5
    Last Post: Sep 17 2010, 04:55
  3. Scripts at a non-dedicated server
    By McArcher in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 1
    Last Post: Jan 20 2010, 14:00
  4. Way to test new scripts on a dedicated server
    By norrin in forum ARMA - MISSION EDITING & SCRIPTING
    Replies: 6
    Last Post: Feb 26 2007, 22:30
  5. Waypoints don't work on dedicated server properly
    By Iron Eddie in forum ARMA - TROUBLESHOOTING
    Replies: 2
    Last Post: Dec 11 2006, 15:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •