Jump to content
Rich_R

Download/countdown script

Recommended Posts

Been looking for a script that does the following;

 

  • Multiplayer mission
  • Player A goes to object which has an addaction allowing for the downloading of stuff
  • Once the download is initiated, continues to show the download completion
  • When its finished, it can trigger something (bad guys, alarm, etc)

 

Used to use this - Download data from a laptop by t-800a But it seems to kick up an error. Also tried to tweak it but scripting isn't something I do.

 

Does anyone know of something that does this. I have to figure with the basic framework, this kind of script can be applied to a bunch of mission scenerios

 

Thanks in advance!

 

Share this post


Link to post
Share on other sites

I'm working on something similar  for my own mission. It could take a while due to limited time but I'll post something once I got it usable. 

  • Like 1

Share this post


Link to post
Share on other sites

Hello,

Why don't you try, it's not that complicated ;)

 

• Mapping

Place down a laptop and call it whatever you want.
I will call mine "laptop".

 

• Action (We want player to be able to mouse scroll on the laptop to hack it)

// In the init file
laptop addAction ["Download Files", { [] execVM "download.sqf"}, nil, 2, true, true, "", "!_target getVariable ['inUse',false]"];

// OR directly on the editor in the init field of the obj
this addAction ["Download Files", { [] execVM "download.sqf"}, nil, 2, true, true, "", "!_target getVariable ['inUse',false]"];

// myobj addAction ["Action Name", {//code}, args, priority, showWindow, HideOnUse, shortcut, condition];

https://community.bistudio.com/wiki/execVM

https://community.bistudio.com/wiki/addAction

 

I will explain the following args down below.

 

• Useful variables

 

Since we want it to be multiplayer compatible and we are not dumb. We have to define a variable that checks if someone is already downloading the files => inUse.

We need to init the variable on the object (Forget global variables.)

Like so.

// init.sqf
laptop setVariable ["inUse", false, true];

// OR editor
this setVariable ["inUse", false, true];

// myobj setVariable ["varName", data, broadcast];

https://community.bistudio.com/wiki/setVariable

https://community.bistudio.com/wiki/getVariable

 

So in the condition on the action :

 

!_target getVariable ['inUse',false]

// obj getVariable ['varName', defaultValue];
// We negate the result with "!" as we want to return true when nobody is downloading

• Things to note

 

You probably already saw I used execVM with download.sqf file name. This is a very simple method but not the one you should use if you really want to get shit done.

There are methods to define functions => https://community.bistudio.com/wiki/Functions_Library_(Arma_3)

If you decide to define a function instead of using execVM replace the whole code of the addAction (including brackets) with a string like

this addAction ["RAINBOWWS", "fnc_rainbows"];

 

• Create that damn download.sqf

 

/* 
    File : download.sqf
    Description : Downloads stuff (not MLP related)
*/

// Vars
_maxDistance = 5;
_timePerPercent = 1;

// We check the variable on the laptop in case two player activate the script at the 'same' time
if(laptop getVariable ["inUse", false]) exitWith {hint "Someone is already doawnloading the files."};

// We set the variable to the laptop to true so only
laptop setVariable ["inUse", true, true];

// Warning
hint format ["The download will start in 3 seconds. Stay at least %1 meters away from the laptop",_maxDistance];
sleep 3;

// Download part
for "_i" from 1 to 100 do {
	// Check the distance with the player
	if (player distance laptop > _maxDistance) exitWith { hint format ["Download Canceled : You are %1 meters away from the laptop",_maxDistance]; laptop setVariable ["inUse",false,true];};
	// This is how much time to way at each percent, lower this to make the download faster
    sleep _timePerPercent;
	// Show the current download progress
    hintSilent format ["Download in progress : %1%2, _i, "%"];
};

// This is ugly af but hey, who cares.
// Success
if (player distance laptop < _maxDistance) then {
	hint "You have successfully downloaded MLP_s05_1080p_x264";
	// Uncomment if you want to make ppl able to download again.
    // laptop setVariable ["inUse",false,true];
    
    // DO WATHEVER YOU WANT TO DO IN CASE OF SUCCESS HERE
    myGlobalTriggerVar = 1;
    player addRating 200;
    player setDamage 0;
    "Box_East_WpsSpecial_F" createVehicle position player;
};

https://community.bistudio.com/wiki/sleep

https://community.bistudio.com/wiki/hint

https://community.bistudio.com/wiki/format

https://community.bistudio.com/wiki/distance

https://community.bistudio.com/wiki/for

https://community.bistudio.com/wiki/if

 

Not tested.

It may have typos. Just look at the logs it will be easy to fix.

Anyway, that's it you got the idea.

  • Like 1

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

×