Jump to content
Purzel

getting the player inside a medical car healed

Recommended Posts

Hi Folks,

this is my problem:

Any human player who enters a medical car "mev" (in cargo) should be healed.

This is what I´ve got:

--------------------------------------
the trigger:
serverside, repeatable

cond:
player in mev      // "mev" is the vehicle name

onAct:

0 = [thisList] call compile preProcessfile "scripts\healing.sqf";

 

--------------------------------------

the healing.sqf:

 

_unit = (_unit select 0);
["<t size='0.5' color='#00ffff'>US Combat-Medic:<br/>Beginning trauma treatment...!</t>",0,0.85,4,2] remoteExec ["bis_fnc_dynamictext", WEST, false];   // should only be visible for units in healing-process...
_unit setdamage 0; 
sleep 3;
[_unit, false] call ace_medical_fnc_setUnconscious;  
sleep 2;
_unit setVariable ["ACE_medical_pain", 0, true]; 
sleep 2;
_unit setVariable ["ACE_medical_bloodVolume", 100, true]; 
sleep 10;
_unit setVariable ["ACE_isUnconscious",false,true];
["<t size='0.5' color='#00ffff'>US Combat-Medic:<br/>You are healed - now get out and fight!</t>",0,0.85,4,2] remoteExec ["bis_fnc_dynamictext", WEST, false];  // should only be visible for units in healing-process...
_this action ["Eject",vehicle _this];
sleep 5;



In my opinion, this stuff should work, but it doesnt - where is the problem?
Has to work on a dedicated server.

I´m trying about 4 hours now...

Greetz Purzel
 


 

Share this post


Link to post
Share on other sites

First line should be _unit = _this select 0;

  • Thanks 1

Share this post


Link to post
Share on other sites

Also your messages will be seen by everyone in blufor. And instead of using a trigger you should use a getIn eventhandler.

  • Thanks 1

Share this post


Link to post
Share on other sites

Thx,
but how should I use a getIn eventhandler...?
I´m not that good at scripting...

changed the text to:
 

["<t color='#ff0000' size = '0.7'>US Combat-Medic:<br/>Dude, if you need medical attention,<br/>get in cargo for treatment</t>",-1,0.55,4,1,0,789] spawn BIS_fnc_dynamicText;

 

Share this post


Link to post
Share on other sites

Okay so first you should add the handler only on the server. Best way is to add it from your initserver.sqf

 

It will look something like that.

mev addEventHandler ["GetIn", { params ["_vehicle", "_role", "_unit", "_turret"];

[_unit] execVM "healing.sqf"

}];

  • Thanks 1

Share this post


Link to post
Share on other sites

There are a few other things that are not ok in your code: replace the WEST in your remote exec's by _unit. And anyway if I where you I'd just remote exec the whole healing.sqf where unit is local (and remove all the remote exec's inside) also in the line where you use the eject action _this should be _unit. Sorry for not explaining everything or pasting full code but I'm on my phone.

  • Thanks 1

Share this post


Link to post
Share on other sites

this is what I´ve actual did:

_unit = _this select 0;
["<t color='#ff0000' size = '0.7'>US Combat-Medic:<br/>Beginning trauma treatment...!</t>",-1,1.5,4,1,0,789] spawn BIS_fnc_dynamicText;  
_unit setdamage 0; 
sleep 3;
[_unit, false] call ace_medical_fnc_setUnconscious;  
sleep 2;
_unit setVariable ["ACE_medical_pain", 0, true]; 
sleep 2;
_unit setVariable ["ACE_medical_bloodVolume", 100, true]; 
sleep 10;
_unit setVariable ["ACE_isUnconscious",false,true];
["<t color='#ff0000' size = '0.7'>US Combat-Medic:<br/>You are healed - now get out and fight!</t>",-1,1.5,4,1,0,789] spawn BIS_fnc_dynamicText;
_unit action ["Eject",vehicle _unit];

but the text is still not shown.

Share this post


Link to post
Share on other sites

Does the rest work ? If so have you tested just the text bits in the console to see if they work ?

  • Thanks 1

Share this post


Link to post
Share on other sites

Assuming your code is correct here's how I would set it up :

In your initserver.sqf

 

Spoiler

//initserver.sqf
mev addEventHandler ["GetIn", {
	params ["_vehicle", "_role", "_unit", "_turret"];
	["TAG_heal_event",[_unit],_unit] call CBA_fnc_localEvent;
}];

 

 

In your init.sqf

Spoiler

//init.sqf 
["TAG_heal_event",
	{
		_this spawn
		{
			params ["_unit"];
			["<t color='#ff0000' size = '0.7'>US Combat-Medic:<br/>Beginning trauma treatment...!</t>",-1,1.5,4,1,0,789] spawn BIS_fnc_dynamicText;  
			_unit setdamage 0; 
			sleep 3;
			[_unit, false] call ace_medical_fnc_setUnconscious;  
			sleep 2;
			_unit setVariable ["ACE_medical_pain", 0, true]; 
			sleep 2;
			_unit setVariable ["ACE_medical_bloodVolume", 100, true]; 
			sleep 10;
			_unit setVariable ["ACE_isUnconscious",false,true];
			["<t color='#ff0000' size = '0.7'>US Combat-Medic:<br/>You are healed - now get out and fight!</t>",-1,1.5,4,1,0,789] spawn BIS_fnc_dynamicText;
			_unit action ["Eject",vehicle _unit];
		}
	}

] call CBA_fnc_addEventHandler;

 

Using cba events to run some code where unit is local is how ACE does it instead of remote executing, I believe it's better optimized this way.

  • Thanks 1

Share this post


Link to post
Share on other sites

Shouldnt I place the second code better in InitPlayerLocal.sqf?
Because our "Bloodfix" is there to. (Its a fix for sometime ACE does not work correctly when giveing blood)

 

if (player getVariable ["ACE_medical_medicClass",0] > 0) then {

	player addaction ["<t color='#FF0000'>ACE-FIX (Blood und Morphine)</t>", {_this spawn FAS_fnc_AceBloodFix}, nil, 0, false, true, "", "alive _target && _target == _this"];
	player addEventHandler ["respawn", {player addaction ["<t color='#FF0000'>ACE-FIX (Blood und Morphine)</t>", {_this spawn FAS_fnc_AceBloodFix}, nil, 0, false, true, "", "alive _target && _target == _this"]}];

};

this is to much knowledge for me... unfortunatly I´m not the Coder, just a little mission-builder...
 

Share this post


Link to post
Share on other sites

Unfortunarly I´m not getting healed...

 

just one step-healing... this means:
When I get shot an have "red" arm/leg/whatever it changes just  as if I used one bandage on that bodypart.
So I have to get in and out the ambulance until every part is healed, which is not satisfying..
I need a one-time-all-healing...

and there´s still no text... but I´m thrown out of the car (still wounded)
 

 

Share this post


Link to post
Share on other sites

To heal why don't you use the ace function ?
 

[_unit,_unit] call ACE_medical_fnc_treatmentAdvanced_fullHeal;

 

  • Thanks 1

Share this post


Link to post
Share on other sites

I didnt know that function... 😌


but still no Text for the player entering the vehicle:

 

["<t color='#ff0000' size = '0.7'>US Combat-Medic:<br/>Beginning trauma treatment...!</t>",-1,2,4,1,0,789] spawn BIS_fnc_dynamicText;

["<t size='0.7' color='#ff0000'>US Combat-Medic:<br/>Beginning trauma treatment...!</t>",0,2,4,1] remoteExec ["bis_fnc_dynamictext", _unit, false]; 

both codes are not working on the dedicated server, seems to be a locality problem...

 

Share this post


Link to post
Share on other sites

I found this, which should be the working solution, (but I don´t know how to use it) :

 

 Example:
 * [player] call adv_fnc_fullHeal
 *
 * Public: No
 */

params [
	["_target", player, [objNull]]
];

_target setDamage 0;

if (isClass(configFile >> "CfgPatches" >> "ace_medical")) exitWith {
	_target setVariable ["adv_aceSplint_reopenUndo",true];
	
	if (isNull player) then {
		[objNull,_target] call ACE_medical_fnc_treatmentAdvanced_fullHealLocal;
	} else {
		[player,_target] call ACE_medical_fnc_treatmentAdvanced_fullHealLocal;
	};

/*
	if ( (missionnamespace getVariable ["ace_medical_level",2]) > 1 ) then {
		if (isNull player) then {
			[objNull,_target] call ACE_medical_fnc_treatmentAdvanced_fullHealLocal;
		} else {
			[player,_target] call ACE_medical_fnc_treatmentAdvanced_fullHealLocal;
		};
	} else {
		_target setVariable ["ace_medical_pain", 0, true];
		_target setVariable ["ace_medical_morphine", 0, true];
		
		_target setVariable ["ace_medical_bloodVolume", 100, true];
		
		_target setVariable ["ace_medical_bodyPartStatus", [0,0,0,0,0,0], true];
		{
			[_target, _x, 0, false] call ace_medical_fnc_setHitPointDamage;
			nil;
		} count [
			"HitHead"
			,"HitBody"
			,"HitArms"
			,"HitLeftArm"
			,"HitRightArm"
			,"HitLegs"
			,"HitLeftLeg"
			,"HitRightLeg"
		];
		//_target setHitPointDamage ["hitHead", 0];
		//_target setHitPointDamage ["hitBody", 0];
		//_target setHitPointDamage ["hitArms", 0];
		//_target setHitPointDamage ["hitLegs", 0];
		
		[_target,false] call ACE_medical_fnc_setUnconscious;
	};
	*/
	nil
};

 Maybe someone could help me with this?

Only the player, who is entering the cargo of my ambulance, should be healed completely.
Do I have to set up a trigger, copy the code above into a healing.sqf and call it from the trigger?
Or can I somehow use this stuff in the solution of Mr. H without trigger and the serverInit.sqf instead...?
This is to much coding stuff and far above my coding-level...
I just need a working solution for that problem. The code above seem to the solution for medic-unit, which can heal another unit.

Greetz Purzel

PS:
What does the ACE-Option "is medical vehicle" in the attributes of an vehicle do?
As I detected, it seems not to heal a player inside (but this would be a fine solution, which I could handle)


 

Share this post


Link to post
Share on other sites
On 1/20/2020 at 12:37 AM, Purzel said:

What does the ACE-Option "is medical vehicle" in the attributes of an vehicle do?

Makes the vehicle count as a "medical vehicle"
related to other ace settings, like the ability to only use personal aid kit in medical vehicle/facility.

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

×