iBobbiee 0 Posted December 15, 2021 Hi there, I'm looking for a script or something along the lines to add the ability for server admins to be able to revive someone incapacitated, using the map. I've got a basic admin system in place, and I have a few addAction functions in place already for them (like clicking on the map to teleport, and healing players just by looking at them), but I cannot figure out how to heal/revive players using the map. My intention is to use the scroll wheel to select "Map Revive", which opens the map and I'm able to click on an incapacitated player and revive them - seems simple but I'm beginning to give myself a headache trying to figure it out. If anyone could be of any help, that would be awesome. Thanks! Share this post Link to post Share on other sites
pierremgi 4738 Posted December 15, 2021 You can use the MEH "mapSingleClick" checking for any incapacitated player near the cursor position. So, here is an example of code for admins. (I suppose you already have icon(s) on incapacitated player(s), so you know where there are on map) For a 20 m radius: addMissionEventHandler ["MapSingleClick", { params ["_units", "_pos", "_alt", "_shift"]; private _incapPlyrs = (allPlayers select {lifeState _x == "incapacitated"}) inAreaArray [_pos, 20, 20]; if (_incapPlyrs isNotEqualTo []) then { { if (local _x) then { _x setUnconscious false } else { [_x,false] remoteExec ['setUnconscious',_x] } } forEach _incapPlyrs; }; }]; Welcome on forum,btw! 4 Share this post Link to post Share on other sites
avibird 1 141 Posted December 27, 2021 @pierremgi this one👍 1 Share this post Link to post Share on other sites
pierremgi 4738 Posted December 28, 2021 For playable units, you just have to change: private _incapPlyrs = (allPlayers select {lifeState _x == "incapacitated"}) inAreaArray [_pos, 20, 20]; by private _incapPlyrs = (playableUnits select {lifeState _x == "incapacitated"}) inAreaArray [_pos, 20, 20]; Note 1: you can change (everywhere!) the name of the local variable _incapPlyrs by _incapPlydUnits (or any name you want). Note 2: You can add a filter for side or group of the player clicking on map. Example: _incapPlyrs = (playableUnits select {lifeState _x == "incapacitated" && group _x == group player}) inAreaArray [_pos, 20, 20] 1 1 Share this post Link to post Share on other sites
Larrow 2797 Posted December 29, 2021 If using BIS Revive... Spoiler #include "\a3\functions_f_mp_mark\revive\defines.inc" if ( !canSuspend ) exitWith { if ( !isNil "_fnc_scriptName" && { missionNamespace getVariable _fnc_scriptName isEqualType {} } ) then { //Only works if this function is defined in CfgFunctions private _nul = [] spawn ( missionNamespace getVariable _fnc_scriptName ); }else{ hint "This function needs to be run scheduled( spawn ) - ADMIN revive"; }; }; InCapPlayers = allPlayers select { GET_STATE( _x ) == STATE_INCAPACITATED }; if ( InCapPlayers isNotEqualTo [] ) then { { private _mrk = createMarkerLocal[ format[ "Revive_%1", name _x ], getPosATL _x ]; _mrk setMarkerShapeLocal "ICON"; _mrk setMarkerTypeLocal "Select"; _mrk setMarkerDirLocal 0; _mrk setMarkerColorLocal "ColorGreen"; _mrk setMarkerAlphaLocal 1; _mrk setMarkerTextLocal name _x; InCapPlayers set[ _forEachIndex, [ _mrk, _x ] ]; }forEach InCapPlayers; if !( visibleMap ) then { openMap true; }; private _map = findDisplay 12 displayCtrl 51; hint "Choose a Player to Revive\n Or close the map to finish"; _MEH_OEF_ID = addMissionEventHandler[ "EachFrame", { if ( visibleMap ) then { _map = findDisplay 12 displayCtrl 51; _over = ctrlMapMouseOver _map; if !( _over isEqualTo [] ) then { if ( isNil "LASTOVER" || { !isNil "LASTOVER" && { LASTOVER isNotEqualTo _over } } ) then { LASTOVER = _over; if ( _over select 0 == "marker" && { _over select 1 select[ 0, 7 ] == "Revive_" } ) then { hint format[ "Revive %1", markerText( _over select 1 ) ]; }; }; }else{ LASTOVER = nil; }; }else{ removeMissionEventHandler[ "EachFrame", _thisEventHandler ]; }; }]; _MAPEH_MBU_ID = _map ctrlAddEventHandler[ "MouseButtonUp", { params[ "_ctrl", "_button", "_mouseX", "_mouseY", "_shft", "_ctr", "_alt" ]; _over = ctrlMapMouseOver _ctrl; if ( _over isNotEqualTo [] && { _over select 0 == "marker" && { _over select 1 select[ 0, 7 ] == "Revive_" } } ) then { _playerData = InCapPlayers select{ _x select 0 == ( _over select 1 ) } select 0; if !( isNil "_playerData" ) then { _playerData params[ "_mrk", "_player" ]; hint format[ "Reviving %1", name _player ]; SET_STATE( _player, STATE_REVIVED ); deleteMarkerLocal _mrk; InCapPlayers deleteAt ( InCapPlayers find _playerData ); }; }; }]; waitUntil{ !visibleMap }; _map ctrlRemoveEventHandler[ "MouseButtonUp", _MAPEH_MBU_ID ]; { _x params[ "_mrk" ]; deleteMarkerLocal _mrk; }forEach InCapPlayers; }else{ hint "No Players need reviving"; }; InCapPlayers = nil; Tested - Example Mission 1 Share this post Link to post Share on other sites
Larrow 2797 Posted January 2, 2022 Updated previous post with a tested version including Example Mission using ctrlMapMouseOver instead of marker distance. 1 Share this post Link to post Share on other sites