Jump to content
t-800a

script snippet - downlad data from a laptop

Recommended Posts

Hi everyone,

here is a small script snippet from a coop mission I created to play with some friends. Maybe someone finds this usefull...

Because I thought downloading intel data from a Laptop by just adding a simple addaction to the Laptop is a bit boring I added a small downloading GUI window to it which has some changing texts. The download is only useable by one player at a time, you can abort the download / close the window by hitting ESC or clicking the X. When the download is finished a public var is updated that triggers the task to succeed.

Here is how the GUI looks like: http://hummelhummel-ag.de/downloads/Showcase_DownloadData.Altis.png (897 kB)

---- Updated on 01.02.2014 ----

support for multiple laptops / objects

you can check if the download on a laptop/object was finished by using the following var: T8_pubVarDataTask_MyObjectsName

and with the var T8_pubVarInUse_MyObjectsName you can check if someone uses this object. compare with the triggers placed in the demo mission!

---- Updated on 24.06.2014 ----

fixed the bug that was posted in April ... lazy me

added the percentage part cuel posted down below. thanks!

added WTFPL licence to script files, because licenses everywhere :x

---- updated script on 30.01.2015 - V004 ----

updated the script to better work with objects created on-the-fly

incompatible to previous versions, so you are not done by replacing files!

You can check if the download on a laptop/object was finished and/or if someone uses the object by checking the

following variables saved to the object:

_laptopInUse = _myLaptop getVariable [ "T8L_pvar_inUse", false ];
_downloadComplete = _myLaptop getVariable [ "T8L_pvar_dataDownloaded", false ];

Download the sample mission (V004)

V003

V002

Edited by t-800a

Share this post


Link to post
Share on other sites
Guest

Release frontpaged on the Armaholic homepage.

==============================================

You are not registered on Armaholic, or at least not that we are aware of. In the future we offer the possibility to authors to maintain their own pages.

If you wish to be able to do this as well please register on Armaholic and let me know about it.

This is not mandatory at all! Only if you wish to control your own content you are welcome to join, otherwise we will continue to follow your work like we have always done ;)

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Haven't tried it out yet, but it seems useful and rather unique. Thanks for the release!

---------- Post added at 09:44 AM ---------- Previous post was at 09:10 AM ----------

Edit: Works great so far, thanks for the release! I am, however, having problems with getting the GUI to appear. All of the scripts seem to be in order, and #include "downloadData.hpp" is in the description.ext... and yet nothing pops up upon downloading! I know nothing about .HPP files, but I read that that "Upon binarization included files are merged into the single config.bin file that is included in the final PBO". Yet when I .PBOed it, still nothing has appeared.

I would appreciate the help, as this is quite a nice thing you have released.

Edited by Hoffinator

Share this post


Link to post
Share on other sites

Hey Hoffinator, glad you like it so far.

I created a clean Mission and exported it as pbo for you, maybe you can compare it to your mission and find the error, because I dont understand why the "download window" doesn't show up for you.

You can find the pbo file [ here ].

On the "binarization and merging to config.bin" ... I have got no Idea what that means, I am really just a beginner with SQF and Mission editing, but my best guess is, that this has something todo with addons, in those pbo files you can find a config.bin.

Share this post


Link to post
Share on other sites

Nice dialog :) I added a little percentage indicator:

ctrlSetText [ 8002, format [ "%1 kb/t", _dlRate ] ];		
_percent =  (_newFile/ T8_varFileSize);
_percent = toArray str _percent;
{_percent set [_x,-1]} forEach [0,1]; 
_percent = _percent - [-1];
_percent resize 2;
_percent = toString _percent;
ctrlSetText [ 8004, format [ "%1 kb (%2%3)", _newFile,if (T8_varDiagAbort) then {100}else{_percent},"%"]];				

Share this post


Link to post
Share on other sites

Just wondering, how would one go about allowing the user to move around while file is downloadling?

I'm assuming that the action would trigger something and then go away allowing for this other bit of code to continue until finished then updating the action?

Share this post


Link to post
Share on other sites
Just wondering, how would one go about allowing the user to move around while file is downloadling?

I'm assuming that the action would trigger something and then go away allowing for this other bit of code to continue until finished then updating the action?

It would need to be created as a resource (IE: HUD) and not a dialog. Dialogs steal focus so that the user can use the mouse.

Share this post


Link to post
Share on other sites

My personal intention was to steal that focus, so the player is locked down for a few seconds maintaining the download, making him more vulnerable to his surroundings. Therefore I didn't use HUD elements. But feel free to edit this thing to your personal preferences. ;)

Share this post


Link to post
Share on other sites

This looks great, only issue is I'm crap at scripting. Are you able to explain how to change the location of the laptop? I want to use it but I can't seem to get it into the right spot in my mission after changing the numbers in the init.sqf. Any help would be appreciated.

Edit: Got it working! WooHoo........

Edited by AusCleaver

Share this post


Link to post
Share on other sites

@AusCleaver or t-800a, give a noob to mission making a chance and tell how to change the location of the laptop. In the last two hours I managed to place a lapop on a desk, just to find out in the sample mission is no laptop at all in the editor.

Share this post


Link to post
Share on other sites

@Novahot:

Have a look at this sample I posted a bit later, here I used a editor placed object. I hope this Helps -> [ here ]

Share this post


Link to post
Share on other sites

@t-800a

Hello and thank you very much for this script. I have a question though please. I have tried your script in a dedicated server multiplayer mission that I am running and it works fine the first time through but after you download the data, you cannot ever download it again unless I restart the mission. I would like to be able to download data from the laptop repeatedly at different stages of my mission. Is there any way that I can "RESET" everything so that all the laptop is available again for download?

Thanks in advance!

Share this post


Link to post
Share on other sites

This is just a great idea! Thanks for this great script.

I can change the position of the laptop, even put it on a table in a building.

I also changed it so you can only activate the download if your within 3m of the laptop.

What i would like to know though, is can this script be modified to do away with the lines in the Init.sqf that relate to spawning the Laptop?

Now that i actually took the time to look through your example of using an object placed in the editor, i`m rocking there too.

I was struggling for hours yesterday and came here to ask how/why/help etc. but managed to help myself! lol

Cheers for a great idea and a great script that hopefully, will bring me and my Arma buddies a few great games :)

Share this post


Link to post
Share on other sites

Looks pretty nice, I was wondering if that laptop item could be used with setObjectTexture or for PiP stuff, so we can display a custom screen, that would be awesome. Didn't have time to look into it.

Share this post


Link to post
Share on other sites
Looks pretty nice, I was wondering if that laptop item could be used with setObjectTexture or for PiP stuff, so we can display a custom screen, that would be awesome. Didn't have time to look into it.

It can, create a camera and a rendertarget, then:

_laptop setObjectTextureGlobal [0, "#(argb,512,512,3)r2t(rendertarget2,1.0)"];

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

Great script, t-800a. I`d like to use this script for uploading. Guessing one would just have to set a reverse value, could someone explain me where to do so?

Share this post


Link to post
Share on other sites
Great script, t-800a. I`d like to use this script for uploading. Guessing one would just have to set a reverse value, could someone explain me where to do so?

I hope this fits your needs, now it starts with a big File which gets smaller:

// =======================================================================================================
//
//		downloadData.sqf - by T-800a
//
// =======================================================================================================

if ( isNil "T8_pubVarInUse" ) then { T8_pubVarInUse = false; };
if ( isNil "T8_pubVarDataTask" ) then { T8_pubVarDataTask = false; };


T8_varFileSize = 32875;  								// Filesize ... smaller files will take shorter time to download!

T8_varTLine01 = "Upload abgebrochen!";				// download aborted
T8_varTLine02 = "Wird bereits ausgefuehrt!";			// download already in progress by someone else
T8_varTLine03 = "Upload gestarted!";					// download started
T8_varTLine04 = "Upload abgeschlossen!";				// download finished
T8_varTLine05 = "##  Upload Data  ##";				// line for the addaction

T8_varDiagAbort = false;
T8_varDownSucce = false;



T8_fnc_abortActionLaptop =
{
if ( T8_varDownSucce ) exitWith {};

player sideChat T8_varTLine01; 
T8_varDiagAbort = true;
};


T8_fnc_addActionLaptop =
{
if ( T8_pubVarDataTask ) exitWith {};
_this addAction [ T8_varTLine05, "call T8_fnc_ActionLaptop", nil, 0.1, false ];
};


T8_fnc_removeActionLaptop =
{
_laptop = _this select 0;
_id = _this select 1;
_laptop removeAction _id;
};


T8_fnc_ActionLaptop =
{
private [ "_laptop", "_caller", "_id" ];
_laptop = _this select 0;
_caller = _this select 1;
_id = _this select 2;

if ( T8_pubVarInUse ) exitWith { player sideChat T8_varTLine02;  };

player sideChat T8_varTLine03;

T8_pubVarInUse = true;
publicVariable "T8_pubVarInUse";

[ _laptop, _id ] spawn 
{
	private [ "_laptop", "_id", "_newFile", "_dlRate" ];
	_laptop = _this select 0;
	_id = _this select 1;
	_newFile = T8_varFileSize;

	createDialog "T8_DataDownloadDialog";

	sleep 0.5;
	ctrlSetText [ 8001, "Connecting ..." ];
	sleep 0.5;
	ctrlSetText [ 8001, "Connected:" ];		
	ctrlSetText [ 8003, format [ "%1 kb", T8_varFileSize ] ];		
	ctrlSetText [ 8004, format [ "%1 kb", _newFile ] ];		

	while { !T8_varDiagAbort } do
	{
		_dlRate = 200 + random 80;
		_newFile = _newFile - _dlRate;

		if ( _newFile < 0 ) then 
		{
			_dlRate = 0;		
			_newFile = 0;
			ctrlSetText [ 8001, "Upload finished!" ];	
			T8_varDiagAbort = true;
			player sideChat T8_varTLine04;
			T8_varDownSucce = true;

			T8_pubVarDataTask = true;
			publicVariable "T8_pubVarDataTask";			

			[ [ _laptop, _id ], "T8_fnc_removeActionLaptop", true, true] spawn BIS_fnc_MP;
		};

		ctrlSetText [ 8002, format [ "%1 kb/t", _dlRate ] ];		
		ctrlSetText [ 8004, format [ "%1 kb left", _newFile ] ];				

		sleep 0.2;
	};

	T8_varDiagAbort = false;

	T8_pubVarInUse = false;
	publicVariable "T8_pubVarInUse";
};
};

downloadDataDONE = true;

Share this post


Link to post
Share on other sites

Hey, I just stumbled across your laptop downloading script recently and I would like to use it in a mission that I am working on where you must sneak into enemy lines and download crucial intel. I am not the best with scripts and I am wondering how can I change the laptops position so that it will be at the dirt airfield near selakano?

I would really like to hear from you if you still are looking at this forum since this is a brilliant script that you have designed it could leave a lot of mission makers like my self to make some amazing missions where you have to download intel and defend it aswell.

Share this post


Link to post
Share on other sites

Neat script. Thanks for sharing.

I was hoping to use it in a slightly different manner, but I can't figure out how to do so. I'll try to explain best i can.

What I was hoping to do was not assign it to a specific Task, but simply fire a trigger when done Uploading a file - and then sync that trigger to a new MenuRespawn respawn position.

I know how to place a respawn module, and sync it to a trigger to get it to show up in mission. No problem there.

But when I tried to simply place respawn module position and sync it to the trigger in your example mission, it didn't seem to work.

Anyway, my desire is to be able to use it over and over again all across the map. So everywhere I go and upload 'data' to certain laptops, a trigger is fired and a new respawn point becomes available there. Just thought it would be neater then simply walking into an area and having the respawn point activated.

If anyone is interested in helping this happen, I'd be very grateful.

Share this post


Link to post
Share on other sites

Thanks for the interest in my script guys!

What I was hoping to do was not assign it to a specific Task, but simply fire a trigger when done Uploading a file - and then sync that trigger to a new MenuRespawn respawn position.

I know how to place a respawn module, and sync it to a trigger to get it to show up in mission. No problem there.

But when I tried to simply place respawn module position and sync it to the trigger in your example mission, it didn't seem to work.

I modified the script for you so it can be used on multiple laptops / objects. Just check the new demo mission I linked below. Hope that is what you are looking for.

Hey, I just stumbled across your laptop downloading script recently and I would like to use it in a mission that I am working on where you must sneak into enemy lines and download crucial intel. I am not the best with scripts and I am wondering how can I change the laptops position so that it will be at the dirt airfield near selakano?

I would really like to hear from you if you still are looking at this forum since this is a brilliant script that you have designed it could leave a lot of mission makers like my self to make some amazing missions where you have to download intel and defend it aswell.

In the new demo mission you can find the Laptops placed in the editor, this should help you move them around.

If you want more or other Objects to be used with the script, give those objects a name and edit this line in the init.sqf

 [ [ laptop01, nameOfMyPlacedObj, oneMorePlacedObj, objCalledHeinz ], "T8_fnc_addActionLaptop", true, true] spawn BIS_fnc_MP;

you can check if the download on a laptop/object was finished by using the following var: T8_pubVarDataTask_MyObjectsName

and with the var T8_pubVarInUse_MyObjectsName you can check if someone uses this object. compare with the triggers placed in the demo mission!

I also inclueded a small bonus in the mission, a small bomb you can defuse/detonate when interacting with it. maybe someone finds this useful. :)

Sadly I haven't had time to test it with someone on Multiplayer / dedicated ... but afaik it should work

download here

@foxhound: if you read this, could you link the armaholic download to my profile (also: t-800a)? then i'll update it by myself. ;)

Edited by t-800a

Share this post


Link to post
Share on other sites
Guest

Thanks for registering, pages connected with your account. Keep in mind it is a future feature, its not active yet (we are working hard to get things done).

Updated version frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Thanks for the update, love this script!

In the past I placed the laptop object in the editor anyway, then in the init.sqf just said something like _laptop = intelLaptop1; Skipping all the placement commands and hair pulling! ;)

Share this post


Link to post
Share on other sites

That is just perfect!

Very kind of you sir, to share you time and talent to help like that.

Thank you very much. :)

Share this post


Link to post
Share on other sites

I'm trying to make a mission with this, but the task always shows up as completed from the briefing screen. Any Ideas what could cause this?

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

×