Jump to content
darkxess

How to get "notifications" using this script

Recommended Posts

Hey guys, I am using the vehicle respawn script by Quicksilver and though its working fine for me I would like to get it to show a notification upon respawning the vehicle like the default BIS spawner does.

 

This is the script:

/*
@filename: fn_vMonitor.sqf
Credit: Tophe for earlier monitor script
Author:

	Quiksilver
	
Last modified:

	23/10/2014 ArmA 1.32
	
Description:

	Vehicle monitor. This code must be spawned, not called. Ex. 

______________________________________________________*/

if (!isServer) exitWith { /* GO AWAY PLAYER */ };

//======================================== CONFIG

private ["_v","_t","_d","_s","_i","_sd","_sp","_ti","_u"];

#define DIST_FROM_SPAWN 150

_v = _this select 0;												// vehicle
_d = _this select 1;												// spawn delay
_s = _this select 2;												// setup
_i = _this select 3;												// init

_t = typeOf _v;														// type
_sd = getDir _v;													// spawn direction
_sp = getPosATL _v;													// spawn position

sleep (5 + (random 5));

[_v] call _i;

//======================================== MONITOR LOOP

while {true} do {
	
	//======================================== IF DESTROYED
	
	if (!alive _v) then {
		if (({((_sp distance _x) < 1.5)} count (entities "AllVehicles")) < 1) then {
			_ti = time + _d;
			waitUntil {sleep 5; (_ti < time)};
			if (!isNull _v) then {deleteVehicle _v;}; sleep 0.1;
			_v = createVehicle [_t,[(random 1000),(random 1000),(10000 + (random 20000))],[],0,"NONE"]; sleep 0.1;
			waitUntil {!isNull _v}; sleep 0.1;
			_v setDir _sd; sleep 0.1;
			_v setPos [(_sp select 0),(_sp select 1),((_sp select 2)+0.1)]; sleep 0.1;
			[_v] call _i;
		};
	};
	
	sleep (5 + (random 5));
	
	//======================================== IF ABANDONED
	
	if ((_v distance _sp) > DIST_FROM_SPAWN) then {
		if (isMultiplayer) then {_u = playableUnits;} else {_u = switchableUnits;};
		if (({(_v distance _x) < PARAMS_VehicleRespawnDistance} count _u) < 1) then {
			if ((count (crew _v)) == 0) then {
				_v lock 2;
				_v allowDamage FALSE;
				_v setPos [(random 1000),(random 1000),(10000 + (random 20000))];
				_v enableSimulationGlobal FALSE;
				_v hideObjectGlobal TRUE;
				waitUntil {
					sleep (5 + (random 5)); 
					(({(_sp distance _x) < 1.5} count (entities "AllVehicles")) < 1)
				};
				_v enableSimulationGlobal TRUE;
				_v hideObjectGlobal FALSE;
				_v allowDamage TRUE;
				_v lock 0;
				_v setDir _sd; sleep 0.1;
				_v setPos _sp; sleep 0.1;
				_v setDamage 0; sleep 0.1;
				_v setVehicleAmmo 1; sleep 0.1;
				if ((fuel _v) < 0.95) then {[[_v,1],"setFuel",true,false] spawn BIS_fnc_MP;};
				if (isEngineOn _v) then {_v engineOn FALSE;}; sleep 0.1;
				if (isCollisionLightOn _v) then {_v setCollisionLight FALSE;}; sleep 0.1;
				if (isLightOn _v) then {_v setPilotLight FALSE;}; sleep 0.1;
			};
		};
	};
	sleep (20 + (random 20));
};

 

And this is the part that goes into the vehicles init line. I have gone over it and tried various ways to get it to show a notification but to no avail.
 

0 = [this,30,FALSE,QS_fnc_vSetup02] spawn QS_fnc_vMonitor;


Please, any help? thanks :)

Share this post


Link to post
Share on other sites

Hi darkxess, you could try and modify like this

....
	_v setPos [(_sp select 0),(_sp select 1),((_sp select 2)+0.1)]; sleep 0.1;
	[_v] call _i;
	["RespawnVehicle",["Vehicle","base","\A3\ui_f\data\map\mapcontrol\taskIcon_ca.paa"]] remoteExec ["BIS_fnc_showNotification"];
};
....

the relevant part in your fn_vMonitor.sqf

  • Like 1

Share this post


Link to post
Share on other sites

@Nikander awesome it worked, but the icon "taskIcon" which you have assigned, how would I change that to the type of vehicle which has been respawned? is it possible?

Thanks man :)

  • Like 1

Share this post


Link to post
Share on other sites
Just now, darkxess said:

icon "taskIcon" which you have assigned, how would I change that to the type of vehicle which has been respawned?

 

@darkxess, try the following

["RespawnVehicle",["Vehicle","base",getText (configfile >> "CfgVehicles" >> typeOf _v >> "picture")]] remoteExec ["BIS_fnc_showNotification"];

I hope this helps

  • Like 1

Share this post


Link to post
Share on other sites

^Mate, your my new best friend, it works perfectly, thank you so much :)

  • 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

×