Spawn Sputtering Road Flares possible?

Vonstorm

Member
Anyone know how to spawn burning road flares, or any type of flare. I've tried the create vehicle classnames for flares, but after further googling and looking at the epoch compiles I see theres alot more going on. Basically its a trigger that runs a script, producing a flare at the triggers location. Any help is appreciated.
 
you are spawning a vehicle of #light or #lightsource, can't remember.

It only exists on client so you ahve to do some communication around the system.
 
tried this kind of thing from the arma 2 forums -
flare = "F_40mm_white" createVehicle [getPos _trigger select 0, getPos _trigger select 1, 50];
hoped it would spawn 50m above trigger but no luck.
 
What versions of DayZ are you trying this on?

Also did you run that clientside or server?
 
tried this kind of thing from the arma 2 forums -
flare = "F_40mm_white" createVehicle [getPos _trigger select 0, getPos _trigger select 1, 50];
hoped it would spawn 50m above trigger but no luck.

i expect the above classname is for the actual round that you can pick up off the ground, not the lit flare....
as,schwede and delpi points out you have to create a lightpoint and attach it to the flare

in the script you used, is the variable _trigger defined locally?
start adding diag_log to the script to print out to the rpt whst is going on in your script, like diag_log format["trigger pos %1,%2",_trigger select 0, _trigger select 1];

is this all you want is a normal flare? to hang suspended indefinately or to,drop normally?
 
Last edited:
Thanks for your time guys...
When I started I wanted a road flare, but saw it possible (maybe?) to have a "starshell" create and float down.

Have this on right click -
Code:
private ["_mypos","_mags","_tool","_onLadder","canDo"];

_mags = magazines player;
_tool = items player;
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);
if ((speed player <= 1) && _canDo) then { //another if statement because fn_self actions is not a while loop.
   
    if (("ItemToolbox" in _tool) && ("HandRoadFlare" in _mags)) then {

        player playActionNow "Medic";
        
        _mypos = getPosATL player;
        
        sleep 5;
        
       
        player removeMagazine "HandRoadFlare";
        
        DZ_flareTrap = [_myPos];
        publicVariableServer "DZ_flareTrap"; //Send needed values to server.
        DZ_flareTrap = []; //Clean up global variable.
        
        cutText [format["You have placed a Trip Flare. 15 seconds till its live!!!"], "PLAIN DOWN"];
    }
   
    else {
        cutText [format["You do not have the required material. You need a toolbox & Road Flares"], "PLAIN DOWN"];
    };
};
That looks to run well
in init.sqf -

if (isServer) then {
"DZ_flareTrap" addPublicVariableEventHandler {[_this] execVM 'Scripts\createFlare.sqf'};

};

then createFlare.sqf
Code:
private ["_bombPos","_spawnStash","_bombTrigger"];
if (!isServer) exitWith {}; //Make sure this script runs only on server.

_bombPos = _this;          diag_log format ["flare position is %1",_bombPos];
//Create the stash object
_spawnStash = createVehicle ["BeltBuckle_DZE", [0,0,0], [], 0, "NONE"]; diag_log format ["created buckle"];
//Prevent server from deleting the object by assigning it a blank UID.
_spawnStash setVariable ["ObjectUID",""];
sleep 15;
//Create the trigger object
_bombTrigger = createTrigger["EmptyDetector",[0,0,0]];
_bombTrigger setTriggerArea [5,5,0,false];
_bombTrigger setTriggerActivation ["ANY","PRESENT",true];
_bombTrigger setTriggerStatements ["{(_x isKindOf 'Man')} count thisList > 0;","0 = [_bombTrigger,_spawnStash,thislist,_bombPos] execVM 'Scripts\detonateFlare.sqf'",""];
//cutText [format["Trip Flare is now live until server restart"], "PLAIN DOWN"];
//Set position of stash and trigger
_spawnStash setPosATL _bombPos;
_bombTrigger setPosATL _bombPos;
DZ_flareTrap = nil;

RPT log has this -
9:44:44 "flare position is [["DZ_flareTrap",[[7203.99,2994.25,0.00165558]]]]"
9:44:44 z\addons\dayz_epoch\models\skull.p3d: No geometry and no visual shape
9:44:44 z\addons\dayz_epoch\models\skull.p3d: No geometry and no visual shape
9:44:44 "created buckle"
9:44:59 Error in expression <\detonateFlare.sqf'",""];


_spawnStash setPosATL _bombPos;
_bombTrigger setPosA>
9:44:59 Error position: <setPosATL _bombPos;
_bombTrigger setPosA>
9:44:59 Error 1 elements provided, 3 expected
9:44:59 File mpmissions\DayZ_Epoch_11.Chernarus\Scripts\createFlare.sqf, line 20

so I know I have a problem with the position array. This carries over to the detonateFlare.sqf.

Code:
private ["_trigger","_stashObject","_nearbyUnits","_nearbyPlayers","_theBomb","_flarePos"];

if (!isServer) exitWith {};

_trigger = _this select 0;              //The trigger object
_stashObject = _this select 1;  //The stash object
_nearbyUnits = _this select 2;  //All units in trigger area (may not be players).
_flarePos = _this select 3; // flare position

//diag_log "Bomb is triggered.";

//Check if there is at least one unit in trigger area
if ((count _nearbyUnits) > 0) then {
    //Create bomb on trigger object
    _theBomb = createVehicle ["F_40mm_white",_flarePos select 0,_flarePos select 1, 50];
    cutText [format["Flare detonated"], "PLAIN DOWN"];
        //Remove trigger and stash after bomb is created and detonated.
    deleteVehicle _trigger;
    //deleteVehicle _stashObject;
} else {
        //diag_log "no Trigger";
};

I know most of you will cringe, but I think Im almost there barring a few beginner errors, with the help of SchwEde's insight, or something else that spawns the ingame flare mechanic at that spot.
 
So you want booby traps that spawn a flare when they're triggered?
If so just give me time till I come home and I will give you a working script for it ;P
 
Check the syntax for setposatl
https://community.bistudio.com/wiki/setPosATL

What you are providing is _bombpos which is ONE variable that contains an array with an array as which is shown in your log
diag_log format ["flare position is %1",_bombPos]; results in
9:44:44 "flare position is [["DZ_flareTrap",[[7203.99,2994.25,0.00165558]]]]"
so instead why not directly use the passed position? I think this is what you need here ... double check it, probably wrong but its close to what you want
Code:
//Set position of stash and trigger
_spawnStash setPosATL [(_this select 1)select 0,(_this select 1)select 1,(_this select 1)select 2];
_bombTrigger setPosATL [(_this select 1)select 0,(_this select 1)select 1,(_this select 1)select 2];
 
Ok, tried your suggestion, getting:
14:18:27 "flare position is [["DZ_flareTrap",[[7211.33,2993.15,0.00165176]]]]"
14:18:27 z\addons\dayz_epoch\models\skull.p3d: No geometry and no visual shape
14:18:27 z\addons\dayz_epoch\models\skull.p3d: No geometry and no visual shape
14:18:27 "created buckle"
14:18:42 Error in expression <\detonateFlare.sqf'",""];


_spawnStash setPosATL [(_this select 1)select 0,(_th>
14:18:42 Error position: <setPosATL [(_this select 1)select 0,(_th>
14:18:42 Error Type Any, expected Number
14:18:42 File mpmissions\DayZ_Epoch_11.Chernarus\Scripts\createFlare.sqf, line 20

Also tried using _bombPos select 0 etc. - no luck. - Squint not reporting syntax errors so its some kind of variable issue?

Heres the one for smoke that works if it helps (taken from the posted booby traps script).
Code:
private ["_bombOwnerUID","_bombPos","_spawnStash","_bombTrigger","_objectUID"];
if (!isServer) exitWith {}; //Make sure this script runs only on server.
_bombOwnerUID = (_this select 0) select 0;      //diag_log format ["Bomb owner's UID is %1",_bombOwnerUID];
_bombPos = (_this select 0) select 1;          //diag_log format ["Bomb's position is %1",_bombPos];
//Create the stash object
_spawnStash = createVehicle ["BeltBuckle_DZE", [0,0,0], [], 0, "NONE"];
//Prevent server from deleting the object by assigning it a blank UID.
_spawnStash setVariable ["ObjectUID",""];
sleep 15;
//Create the trigger object
_bombTrigger = createTrigger["EmptyDetector",[0,0,0]];
_bombTrigger setTriggerArea [5,5,0,false];
_bombTrigger setTriggerActivation ["ANY","PRESENT",true];
_bombTrigger setTriggerStatements ["{(_x isKindOf 'Man')} count thisList > 0;","0 = [thisTrigger,_spawnStash,thislist] execVM 'Scripts\detonateBomb.sqf'",""];
_bombTrigger setVariable ["ownerUID",_bombOwnerUID];
cutText [format["Booby trap is now live until server restart"], "PLAIN DOWN"];
//Set position of stash and trigger
_spawnStash setPosATL _bombPos;
_bombTrigger setPosATL _bombPos;
DZ_boobyTrap = nil;

has extra info for owner that isnt used
 
your diag_log outputs _bombpos and shows that its equal to this
[["DZ_flareTrap",[[7211.33,2993.15,0.00165176]]]]
it contains an array of String (dz_flaretrap) and an array of the positions
I had mentioned a few posts up to add some diag_log outputs into your script. so do that and see what is showing up
diag_log format["BOMBPOS is %1,%2",_bombpos select 0, _bombpos select 1];
that will print what each array value is (should be the trap classname and the position array).
If that is working correctly then add a line that sets _position = _bombpos select 1; which will now contain the correct position in an array.
And use _position in your setposatl
_spawnStash setPosATL [_position select 0,_position select 1,_position select 2];
_bombTrigger setPosATL [_position select 0,_position select 1,_position select 2;_bombPos];
 
ok the results Im getting are:
8:50:33 "flare position is [["DZ_flareTrap",[[7204.79,2990.61,0.00172043]]]]"
8:50:33 "BOMBPOS is ["DZ_flareTrap",[[7204.79,2990.61,0.00172043]]],<null>"
8:50:33 "position is any,any,any"
position being _position variable.

_position = (_bombpos select 0) select 1;
yields "position is [7200.08,2987.04,0.00166702],<null>,<null>"
will attempt further
UPDATE:
_position = ((_bombpos select 0) select 1) select 0;

10:32:12 "flare position is [["DZ_flareTrap",[[7202.22,2988.96,0.00167084]]]]"
10:32:12 "BOMBPOS is ["DZ_flareTrap",[[7202.22,2988.96,0.00167084]]],<null>"
10:32:12 "position is 7202.22,2988.96,0.00167084"

no errors

following the same advice in detonateFlare.sqf
calling it from trigger so -
_bombTrigger setTriggerStatements ["{(_x isKindOf 'Man')} count thisList > 0;","0 = [_bombTrigger,_spawnStash,thislist,_position] execVM 'Scripts\detonateFlare.sqf'",""];

however the variable output in detonateFlare.sqf from _this is:
11:07:53 "flarePOS is any,any,[B 1-1-B:1 (john) REMOTE,30ce4800# 1062260: skull.p3d],any"

EDIT:
what im having trouble getting my head around is where everything in the array is coming from. In setFlare.sqf just the position is supposed to be passed as a variable, to the global and then on to createFlare.sqf. Obviously Im wrong but the variable I was expecting should just be the position array - export from getPosATL, import to setPosATL in createFlare.sqf, pass on to detonateFlare.sql.
 
Last edited:
I dont see a setflare.sqf file in your code blocks.
The _bombpos is in the createflare.sqf file and in your init.sqf and the position coordinates are passed here
Code:
"DZ_flareTrap" addPublicVariableEventHandler {[_this] execVM 'Scripts\createFlare.sqf'};
so what it does is whenever the variable DZ_flaretrap is called as publicvariable (which makes that variable available to all computers and the server) https://community.bistudio.com/wiki/addPublicVariableEventHandler and the method of calling the createflare.sqf script might be some of the problem here. You are passing the _this variable array to the script which you dont need to do, that is done automatically and that value in fact does not exist in your init.sqf. So you are passing a variable that is null at the time.
What the createflare.sqf script is receiving is the name of the variable (DZ_flaretrap) and the data dz_flaretrap contains and its accessed from your script using _this
So try removing the _this from your event handler.
Code:
"DZ_flareTrap" addPublicVariableEventHandler { execVM 'Scripts\createFlare.sqf'};
And remember, the entire purpose of a publicvariable is that its passing a variable to all computers. so in your createflare.sqf code the dz_flaretrap contains a position array of the player.
So you can actually use dz_flaretrap select 0, dz_flaretrap select 1, dz_flaretrap select 2 in your createflare.sqf script.
https://community.bistudio.com/wiki/publicVariable

Schwede offered to make a working script. how about you post your flare files and init.sqf
 
ok @Vonstrom i need following files from you:

server_monitor.sqf
player_build.sqf
init.sqf
you can send me them via PN or post them here.
Best thing would though would be if you would send me you mission.pbo and dayz_server.pbo :)

Are trying to get the bombs with an owner IDso they wont detonate on the owner or should they detonate on every player?
 
@ ShootingBlanks - setFlare.sqf is the first codeblock - repeated below:
setFlare.sqf
Code:
private ["_mypos","_mags","_tool","_onLadder","canDo"];

_mags = magazines player;
_tool = items player;
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);
if ((speed player <= 1) && _canDo) then { //another if statement because fn_self actions is not a while loop.
  
    if (("ItemToolbox" in _tool) && ("HandRoadFlare" in _mags)) then {

        player playActionNow "Medic";
       
        _mypos = getPosATL player;
       
        sleep 5;
       
      
        player removeMagazine "HandRoadFlare";
       
        DZ_flareTrap = [_myPos];
        publicVariableServer "DZ_flareTrap"; //Send needed values to server.
        DZ_flareTrap = []; //Clean up global variable.
       
        cutText [format["You have placed a Trip Flare. 15 seconds till its live!!!"], "PLAIN DOWN"];
    }
  
    else {
        cutText [format["You do not have the required material. You need a toolbox & Road Flares"], "PLAIN DOWN"];
    };
};

Thanks for helping me understand where all the variable data is coming from so I can clean it up :). Ill keep bashing away at it and look at schwedes version to see how far off I am.
Its the understanding thats important, if I have to set too many more flares to test Im going to go postal! :)
 
Last edited:
Back
Top