arma_max 13 Posted July 27, 2019 Hi, I want to make sure that in SP my player gets teleported to a specific marker when he is dying. I thought to start simple I catch the HandleDamage event and manage it in there (no teleportation in here): player addEventHandler ["HandleDamage", { _logKey = "HandleDamage--------------------------------------- "; diag_log format ["%1unit: %2", _logKey, _this select 0]; diag_log format ["%1_selection: %2", _logKey, _this select 1]; diag_log format ["%1_damage: %2", _logKey, _this select 2]; diag_log format ["%1_source: %2", _logKey, _this select 3]; diag_log format ["%1_projectile: %2", _logKey, _this select 4]; diag_log format ["%1_hitIndex: %2", _logKey, _this select 5]; diag_log format ["%1_instigator: %2", _logKey, _this select 6]; diag_log format ["%1_hitPoint: %2", _logKey, _this select 7]; diag_log format ["%1_player getDammage: %2", _logKey, getDammage player]; if (getDammage player >= 0.9) then { player setDamage 0; }; }]; When I now go out on the battlefield it seems to work fine but then after some time under heavy fire and grenades, my player still dies and I get the mission end screen. Am I missing something here - should I look for a different event instead? Max Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted July 27, 2019 Hello there arma_max ! You can find here my WIP Respawn in SP , Script - Mod Version : Share this post Link to post Share on other sites
sabot10.5mm 47 Posted July 28, 2019 Spoiler onPlayerKilled.sqf private ["_plyr","_kilr"]; _plyr = _this select 0; _kilr = _this select 1; //If you want to respawn at a marker...call the script like this... nul = [_plyr,_kilr,"wrespawn"] execVM "playerKilled.sqf"; //If you want to respawn as a playable AI...call the script like this... //nul = [_plyr,_kilr] execVM "playerKilled.sqf"; playerKilled.sqf private ["_plyr","_kilr","_type","_group","_dist","_camera","_found","_rand","_unit"]; _plyr = _this select 0; _kilr = _this select 1; _mrkr = if (count _this >2) then {_this select 2}; if (isNil "_kilr") then {_kilr = objNull}; //grab some stuff we need later _type = typeOf _plyr; _group = group _plyr; _dist = _plyr distance _kilr; if (count _this > 2) then { //if (not (isNil _mrkr)) then { //create the new unit.... same group _unit = _group createUnit [_type, (getMarkerPos _mrkr), [], 1, "none"]; sleep 1; addSwitchableUnit _unit; selectPlayer _unit; _unit setRank "COLONEL"; waitUntil {_unit == player}; _found = true; _oldUnit = _plyr; _oldGroup = group _oldUnit; //We dont care if he was not the leader if ((leader _oldGroup) == _oldUnit) then { _oldGroup selectLeader _unit; waitUntil {(leader _oldGroup) == _unit}; _handle = [_oldUnit, _oldGroup, _unit] spawn { _oldUnit = _this select 0; _oldGroup = _this select 1; _unit = _this select 2; _oldProviders = _oldUnit getVariable ["BIS_SUPP_allProviderModules",[]]; _HQ = _oldUnit getVariable ["BIS_SUPP_HQ",nil]; //Wait for a new leader to be assigned _leader = _unit; if (isNil {_unit getVariable ["BIS_SUPP_HQ",nil]}) then { if ((count _oldProviders) > 0) then { { _providerModule = _x; { if (typeOf _x == "SupportRequester" && _oldUnit in (synchronizedObjects _x)) then { [_leader, _x, _providerModule] call BIS_fnc_addSupportLink; }; }forEach synchronizedObjects _providerModule; }forEach _oldProviders; }; _unit setVariable ["BIS_SUPP_transmitting", false]; _unit kbAddTopic ["BIS_SUPP_protocol", "A3\Modules_F\supports\kb\protocol.bikb", "A3\Modules_F\supports\kb\protocol.fsm", {call compile preprocessFileLineNumbers "A3\Modules_F\supports\kb\protocol.sqf"}]; _unit setVariable ["BIS_SUPP_HQ", _HQ]; }; { _used = _oldUnit getVariable [format ["BIS_SUPP_used_%1",_x], 0]; _leader setVariable [format ["BIS_SUPP_used_%1", _x], _used, true] } forEach [ "Artillery", "CAS_Heli", "CAS_Bombing", "UAV", "Drop", "Transport" ]; }; }; } else { //try to find a random playable unit while {(not (_found)) and ((count switchableunits) >=1)} do { _unit = switchableunits select (floor (random (count switchableunits))); if (alive _unit) then { _found = true; selectplayer _unit; }; sleep 1; }; }; BIS_DeathBlur ppEffectAdjust [0.0]; BIS_DeathBlur ppEffectCommit 0.0; onPlayerKilled.sqf Executed when player is killed in singleplayer or in multiplayer mission. 1 Share this post Link to post Share on other sites