Jump to content
Purzel

Locality problem on dedicated server. (mixed commands)

Recommended Posts

Hi Folks!

 

how do I get this working on a dedicated server...
Locality is not my friend... and I´m not really good in scripting...

What I want to do:
There's a chopper which is stalling, everybody inside is set to "allowdamage false".

Some warning sounds should be heard and only the players inside should get a short "blackout"...
When the chopper is "down" (and while the blackout!) an area-marker is set on position of the crashsite and an eos-Script is spawning depending on the marker size (300m).
then another script deletes a radius about 200m around the helicopter, so that no enemies are to close to the crashsite and a ring of 100m withe enemies remains.
That all should happen, while the players of the chopper are unconscience ("blackout"),

 

SOLUTION: HERE

 

my problem is, that there are commands which have to played on my dedicated server (like markers, etc.) and some played only on clients machines (sounds, blackout, etc.)

Here are my commandlines with no sequence/order:




explo = "R_60mm_HE" createVehicle (getPos _evacheli);                                                             //explosion
explo attachto [_evacheli, [0,-1.5,0]];

 

[{_evacheli say3D "mastercaution";},"BIS_fnc_spawn",west,true] call BIS_fnc_MP;                        //sound to be played

 

waituntil {(getPosATL _evacheli select 2) <= 0.5};
sleep 2;
_markerabsturz = createMarker ["crashsite", position (vehicle pablo)];
_markerabsturz setMarkerShape "ICON";
_markerabsturz setMarkerColor "colorBLUFOR";
_markerabsturz setMarkerText "   Crashsite";
_markerabsturz setMarkerType "hd_unknown";
_markerabsturz setMarkerPos (getpos (vehicle pablo));
_markerabsturz setMarkerAlpha 1;    

_markerabsturz1 = createMarker ["_markerabsturz1", position (vehicle pablo)];
_markerabsturz1 setMarkerBrush "SOLID";
_markerabsturz1 setMarkerShape "ELLIPSE";
_markerabsturz1 setMarkerSize [800, 800];
_markerabsturz1 setMarkerColor "colorBLUFOR";
_markerabsturz1 setMarkerPos (getpos (vehicle pablo));
_markerabsturz1 setMarkerAlpha 0;                                                                        



nul = [] execVM "eos\OpenMe.sqf";                                                                                                //spawns the enemies

 

{deleteVehicle _x} forEach (nearestObjects [(getMarkerPos "crashsite"),["Men"], 200]);                        //deletes enemies to close to the crashsite
 

 

 

 

[{                                                                                                                                                     // blackout in which all the above should happen                                      
     [] spawn {                                    
        cutText ["", "BLACK OUT", 2];

        private ["_blur"];
        _blur = ppEffectCreate ["DynamicBlur", 474];  
        _blur ppEffectEnable true;
        cutText ["", "BLACK OUT", 12];
        _blur ppEffectAdjust [0];
        _blur ppEffectCommit 0;
        titleText ["Autschn!", "BLACK FADED", 10];
        waitUntil {ppEffectCommitted _blur};
        cutText ["", "BLACK IN", 7];
        _blur ppEffectAdjust [15];
        _blur ppEffectCommit 0;
        _blur ppEffectAdjust [0];
        _blur ppEffectCommit 10;
        waitUntil {ppEffectCommitted _blur};
        _blur ppEffectEnable false;
        ppEffectDestroy _blur;
    };
} forEach units (vehicle Pablo)] call BIS_fnc_execVM;


Maybe someone could give me some hints!
Thanks!

Purzel

Share this post


Link to post
Share on other sites

I got a couple questions:

 

What are you using the R_60mm_HE for? I don't see a point in attaching it to the heli pre-crash. I also don't know why it's a global var but that may just be an oversight, and it's not really that important anyway. 

When are you planning on doing this? If the sequence is at the start stuff like initPlayerLocal.sqf is going to be really useful, but if it's mid mission it's slightly more complicated.

Why BIS_fnc_execVM? Pretty unnecessary, especially in conjunction with [] spawn {}.

 

You may want to look into remoteExec/remoteExecCall instead of BIS_fnc_MP as the former has replaced the latter since Tanoa update. 

 

This all ultimately depends on when you execute this. As it's a dedi you've got a few init files to help you along the way, especially when it comes to creating markers on client's machines, creating the blackout effect etc. However, if you do this mid-mission it'll be slightly more complicated but nothing remoteExecCall can't fix. 

Share this post


Link to post
Share on other sites

The 60 mm HE is attached to the turbine of the chopper, it looks like a jetflame coming out, followed by an explosion. looks pretty nice...
but its just eye-candy...

 

And yes its in the middle of the mission.

I just need the crashsite-marker on every machine, because the stalled team has to be rescued by the other team.
All other marker are only for spawning enemies in them and have not to be seen.

Share this post


Link to post
Share on other sites

Hints anyone?
 

My problem is, to mix dedicated server stuff with clients stuff...
Everybody inside the helicopter should hear the warning-sounds and have a blackout and while this happens, the server should create markers in which enemies spawns around the chopper...
 

Please help me
Thanks

 

Purzel

Share this post


Link to post
Share on other sites

The basic solution of "mixed code" is create a functions global and server side
While running code on server you can at any time remoteexecute a function with pased params on clients
Works either server to players or player to server
 
An example
 
we gathering data from player and send it as params to server with remote execute a server side function

_pos = getPos player;
_player = player;
null = [_pos, _player] remoteExec ["fnc_somefunction", 2,false];

in another direction with command instead

_veh = "C_Offroad_01_F" createVehicle [0,0,0];
[_veh , ["<t color='#ff9900'>Get in Cargo (Left Seat)</t>", {(_this select 1) moveinTurret [(_this select 0), [4]]}]] remoteExec ["addAction",[0,-2] select isDedicated, _veh];

Share this post


Link to post
Share on other sites

Hard to understand... :(


If I want the soundfiles to be played on clientside...

this (from your example)

null = [_pos, _player] remoteExec ["fnc_somefunction", 2,false];

will become this:

null = [_evacheli say3D "mastercaution";] remoteExec ["call BIS_fnc_MP", -2, false];

is that correct?

Especially with all the ; and ( [ { } ] )
It´s really complicated for me...

But how do I get the "blackout" from the first post running, because its a sequence of some more commands...:

[{                                                                                                                                                     // blackout in which all the above should happen                                      
     [] spawn {                                    
        cutText ["", "BLACK OUT", 2];

        private ["_blur"];
        _blur = ppEffectCreate ["DynamicBlur", 474];  
        _blur ppEffectEnable true;
        cutText ["", "BLACK OUT", 12];
        _blur ppEffectAdjust [0];
        _blur ppEffectCommit 0;
        titleText ["Autschn!", "BLACK FADED", 10];
        waitUntil {ppEffectCommitted _blur};
        cutText ["", "BLACK IN", 7];
        _blur ppEffectAdjust [15];
        _blur ppEffectCommit 0;
        _blur ppEffectAdjust [0];
        _blur ppEffectCommit 10;
        waitUntil {ppEffectCommitted _blur};
        _blur ppEffectEnable false;
        ppEffectDestroy _blur;
    };
} forEach units (vehicle pablo)] call BIS_fnc_execVM;

How do I integrate some stuff without breaking up the (local / clientside) sequence?
While its black to the clients (only in the chopper!) the enemies should be created...
Is it possible to break the single commandlines and insert the other stuff?
Like this:

_blur ppEffectAdjust [15];                                    // blurry effect
        _blur ppEffectCommit 0;
        _blur ppEffectAdjust [0];
 -----> PUT IN SOME OTHER STUFF HERE create enemies,etc.      // is this interrupting the clientside effect? because spawning the enemies happens on dedicated server...
        _blur ppEffectCommit 10;
        waitUntil {ppEffectCommitted _blur};                  // wait until blurryness-effect gone.


Greetz
Purzel

Share this post


Link to post
Share on other sites


//initServer.sqf

TAG_fnc_heloExplosion = {

    params[ "_vehicle" ];

    _crew = ( crew _vehicle ) select { isPlayer _x };

    //create Explosion

    [ true ] remoteExec [ "TAG_fnc_heloEffects", _crew ];

    //wait for helo touching ground

    //create markers

    //wait for eos zone to activate

    //delete EOS units

    [ false ] remoteExec [ "TAG_fnc_heloEffects", _crew ];

};

//initPlayerLocal.sqf

TAG_fnc_heloEffects = {

    params[ "_start" ];

    

    if ( _start ) then {

        //Allow damage false

        //Start effects

    }else{

        //stop effects

        //Allow damage true

    };

};

//Then where ever you start the sequence from

if ( isServer ) then {

    _helo call TAG_fnc_heloExplosion;

};

  • Like 1

Share this post


Link to post
Share on other sites

[EDIT: ]
The above does not work:

Where do I save the initServer.sqf and the initPlayerLocal.sqf?
I have to put it in the missionfolder together with description.ext and init.sqf, right?

I called it from a trigger with:

if ( isServer ) then { _helo call TAG_fnc_heloExplosion;};

but what is this "TAG_fnc_heloEffects"-thing...?
I didn´t found any clues to that, is it just a name for a condition?

And when executed, nothing happens, but there´s no errormessage too, so I don´t have any clue, whats going on (and if it´s going on at all...)

 

Here´s the initPlayerLocal.sqf, I wrote it for my needs:

TAG_fnc_heloEffects = {
    params[ "_start" ];
    
    if ( _start ) then {
        pablo allowdamage false;
        _evacheli say3D "mastercaution";
        sleep 5;
        _evacheli say3D "enginefire";
    }else{
        //stop effects
        pablo allowdamage true;
    };
};

Where do I have to insert the blurry-part? (after enginefire?)
Do I just need to copy the below code after the line below enginfire?

[] spawn {                                    
        cutText ["", "BLACK OUT", 2];

        private ["_blur"];
        _blur = ppEffectCreate ["DynamicBlur", 474];  
        _blur ppEffectEnable true;
        cutText ["", "BLACK OUT", 12];
        _blur ppEffectAdjust [0];
        _blur ppEffectCommit 0;
        titleText ["Autschn!", "BLACK FADED", 10];
        waitUntil {ppEffectCommitted _blur};
        cutText ["", "BLACK IN", 7];
        _blur ppEffectAdjust [15];
        _blur ppEffectCommit 0;
        _blur ppEffectAdjust [0];
        _blur ppEffectCommit 10;
        waitUntil {ppEffectCommitted _blur};
        _blur ppEffectEnable false;
        ppEffectDestroy _blur;
    };

But maybe here´s another problem hidden in the initServer.sqf because of my poor scripting skills...:
(If someone please could have a short look-over)

TAG_fnc_heloExplosion = {
    params[ "_evacheli" ];

    _crew = ( crew _evacheli ) select { isPlayer _x };
    explo = "R_60mm_HE" createVehicle (getPos _evacheli);
    explo attachto [_evacheli, [0,-1.5,0]];
    sleep 9;
    smoke1 = "SmokeShell" createVehicle (position _evacheli);
    smoke1 attachto [_evacheli, [0,-7.5,0.9]];
    _evacheli setHitPointDamage ["HitVRotor", 0.7];
    smoke2 = "test_EmptyObjectForSmoke" createVehicle position _evacheli;
    smoke2 attachTo [_evacheli,[0,-2,-0.8]];
    sleep 5;
    feuer = "HelicopterExploSmall" createVehicle position _evacheli;
    feuer attachTo [_evacheli,[0.5,-1.5,-1.5]];
    [ true ] remoteExec [ "TAG_fnc_heloEffects", _crew ];
    waituntil {(getPosATL _evacheli select 2) <= 0.5};
    _markerabsturz = createMarker ["crashsite", position (vehicle pablo)];
    _markerabsturz setMarkerShape "ICON";
    _markerabsturz setMarkerColor "colorBLUFOR";
    _markerabsturz setMarkerText "   Crashsite";
    _markerabsturz setMarkerType "hd_unknown";
    _markerabsturz setMarkerPos (getpos (vehicle pablo));
    _markerabsturz setMarkerAlpha 1;    

    _markerabsturz1 = createMarker ["_markerabsturz1", position (vehicle pablo)];
    _markerabsturz1 setMarkerBrush "SOLID";
    _markerabsturz1 setMarkerShape "ELLIPSE";
    _markerabsturz1 setMarkerSize [800, 800];
    _markerabsturz1 setMarkerColor "colorBLUFOR";
    _markerabsturz1 setMarkerPos (getpos (vehicle pablo));
    _markerabsturz1 setMarkerAlpha 0.5;
    sleep 2;
    nul = [] execVM "eos\OpenMe.sqf";
    sleep 2;
    {deleteVehicle _x} forEach (nearestObjects [(getMarkerPos "crashsite"),["Men"], 50]);
    [ false ] remoteExec [ "TAG_fnc_heloEffects", _crew ];
};
 

 

Share this post


Link to post
Share on other sites

The above does not work:

Thats a bold statement when followed with..

 

Where do I save the initServer.sqf and the initPlayerLocal.sqf?

but what is this "TAG_fnc_heloEffects"-thing...?

Ill be blatantly honest i think you need to learn some of the basics of scripting before messing around with locality.

 

Where do I save the initServer.sqf and the initPlayerLocal.sqf?

Yes in the root of your mission folder where the description.ext is. They are specially named scripts that are started by the game like init.sqf is. see Event Scripts for more info.

 

but what is this "TAG_fnc_heloEffects"-thing...?

It is a function defined in initPlayerLocal.sqf as per my previous example code. It is run locally for each client in the helicopter when called for by remoteExec form the server in TAG_fnc_heloExplosion. See Functions more info.

 

Where do I have to insert the blurry-part? (after enginefire?)

Yes the 'blurry-part' are screen effects, as they are screen effects they obviously have to be run local to the client, so you would place them were I wrote //# effects. See next quote.

 

Do I just need to copy the below code after the line below enginfire?

Not all no. Your effects there are two fold, the beginning starts the blur effect and the end stops the effects, so you would split them up according to the comments in my example //start effects - //end effects

 

if ( isServer ) then { _helo call TAG_fnc_heloExplosion;};

What is _helo? It is meant to be replaced with a reference to your helicopter. e.g the name given to your helicopter in the editor in its Variable Name attribute. See Attributes and Objects

 

Same with..

TAG_fnc_heloEffects = {
    params[ "_start" ];

    if ( _start ) then {
        pablo allowdamage false;
        _evacheli say3D "mastercaution";
        sleep 5;
        _evacheli say3D "enginefire";
    }else{
        //stop effects
        pablo allowdamage true;
    };
};

What is pablo? this function is run on all clients in the helicopter and is called remotely from the server, this should be player as its this client we want to disable/enable damage/effects.

Also _evacheli is a local variable and is not defined, if you need a reference to the helo maybe it would be a good idea to also supply this reference from the TAG_fnc_heloExplosion function when the server calls the client function...

[ true, _evacheli ] remoteExec [ "TAG_fnc_heloEffects", _crew ];

and in the client function change

params[ "_start", "_evacheli" ];

So the trigger starts the event and passes a reference of your helo to TAG_fnc_heloExplosion,

The server function does all things that are global like creating the explosion and markers etc,

The server also calls remotely on each client that is in the heli the TAG_fnc_heloEffects passing it whether to start/stop the screen effects and a reference to your helo.

Share this post


Link to post
Share on other sites

I´ve tried around and here´s the solution, solved without initPlayer/Server-Stuff:
(and it´s running finally on a dedicated server!) Yai!  :D

 

Thank you Larrow for your valuable hints!
My problem is to understand the english scripting stuff correctly, it´s not the the scripting itself...

but some stuff is still unknown for me and I don´t know what to search, if I have a special scripting problem...

if (isServer) then
{

_heliCrew = []  + crew (vehicle pablo); 
_playerCrew = [] + crew (vehicle pablo) - [pablo]; 
_evacheli = (vehicle pablo);

// nul = [] execVM "scripts\blackout.sqf"; 

[[_evacheli, "mastercaution"], "Say3d", _playerCrew, false] call BIS_fnc_MP;    

{_x allowDamage false} forEach _heliCrew; 

[_evacheli,0.03] remoteExec ['setfuel',_evacheli];
[_evacheli,false] remoteExec ['allowdamage',_evacheli];

sleep 4;
[[_evacheli, "mastercaution"], "Say3d", _playerCrew, false] call BIS_fnc_MP; 

explo = "R_60mm_HE" createVehicle (getPos _evacheli);
explo attachto [_evacheli, [0,-1.5,0]];
sleep 9;
smoke1 = "SmokeShell" createVehicle (position _evacheli);
smoke1 attachto [_evacheli, [0,-7.5,0.9]];

[_evacheli,true] remoteExec ['allowdamage',_evacheli];
[_evacheli,["HitVRotor", 0.6]] remoteExec ['setHitPointDamage',_evacheli];
[_evacheli,false] remoteExec ['allowdamage',_evacheli];

smoke2 = "test_EmptyObjectForSmoke" createVehicle position _evacheli;
smoke2 attachTo [_evacheli,[0,-2,1]];
 sleep 5;
feuer = "HelicopterExploSmall" createVehicle position _evacheli;
feuer attachTo [_evacheli,[0.5,-1.5,-1.5]];
[[_evacheli, "enginefire"], "Say3d", _playerCrew, false] call BIS_fnc_MP; 
sleep 3.5;

sleep 0.2;

[_evacheli,0] remoteExec ['setfuel',_evacheli];

[[_evacheli, "mastercaution"], "Say3d", _playerCrew, false] call BIS_fnc_MP;
sleep 3.5;
[[_evacheli, "mastercaution"], "Say3d", _playerCrew, false] call BIS_fnc_MP; 

waituntil {sleep 0.1; (getPosATL _evacheli select 2) <= 2}; 
[[[_evacheli],"scripts\blackout.sqf"],"BIS_fnc_execVM",west,false] call BIS_fnc_MP;      

sleep 2; 

_position = [getPos _evacHeli, 5 + random 15, random 360] call BIS_fnc_relPos;         //get a random position in a radius from 5m to 20m around the crashed helicopter
[pablo] call ACE_captives_fnc_vehicleCaptiveMoveOut;                                 // kick pablo of the chopper
pablo setPos _position;                                                              // teleport pablo to a save position (not in walls or rocks, etc.)

_evacheli setdamage 0.8;

_markerabsturz = createMarker ["crashsite", position (vehicle Pablo)];
_markerabsturz setMarkerShape "ICON";
_markerabsturz setMarkerColor "colorBLUFOR";
_markerabsturz setMarkerText "   Crashsite";
_markerabsturz setMarkerType "hd_unknown";
_markerabsturz setMarkerPos (getpos (vehicle Pablo));
_markerabsturz setMarkerAlpha 1;    

_markerabsturz1 = createMarker ["crashsite1", position (vehicle Pablo)];
_markerabsturz1 setMarkerShape "ELLIPSE";
_markerabsturz1 setMarkerSize [800, 800];
_markerabsturz1 setMarkerColor "colorBLUFOR";
_markerabsturz1 setMarkerBrush "SOLID";
_markerabsturz1 setMarkerPos (getpos (vehicle Pablo));
_markerabsturz1 setMarkerAlpha 0.3;    

_evacheli allowdamage false; 
 
sleep 20;
deleteVehicle feuer;

{_x allowDamage true} forEach _heliCrew;                                    
sleep 10;
[playSound ["evacdown", true]] call BIS_fnc_MP;                              
["task4", "created"] call FHQ_fnc_ttSetTaskState;                               
[west,["task4", "Beschützen Sie Pablo Escobar und schlagen Sie sich mit ihm zum Polizei-Revier in Tanouka durch.", "Schlagen Sie sich zum Polizeirevier durch.", ""]] call FHQ_fnc_ttAddTasks;

// Das mit dem explodierenden Heli regeln wir anders
while {{_x distance _evacheli < 50} count playableUnits > 0} do {sleep 5};
_evacheli allowdamage true;    
_evacheli setdamage 1;
[pablo,flaggenmast,RESISTANCE,90,600,800,800] execVM "scripts\feindspawn.sqf";
};

Here is the blackout.sqf:
 

private ["_evacheli"];
_evacHeli = _this select 0;

if (player in _evacHeli) then {        

    cutText ["", "BLACK OUT", 1];
    
    sleep 2;                                                                               
    _position = [getPos _evacHeli, 5 + random 15, random 360] call BIS_fnc_relPos;              //the following 5 lines kicks the players outside the chopper and lay them on the ground.   
    player action ["Eject", _evacHeli];                                                      
    sleep 0.5;
    player setPos _position;                                                                
    player switchMove "AidlPpneMstpSnonWnonDnon_AI";                                          
        
    _blur = ppEffectCreate ["DynamicBlur", 474];
    _blur ppEffectEnable true;
    
    cutText ["", "BLACK IN", 15];
    _blur ppEffectAdjust [0];
    _blur ppEffectCommit 0;
    cutText ["", "BLACK OUT", 2];
    waitUntil {ppEffectCommitted _blur};
    cutText ["", "BLACK", 10];
    cutText ["", "BLACK IN", 7];
    _blur ppEffectAdjust [15];
    _blur ppEffectCommit 0;
    _blur ppEffectAdjust [0];
    _blur ppEffectCommit 15;
    
                                                                                           
    
    if ([player] call ace_medical_fnc_isMedic) then {                       // put some injuries to all players that are no medics
    sleep 0.2
    }
    else
    {
        private ["_bodyParts","_numberOfPartsHit","_severity","_verletzungsGrad"];
        _bodyParts = ["head","body","hand_l","hand_r","leg_l","leg_r"];                           
        _numberOfPartsHit = 1 + (floor random 2.9);                                           
        _severity = [0.3,0.3,0.3,0.8];                                                        
        _unit = [player];
        for "_i" from 1 to _numberOfPartsHit do
        {
            _bodyPartHit = _bodyParts call BIS_fnc_selectRandom;                                  
            _bodyParts = _bodyParts - [_bodyPartHit];                                           
            _verletzungsGrad = _severity call BIS_fnc_selectRandom;                               
            [player, _verletzungsGrad, _bodyPartHit, "bullet"] call ace_medical_fnc_addDamageToUnit;  
            sleep 0.2;                                                                       
        };
    };
    
     waitUntil {ppEffectCommitted _blur};
    _blur ppEffectEnable false;
    ppEffectDestroy _blur;
};

the "feindspawn.sqf" spawns enemies in the line between object "flaggenmast" and "pablo", so no matter where the heli crashed, there will be always enemies walking towards the team with escorts pablo on the escape-route from crashsite to the teams destination:

[pablo,flaggenmast,RESISTANCE,90,600,800,800] execVM "scripts\feindspawn.sqf";

It´s written "open", so I just have to change some variables in the line above and not the script itself.

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×