CCTV

This might be of use to some. I wrote a script to deploy a laptop. It will always be a scroll option for all players, until they deploy it. I set it so that it won't deploy within a certain distance of another laptop. You can tweak that 400 variable to get a distance of your own choosing. I did this to keep people from deploying a hundred laptops on top of each other. Ideally, there should be some way to have an option to "shutdown" the laptop which would delete it. But I haven't figured that part out yet.

Put this in the fn_selfactions.sqf:

Code:
// LAPTOP ON START
private ["_laptop"];
_laptop = count nearestObjects [_playerPos, ["Notebook"], 400] > 0;
 
if((speed player <= 1) && _canDo and !_laptop) then {
    hasLaptop = true;
} else {
    hasLaptop = false;
};
if (hasLaptop) then {
    if (LaptopON< 0) then {
    LaptopON = player addAction [("<t color=""#0096ff"">" + ("Laptop On") +"</t>"),"scripts\LaptopON.sqf","",5,false,true,"",""];
    };
} else {
    player removeAction LaptopON;
    LaptopON = -1;
};
// LAPTOP ON END

and then this goes in your scripts folder as LaptopON.sqf:

Code:
player playActionNow "Medic";
sleep 1;
titleText ["Your laptop is powering up.","PLAIN DOWN"]; titleFadeOut 5;
 
_mypos = getposATL player;
_dir = getdir player;
_mypos = [(_mypos select 0)+2*sin(_dir),(_mypos select 1)+2*cos(_dir), (_mypos select 2)];
_laptopON = createVehicle ["Notebook", _mypos, [], 0, "CAN_COLLIDE"];
_laptopON setDir _dir;
_laptopON setposATL _mypos;
sleep 2;
 
 
titleText ["System online.","PLAIN DOWN"]; titleFadeOut 5;

One problem is that the laptop spawns backwards. I would like for it to spawn in with the screen facing the player. Not sure how to do that. I'll update it when I get that far.



Try this....after _dir = getdir player;

_dir = _dir + 180;
if (_dir > 360.0) then {
_dir = _dir - 360.0;
};
 
This might be of use to some. I wrote a script to deploy a laptop. It will always be a scroll option for all players, until they deploy it. I set it so that it won't deploy within a certain distance of another laptop. You can tweak that 400 variable to get a distance of your own choosing. I did this to keep people from deploying a hundred laptops on top of each other. Ideally, there should be some way to have an option to "shutdown" the laptop which would delete it. But I haven't figured that part out yet.

Put this in the fn_selfactions.sqf:

Code:
// LAPTOP ON START
private ["_laptop"];
_laptop = count nearestObjects [_playerPos, ["Notebook"], 400] > 0;
 
if((speed player <= 1) && _canDo and !_laptop) then {
    hasLaptop = true;
} else {
    hasLaptop = false;
};
if (hasLaptop) then {
    if (LaptopON< 0) then {
    LaptopON = player addAction [("<t color=""#0096ff"">" + ("Laptop On") +"</t>"),"scripts\LaptopON.sqf","",5,false,true,"",""];
    };
} else {
    player removeAction LaptopON;
    LaptopON = -1;
};
// LAPTOP ON END

and then this goes in your scripts folder as LaptopON.sqf:

Code:
player playActionNow "Medic";
sleep 1;
titleText ["Your laptop is powering up.","PLAIN DOWN"]; titleFadeOut 5;
 
_mypos = getposATL player;
_dir = getdir player;
_mypos = [(_mypos select 0)+2*sin(_dir),(_mypos select 1)+2*cos(_dir), (_mypos select 2)];
_laptopON = createVehicle ["Notebook", _mypos, [], 0, "CAN_COLLIDE"];
_laptopON setDir _dir;
_laptopON setposATL _mypos;
sleep 2;
 
 
titleText ["System online.","PLAIN DOWN"]; titleFadeOut 5;

One problem is that the laptop spawns backwards. I would like for it to spawn in with the screen facing the player. Not sure how to do that. I'll update it when I get that far.

you should require the player to have a toolbox and scrap metal to use it
 
you should require the player to have a toolbox and scrap metal to use it
That's a good idea. It's too bad there aren't more electronic items in Day Z to cannibalize. My idea was to require a flashlight be sacrificed for its batteries. So maybe I'll add scrap and tools to the requirements, and a flashlight. Then the device would work for a limited time before self destructing when it runs out of juice. And in the process you lose your flashlight, so people wouldn't be able to dupe dozens of them on the spot. I'll get to work on that then.
 
You could make it disappear with the "cursorTarget" and "deleteVehicle" command.
Yes, I have gotten the power down option to pop up, but so far I'm having trouble with the deletevehicle.

Try this....after _dir = getdir player;

_dir = _dir + 180;
if (_dir > 360.0) then {
_dir = _dir - 360.0;
};

Thank you for this. It's close, but what happens is instead the laptop spawns BEHIND the player, and still backwards.
 
That's a good idea. It's too bad there aren't more electronic items in Day Z to cannibalize. My idea was to require a flashlight be sacrificed for its batteries. So maybe I'll add scrap and tools to the requirements, and a flashlight. Then the device would work for a limited time before self destructing when it runs out of juice. And in the process you lose your flashlight, so people wouldn't be able to dupe dozens of them on the spot. I'll get to work on that then.

I'd be glad to lend any assisstance I can, now that I am home and have a decent computer to work with.
 
I'd be glad to lend any assisstance I can, now that I am home and have a decent computer to work with.
Thanks. The idea, I think, is to require scrap and a flashlight to create a laptop, and on activation the scrap and flashlight are removed. It runs for a time, and then shuts off. The scrap is deposited back in the inventory. Flashlight is lost, because its battery got drained. I have a working script to do this, it's based off the zombie emitter script, so credit where credit is due. I wanted to borrow its timer for the battery life.
The problem is that the video feed does not cut when the laptop dies. So you can sit there watching it forever after it's gone, but turning off the feed you see the laptop is gone and your scrap is back in inventory. So as a temporary/permanent workaround I made the ending say the battery is low, not dead, so it can just be assumed that you squeezed a little extra life out of it.

Here's the new fn_selfaction:

Code:
// LAPTOP ON START
private ["_laptop"];
_laptop = count nearestObjects [_playerPos, ["Notebook"], 4] > 0;
 
if((speed player <= 1) && _canDo and !_laptop && ("PartGlass" in magazines player) && ("PartGeneric" in magazines player) && ("ItemToolbox" in items player) && ("ItemFlashlight" in items player)) then {
    hasLaptop = true;
} else {
    hasLaptop = false;
};
if (hasLaptop) then {
    if (LaptopON< 0) then {
    LaptopON = player addAction [("<t color=""#0096ff"">" + ("Laptop On") +"</t>"),"scripts\LaptopON.sqf","",5,false,true,"",""];
    };
} else {
    player removeAction LaptopON;
    LaptopON = -1;
};
// LAPTOP ON END

And here is the new LaptopON.sqf script:

Code:
private ["_mypos", "_dir", "_createLaptop", "_sounddist", "_battery", "_Laptop", "_LaptopON", "_timer", "_soundList"];
 
player playActionNow "Medic";
sleep 1;
titleText ["Your laptop is powering up.","PLAIN DOWN"]; titleFadeOut 5;
 
_mypos = getposATL player;
_dir = getdir player;
_mypos = [(_mypos select 0)+2*sin(_dir),(_mypos select 1)+2*cos(_dir), (_mypos select 2)];
_createLaptop = createVehicle ["Notebook", _mypos, [], 0, "CAN_COLLIDE"];
_createLaptop setDir _dir;
_createLaptop setposATL _mypos;
sleep 1;
 
player removeMagazine "PartGeneric";
player removeWeapon "ItemFlashlight";
player removeMagazine "PartGlass";
sleep 1;
 
titleText ["System online.","PLAIN DOWN"]; titleFadeOut 5;
 
_sounddist = 50;
_battery = 18;
while {_battery > 1} do {
    _Laptop = nearestObject [player, "Notebook"];
    [nil,_Laptop,rSAY,["", _sounddist]] call RE;
 
    _LaptopON = (alive _Laptop);
    _timer = time;
    while {_LaptopON} do {
        if ((time - _timer) > 5) exitwith {};
    };
    _soundList = [""] call BIS_fnc_selectRandom;
    [nil,_Laptop,rSAY,[_soundList, _sounddist]] call RE;
    _battery = _battery - 1;
};
 
sleep 1;
deleteVehicle _createLaptop;
player addMagazine "PartGeneric";
player addMagazine "PartGlass";
titleText ["The laptop's battery is critically low.","PLAIN DOWN"]; titleFadeOut 5;
As you can see, it's based off the emitter script, so it has a variable for the sound that usually plays. I had problems removing the code so I just removed the sounds themselves. Maybe someone who's better than me can incorporate the sound linked earlier in this thread.

Also, here is the fn_selfaction for a separate power down option for the laptop. The sqf is still giving me issues, so consider this a work in progress:

Code:
//LAPTOP OFF START
    if(cursorTarget isKindOf "Notebook") then {
            if (LaptopOFF < 0) then {
            LaptopOFF = player addAction ["Power Down Laptop","scripts\laptopOFF.sqf",cursorTarget, 0, false, true, "",""];
        };
    } else {
        player removeAction LaptopOFF;
        LaptopOFF = -1;
    };
//LAPTOP OFF END

**Updated: Added partglass to requirements.
 
I think you should have a screen required to, so use a windshield as the item "PartGlass" I think. Also you can have them craft a generator and it works within a 400 meter radius of the cameras, and the laptop and powers them.
 
I think you should have a screen required to, so use a windshield as the item "PartGlass" I think. Also you can have them craft a generator and it works within a 400 meter radius of the cameras, and the laptop and powers them.
Agreed. I've updated my last post to require the windscreen.
 
Its such a buzz people using my stuff. I have only been arma coding for like 2 months. Done some tricky stuff for Epoch recently!
 
Ok guys. I have a solution here for a man portable notebook that can stow in the player inventory. It uses one of the non-dayz arma mission items. In this case, I used Kosteys notebook, but you could use any item you want. This goes in fn_selfactions:
Code:
// NOTEBOOK ON START
private ["_laptop"];
_laptop = count nearestObjects [_playerPos, ["Notebook"], 4] > 0;
 
if((speed player <= 1) && _canDo and !_laptop  && ("Kostey_notebook" in items player) && ("ItemFlashlight" in items player)) then {
    hasNotebook = true;
} else {
    hasNotebook = false;
};
if (hasNotebook) then {
    if (NotebookON < 0) then {
    NotebookON = player addAction [("<t color=""#0096ff"">" + ("Notebook On") +"</t>"),"scripts\notebookON.sqf","",5,false,true,"",""];
    };
} else {
    player removeAction NotebookON;
    NotebookON = -1;
};
// NOTEBOOK ON END

And here is notebookON.sqf, for your scripts folder:

Code:
private ["_mypos", "_dir", "_createLaptop", "_sounddist", "_battery", "_Laptop", "_LaptopON", "_timer", "_soundList"];
 
player playActionNow "Medic";
sleep 1;
titleText ["You use the flashlight's batteries to power your notebook.","PLAIN DOWN"]; titleFadeOut 5;
 
_mypos = getposATL player;
_dir = getdir player;
_mypos = [(_mypos select 0)+2*sin(_dir),(_mypos select 1)+2*cos(_dir), (_mypos select 2)];
_createLaptop = createVehicle ["Notebook", _mypos, [], 0, "CAN_COLLIDE"];
_createLaptop setDir _dir;
_createLaptop setposATL _mypos;
sleep 1;
 
player removeWeapon "Kostey_notebook";
player removeWeapon "ItemFlashlight";
 
sleep 1;
 
titleText ["System online.","PLAIN DOWN"]; titleFadeOut 5;
 
_sounddist = 50;
_battery = 18;
while {_battery > 1} do {
    _Laptop = nearestObject [player, "Notebook"];
    [nil,_Laptop,rSAY,["", _sounddist]] call RE;
 
    _LaptopON = (alive _Laptop);
    _timer = time;
    while {_LaptopON} do {
        if ((time - _timer) > 5) exitwith {};
    };
    _soundList = [""] call BIS_fnc_selectRandom;
    [nil,_Laptop,rSAY,[_soundList, _sounddist]] call RE;
    _battery = _battery - 1;
};
 
sleep 1;
deleteVehicle _createLaptop;
player addWeapon "Kostey_notebook";
titleText ["The laptop's battery is critically low.","PLAIN DOWN"]; titleFadeOut 5;

Now, the trick is to have them spawn in game, and look like the notebook. I have a solution for that first part and maybe the second, but I'm still testing it.
 
nice, let us know if the solutions work.
Sorry for the delay. I got frustrated so I went and worked on another thing. So far I have successfully made the notebook spawn in a store by subbing it out with a script I've been using to swap items from rmod into the game.
I didn't write it, I have no idea who did. Someone from here I think. I searched the forum but got a weird security error I've never seen before. It's a nice script, whomever wrote it.

script is called spawn_loot.sqf. it activates in the init.sqf with:

Code:
spawn_loot                              = compile preprocessFileLineNumbers "scripts\spawn_loot.sqf";

And this goes in scripts.

Code:
private["_itemType","_iPos","_indexLootSpawn","_iArray","_iItem","_iClass","_item","_qty","_max","_tQty","_arrayLootSpawn","_canType","_holderItem"];
// [_itemType,_weights]
_iItem =        _this select 0;
_iClass =      _this select 1;
_iPos =        _this select 2;
_radius =      _this select 3;
_holderItem = _iItem;
switch (_iItem) do {
        case "Binocular": { _holderItem = "Kostey_notebook"};
        default {};
        };
_iItem = _holderItem;
switch (_iClass) do {
        default {
                //Item is food, add random quantity of cans along with an item (if exists)
                _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
                _arrayLootSpawn = [] + getArray (configFile >> "cfgLoot" >> _iClass);
                _itemType = _arrayLootSpawn select 0;
                _weights = _arrayLootSpawn call fnc_buildWeightedArray;
                _qty = 0;
                _max = ceil(random 4) + 1;
                //diag_log ("LOOTSPAWN: QTY: " + str(_max) + " ARRAY: " + str(_arrayLootSpawn));
                while {_qty < _max} do {
                        private["_tQty","_indexLootSpawn","_canType"];
                        _tQty = floor(random 1) + 1;
                        //diag_log ("LOOTSPAWN: ITEM QTY: " + str(_tQty));
                 
                        _indexLootSpawn = _weights call BIS_fnc_selectRandom;
                        _canType = _itemType select _indexLootSpawn;
                 
                        _holderItem = _canType;
                        switch (_canType) do {
//                                case "Kostey_notebook": { _holderItem = "Notebook"};                         
                                default {};
                                };
                        _canType = _holderItem;
                 
                        //diag_log ("LOOTSPAWN: ITEM: " + str(_canType));
                        _item addMagazineCargoGlobal [_canType,_tQty];
                        _qty = _qty + _tQty;
                };
                if (_iItem != "") then {
                        _item addWeaponCargoGlobal [_iItem,1];
                };
        };
        case "weapon": {
                //Item is a weapon, add it and a random quantity of magazines
                _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
                _item addWeaponCargoGlobal [_iItem,1];
                _mags = [] + getArray (configFile >> "cfgWeapons" >> _iItem >> "magazines");
                if (count _mags > 0) then {
                        _item addMagazineCargoGlobal [(_mags select 0),(round(random 3)+2)];
                };
        };
        case "magazine": {
                //Item is one magazine
                _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
                _item addMagazineCargoGlobal [_iItem,1];
        };
        case "object": {
                //Item is one magazine
                _item = createVehicle [_iItem, _iPos, [], _radius, "CAN_COLLIDE"];
        };
};
if (count _iPos > 2) then {
        _item setPosATL _ipos;
};

Ok now the problem. I know I can use part of this script to make certain items have different weaponholder, like I had shotgun shells that looked like ar10 mags. It may have just been a glitch. It's tough to explain, it has to do with the way piles of stuff are generated. This may be null since the loot is so sparse in 1.7.7.1, I don't recall seeing any piles at all. But the idea is to make the item kostey's notebook LOOK like the actual item class "notebook". So I'm trying to find a script that will detect items of that type and sub them out, provided I can't make this thing work. For now that part is commented out.
 
Add the following in your fn_selfactions.....

Code:
//CCTV
    if(cursorTarget isKindOf "Notebook" and _canDo) then {
            if (s_player_Laptop < 0) then {
            s_player_Laptop = player addAction ["Activate Laptop Surveillance","cctv\init.sqf",cursorTarget, 0, false, true, "",""];
        };
    } else {
        player removeAction s_player_Laptop;
        s_player_Laptop = -1;
    };
//End

Once your done with that make a folder called cctv and add the 2 included files (found here: www.zombiebattalion.net/CCTV.rar )into that folder.

Once all this is done you need to go into your editor and place cameras wherever you want them.You also need to add a Laptop somewhere on map to interact with. Classnames are (Notebook) and (Loudspeaker) .
In the editor they are found at Object (small) -> Notebook , Loudspeaker


Depending on how many cameras you place and how for apart they are you may need to adjust the following line to a larger radius.

Found in cctv/init.sqf "CCTV_radius = 500; // Radius which notebooks detect cameras"


Hope this helps...and again this is not my script/code. Credit goes to https://github.com/maca134/dayz-cctv

I using this, all works, but, players cant abort it, ENTER dosent abort .
any ideas? I using antihack.
 
So I thought it would be a nice idea to let you guys know that I am not going to develop a deployable mechanism for this. I sorta went back to a previous project of translating and rewriting R3F Arty & Logistics, which is almost finished!
 
Back
Top