Jump to content

Recommended Posts

Hello folks :)

 

I want to create a visible countdown, but for two different situations.

 

1

There's a laptop/pc. Blufor has to approach it and upload intel to command. It's supposed to take x seconds. The idea is for there to be an interaction menu (scroll wheel) with the option to upload the intel. When activated, a timer will appear showing "XX Seconds to Complete" (or, if possible, in %) and it would be visible to all blufor in an x meters radius.

 

2

You have x minutes to clear an area after beeing detected by opfor, or else the alarm will go off. Applying the same principle as above, I'd like that timer to show up when blufor is detected by opfor. If reaches zero and there's still opfor in the area the alarm will go off, but if all opfor is dead before timer reaches 0, it will disappear and the alarm condition won't apply.

 

 

Thanks in advance ofr the help :)

 

Cheers!

  • Like 1

Share this post


Link to post
Share on other sites

Bump... would also like to set up a similar scenario as per option 2...

Share this post


Link to post
Share on other sites
On 21.8.2016 at 4:53 PM, PCanas said:

I want to create a visible countdown, but for two different situations.

 

1 minute ago, noewon said:

Bump... would also like to set up a similar scenario as per option 2...

 

Posting what you already tried might be a start.

 

Cheers

Share this post


Link to post
Share on other sites

I already did post what i tried. :don15:  got NFI how to do this... 

but could pull apart an example if someone has one

Share this post


Link to post
Share on other sites

I asked a similar question and someone (forgot who...sorry) replied with the following. Haven't had the chance to fully test it it yet.

 

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

×