Advertisement
AdamKadmon

Untitled

Mar 21st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.30 KB | None | 0 0
  1. /**
  2. * ExileServer_object_player_event_onMpKilled
  3. *
  4. * Exile Mod
  5. * www.exilemod.com
  6. * © 2015 Exile Mod Team
  7. *
  8. * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  9. * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  10. */
  11.  
  12. private["_victim","_killer","_countDeath","_countKill","_killSummary","_killingPlayer","_killType","_oldVictimRespect","_newVictimRespect","_oldKillerRespect","_newKillerRespect","_systemChat","_modifyVictimRespect","_respectLoss","_perks","_minRespectTransfer","_respectTransfer","_perkNames","_killerStatsNeedUpdate","_newKillerFrags","_victimStatsNeedUpdate","_newVictimDeaths","_victimPosition"];
  13. _victim = _this select 0;
  14. _killer = _this select 1;
  15. if (!isServer || hasInterface || isNull _victim) exitWith {};
  16. _victim setVariable ["ExileDiedAt", time];
  17. if !(isPlayer _victim) exitWith {};
  18. _victim setVariable ["ExileIsDead", true];
  19. _victim setVariable ["ExileName", name _victim, true];
  20. _countDeath = false;
  21. _countKill = false;
  22. _killSummary = [];
  23. _killingPlayer = _killer call ExileServer_util_getFragKiller;
  24. _killType = [_victim, _killer, _killingPlayer] call ExileServer_util_getFragType;
  25. _oldVictimRespect = _victim getVariable ["ExileScore", 0];
  26. _newVictimRespect = _oldVictimRespect;
  27. _oldKillerRespect = 0;
  28. if !(isNull _killingPlayer) then
  29. {
  30. _oldKillerRespect = _killingPlayer getVariable ["ExileScore", 0];
  31. };
  32. _newKillerRespect = _oldKillerRespect;
  33. switch (_killType) do
  34. {
  35. default
  36. {
  37. _countDeath = true;
  38. _systemChat = format ["A player has died"];
  39. _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "unlucky")));
  40. };
  41. case 1:
  42. {
  43. _countDeath = true;
  44. _modifyVictimRespect = true;
  45. _systemChat = format ["A player has died"];
  46. _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "suicide")));
  47. };
  48. case 2:
  49. {
  50. _countDeath = true;
  51. _countKill = false;
  52. _systemChat = format ["A player has died"];
  53. _newVictimRespect = _oldVictimRespect;
  54. _victim call ExileServer_system_russianRoulette_event_onPlayerDied;
  55. };
  56. case 3:
  57. {
  58. _countDeath = true;
  59. _countKill = false;
  60. _systemChat = format ["A player has died"];
  61. _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "crash")));
  62. };
  63. case 4:
  64. {
  65. _countDeath = true;
  66. _countKill = false;
  67. _systemChat = format ["A player has died"];
  68. _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "npc")));
  69. };
  70. case 5:
  71. {
  72. _countDeath = false;
  73. _countKill = false;
  74. _systemChat = format ["A player has died"];
  75. _respectLoss = round ((abs _oldKillerRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "friendyFire")));
  76. _newKillerRespect = _oldKillerRespect - _respectLoss;
  77. _killSummary pushBack ["", -1 * _respectLoss];
  78. };
  79. case 6:
  80. {
  81. _countDeath = false;
  82. _countKill = false;
  83. _systemChat = format ["A player has died"];
  84. _respectLoss = round ((abs _oldKillerRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "bambiKill")));
  85. _newKillerRespect = _oldKillerRespect - _respectLoss;
  86. _killSummary pushBack ["", -1 * _respectLoss];
  87. };
  88. case 7:
  89. {
  90. _countDeath = true;
  91. _countKill = true;
  92. _perks = [_victim, _killer, _killingPlayer] call ExileServer_util_getFragPerks;
  93. _minRespectTransfer = getNumber (configFile >> "CfgSettings" >> "Respect" >> "minRespectTransfer");
  94. _respectTransfer = round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "frag")));
  95. if (_respectTransfer < _minRespectTransfer) then
  96. {
  97. _respectTransfer = _minRespectTransfer;
  98. };
  99. _newVictimRespect = _oldVictimRespect - _respectTransfer;
  100. _newKillerRespect = _oldKillerRespect + _respectTransfer;
  101. _killSummary pushBack ["", _respectTransfer];
  102. if (_perks isEqualTo []) then
  103. {
  104. _systemChat = format ["A player has died"];
  105. }
  106. else
  107. {
  108. _perkNames = [];
  109. {
  110. _perkNames pushBack (_x select 0);
  111. _killSummary pushBack _x;
  112. _newKillerRespect = _newKillerRespect + (_x select 1);
  113. }
  114. forEach _perks;
  115. _systemChat = format ["A player has died"];
  116. };
  117. };
  118. };
  119. if !(isNull _killingPlayer) then
  120. {
  121. if !(_killSummary isEqualTo []) then
  122. {
  123. [_killingPlayer, "showFragRequest", [_killSummary]] call ExileServer_system_network_send_to;
  124. };
  125. };
  126. if !(isNull _killingPlayer) then
  127. {
  128. _killerStatsNeedUpdate = false;
  129. if (_countKill) then
  130. {
  131. _newKillerFrags = _killingPlayer getVariable ["ExileKills", 0];
  132. _newKillerFrags = _newKillerFrags + 1;
  133. _killerStatsNeedUpdate = true;
  134. _killingPlayer setVariable ["ExileKills", _newKillerFrags];
  135. format["addAccountKill:%1", getPlayerUID _killingPlayer] call ExileServer_system_database_query_fireAndForget;
  136. };
  137. if !(_newKillerRespect isEqualTo _oldKillerRespect) then
  138. {
  139. _killingPlayer setVariable ["ExileScore", _newKillerRespect];
  140. _killerStatsNeedUpdate = true;
  141. format["setAccountScore:%1:%2", _newKillerRespect, getPlayerUID _killingPlayer] call ExileServer_system_database_query_fireAndForget;
  142. };
  143. if (_killerStatsNeedUpdate) then
  144. {
  145. _killingPlayer call ExileServer_object_player_sendStatsUpdate;
  146. };
  147. };
  148. _victimStatsNeedUpdate = false;
  149. if (_countDeath) then
  150. {
  151. _newVictimDeaths = _victim getVariable ["ExileDeaths", 0];
  152. _newVictimDeaths = _newVictimDeaths + 1;
  153. _victim setVariable ["ExileDeaths", _newVictimDeaths];
  154. _victimStatsNeedUpdate = true;
  155. format["addAccountDeath:%1", getPlayerUID _victim] call ExileServer_system_database_query_fireAndForget;
  156. };
  157. if !(_newVictimRespect isEqualTo _oldVictimRespect) then
  158. {
  159. _victim setVariable ["ExileScore", _newVictimRespect];
  160. _victimStatsNeedUpdate = true;
  161. format["setAccountScore:%1:%2", _newVictimRespect, getPlayerUID _victim] call ExileServer_system_database_query_fireAndForget;
  162. };
  163. if (_victimStatsNeedUpdate) then
  164. {
  165. _victim call ExileServer_object_player_sendStatsUpdate;
  166. };
  167. if ((vehicle _victim) isEqualTo _victim) then
  168. {
  169. if !(underwater _victim) then
  170. {
  171. if !(_victim call ExileClient_util_world_isInTraderZone) then
  172. {
  173. _victim call ExileServer_object_flies_spawn;
  174. };
  175. };
  176. };
  177. if !(_systemChat isEqualTo "") then
  178. {
  179. if ((getNumber (configFile >> "CfgSettings" >> "KillFeed" >> "showKillFeed")) isEqualTo 1) then
  180. {
  181. ["systemChatRequest", [_systemChat]] call ExileServer_system_network_send_broadcast;
  182. };
  183. };
  184. if !(_systemChat isEqualTo "") then
  185. {
  186. if ((getNumber (configFile >> "CfgSettings" >> "Logging" >> "deathLogging")) isEqualTo 1) then
  187. {
  188. "extDB3" callExtension format["1:DEATH:%1", _systemChat];
  189. };
  190. };
  191. _victimPosition = getPos _victim;
  192. format["insertPlayerHistory:%1:%2:%3:%4:%5", getPlayerUID _victim, name _victim, _victimPosition select 0, _victimPosition select 1, _victimPosition select 2] call ExileServer_system_database_query_fireAndForget;
  193. format["deletePlayer:%1", _victim getVariable ["ExileDatabaseId", -1]] call ExileServer_system_database_query_fireAndForget;
  194. true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement