Advertisement
Tyler2351

fn_onPlayerKilled.sql

Jan 27th, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_onPlayerKilled.sqf
  4. Author: Bryan "Tonic" Boardwine
  5.  
  6. Description:
  7. When the player dies collect various information about that player
  8. and pull up the death dialog / camera functionality.
  9. */
  10. params [
  11. ["_unit",objNull,[objNull]],
  12. ["_killer",objNull,[objNull]]
  13. ];
  14. disableSerialization;
  15.  
  16. if((vehicle _unit) != _unit) then {
  17. UnAssignVehicle _unit;
  18. _unit action ["getOut", vehicle _unit];
  19. _unit setPosATL [(getPosATL _unit select 0) + 3, (getPosATL _unit select 1) + 1, 0];
  20. };
  21.  
  22. //Set some vars
  23. _unit SVAR ["Revive",true,true];
  24. _unit SVAR ["name",profileName,true]; //Set my name so they can say my name.
  25. _unit SVAR ["restrained",false,true];
  26. _unit SVAR ["Escorting",false,true];
  27. _unit SVAR ["transporting",false,true]; //Why the fuck do I have this? Is it used?
  28. _unit SVAR ["playerSurrender",false,true];
  29. _unit SVAR ["steam64id",(getPlayerUID player),true]; //Set the UID.
  30.  
  31. //Setup our camera view
  32. life_deathCamera = "CAMERA" camCreate (getPosATL _unit);
  33. showCinemaBorder TRUE;
  34. life_deathCamera cameraEffect ["Internal","Back"];
  35. createDialog "DeathScreen";
  36. life_deathCamera camSetTarget _unit;
  37. life_deathCamera camSetRelPos [0,3.5,4.5];
  38. life_deathCamera camSetFOV .5;
  39. life_deathCamera camSetFocus [50,0];
  40. life_deathCamera camCommit 0;
  41.  
  42. (findDisplay 7300) displaySetEventHandler ["KeyDown","if((_this select 1) == 1) then {true}"]; //Block the ESC menu
  43.  
  44. //Create a thread for something?
  45. _unit spawn {
  46. private["_maxTime","_RespawnBtn","_Timer"];
  47. disableSerialization;
  48. _RespawnBtn = ((findDisplay 7300) displayCtrl 7302);
  49. _Timer = ((findDisplay 7300) displayCtrl 7301);
  50.  
  51. _maxTime = time + (life_respawn_timer * 60);
  52. _RespawnBtn ctrlEnable false;
  53. waitUntil {_Timer ctrlSetText format[localize "STR_Medic_Respawn",[(_maxTime - time),"MM:SS.MS"] call BIS_fnc_secondsToString];
  54. round(_maxTime - time) <= 0 OR isNull _this};
  55. _RespawnBtn ctrlEnable true;
  56. _Timer ctrlSetText localize "STR_Medic_Respawn_2";
  57. };
  58.  
  59. [] spawn life_fnc_deathScreen;
  60. [] spawn life_fnc_nlrSetup;
  61.  
  62. //Create a thread to follow with some what precision view of the corpse.
  63. [_unit] spawn {
  64. private["_unit"];
  65. _unit = _this select 0;
  66. waitUntil {if(speed _unit == 0) exitWith {true}; life_deathCamera camSetTarget _unit; life_deathCamera camSetRelPos [0,3.5,4.5]; life_deathCamera camCommit 0;};
  67. };
  68.  
  69. //Make the killer wanted
  70. if(!isNull _killer && {_killer != _unit} && {side _killer != west} && {alive _killer}) then {
  71. if(vehicle _killer isKindOf "LandVehicle") then {
  72. [getPlayerUID _killer,_killer GVAR ["realname",name _killer],"187V"] remoteExecCall ["life_fnc_wantedAdd",RSERV];
  73. //Get rid of this if you don't want automatic vehicle license removal.
  74. if(!local _killer) then {
  75. [2] remoteExecCall ["life_fnc_removeLicenses",_killer];
  76. };
  77. } else {
  78. [getPlayerUID _killer,_killer GVAR ["realname",name _killer],"187"] remoteExecCall ["life_fnc_wantedAdd",RSERV];
  79.  
  80. if(!local _killer) then {
  81. [3] remoteExecCall ["life_fnc_removeLicenses",_killer];
  82. };
  83. };
  84. };
  85.  
  86. private _BountyPeeps = [];
  87.  
  88. {
  89. if (license_civ_bountyH) then {_BountyPeeps pushBack _x};
  90. } forEach playableUnits;
  91.  
  92. life_save_gear = [player] call life_fnc_fetchDeadGear;
  93.  
  94. //Killed by cop stuff...
  95. if(side _killer == west && playerSide != west) then {
  96. life_copRecieve = _killer;
  97. //Did I rob the federal reserve?
  98. if(!life_use_atm && {CASH > 0}) then {
  99. [format[localize "STR_Cop_RobberDead",[CASH] call life_fnc_numberText]] remoteExecCall ["life_fnc_broadcast",RCLIENT];
  100. CASH = 0;
  101. };
  102. };
  103.  
  104. if (side _killer isEqualTo civilian && {_killer != _unit}) then {
  105. if (_killer in _BountyPeeps) then {
  106. life_bountyHunter = _killer;
  107. };
  108.  
  109. if (!isNull _killer) then {
  110. life_removeBounty = true;
  111. };
  112. };
  113.  
  114. if(!isNull _killer && {_killer != _unit}) then {
  115. life_removeWanted = true;
  116. };
  117.  
  118. _handle = [_unit] spawn life_fnc_dropItems;
  119. waitUntil {scriptDone _handle};
  120.  
  121. life_hunger = 100;
  122. life_thirst = 100;
  123. life_carryWeight = 0;
  124. CASH = 0;
  125.  
  126. [] call life_fnc_hudUpdate; //Get our HUD updated.
  127. [player,life_sidechat,playerSide] remoteExecCall ["TON_fnc_managesc",RSERV];
  128.  
  129. [0] call SOCK_fnc_updatePartial;
  130. [3] call SOCK_fnc_updatePartial;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement