HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <sourcemod>
  2. #include <sdkhooks>
  3.  
  4. new Handle:cVarMinDistanceShow;
  5. new Handle:cVarMinDistanceKill;
  6. new Float:MinDistanceShow;
  7. new Float:MinDistanceKill;
  8. new totalDamage[MAXPLAYERS+1];
  9. new kills[MAXPLAYERS+1];
  10. new Float:ClassDefence[] = {5.0,10.0,15.0,15.0,40.0,25.0,30.0,45.0,50.0 }
  11. new Float:HitGroupKoeffitient[] = {
  12. 1.0,
  13. 1.25, // Head
  14. 1.0, // Chest
  15. 1.0,
  16. 1.0, // LArm
  17. 1.0, // RArm
  18. 0.75, //LLeg
  19. 0.75, // RLeg
  20. 1.3 // Neck
  21. };
  22.  
  23. public Plugin:myinfo = {
  24. name = "Damage&Distance Show",
  25. author = "Namolem",
  26. description = "0",
  27. version = "1.0.0.0",
  28. url = "0"
  29. };
  30.  
  31. public OnPluginStart()
  32. {
  33. HookEvent("player_spawn",PlayerSpawnEvent);
  34. CreateTimer(0.75,ShowHud,_,TIMER_REPEAT);
  35. LoadTranslations("plugin.dmgshow.phrases");
  36. for (new client = 1; client <= MAXPLAYERS; client++)
  37. {
  38. if (ValidPlayer(client))
  39. {
  40. SDKHook(client,SDKHook_TraceAttack,SDK_Forwarded_TraceAttack);
  41. }
  42. }
  43. cVarMinDistanceShow = CreateConVar("dmgshow_distance_show","15","Minimum tavolsag meterben",_,true,0.0);
  44. cVarMinDistanceKill = CreateConVar("dmgshow_distance_kill","40","Minimum tavolsag olesnnel, meterben",_,true,0.0);
  45. CreateConVar("dmgshow_version","1.0","Damage&Distance show plugin version",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  46. MinDistanceShow = GetConVarFloat(cVarMinDistanceShow)/0.03048;
  47. MinDistanceKill = GetConVarFloat(cVarMinDistanceKill)/0.03048;
  48. HookConVarChange(cVarMinDistanceKill,ConVarChange);
  49. HookConVarChange(cVarMinDistanceShow,ConVarChange);
  50. }
  51.  
  52. public ConVarChange(Handle:convar, const String:oldValue[], const String:newValue[])
  53. {
  54. MinDistanceShow = GetConVarFloat(cVarMinDistanceShow)/0.03048;
  55. MinDistanceKill = GetConVarFloat(cVarMinDistanceKill)/0.03048;
  56. }
  57. public OnPluginEnd()
  58. {
  59. for (new client = 1;client <= MAXPLAYERS;client++)
  60. {
  61. if (ValidPlayer(client))
  62. {
  63. SDKUnhook(client,SDKHook_TraceAttack,SDK_Forwarded_TraceAttack);
  64. }
  65. }
  66. }
  67.  
  68. public OnClientPutInServer(client)
  69. {
  70. SDKHook(client,SDKHook_TraceAttack,SDK_Forwarded_TraceAttack);
  71. }
  72. public OnClientDisconnect(client)
  73. {
  74. SDKUnhook(client,SDKHook_TraceAttack,SDK_Forwarded_TraceAttack);
  75. }
  76. public Action:SDK_Forwarded_TraceAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
  77. {
  78. decl Float:victimVec[3];
  79. decl Float:attackerVec[3];
  80. GetClientAbsOrigin(victim,victimVec);
  81. GetClientAbsOrigin(attacker,attackerVec);
  82. new Float:distance = GetVectorDistance(victimVec,attackerVec);
  83. if (distance >= MinDistanceKill)
  84. damage = 333.0;
  85. new Float:realDamage = (HitGroupKoeffitient[hitgroup]*damage*(100.0-ClassDefence[GetEntProp(victim, Prop_Send, "m_iClass")]))/100.0;
  86. if (distance >= MinDistanceShow)
  87. {
  88. PrintCenterText(attacker,"%t","HP METERS",RoundFloat( realDamage ),distance*0.03048);
  89. }
  90. else
  91. {
  92. PrintCenterText(attacker,"%t","HP",RoundFloat( realDamage ));
  93. }
  94. totalDamage[attacker] += RoundFloat(realDamage);
  95. if (realDamage >= GetClientHealth(victim))
  96. kills[attacker]++;
  97. ShowHud(INVALID_HANDLE);
  98. return Plugin_Changed;
  99. }
  100. stock bool:ValidPlayer(client,bool:check_alive=false){
  101. if(client>0 && client<=MaxClients && IsClientConnected(client) && IsClientInGame(client))
  102. {
  103. if(check_alive && !IsPlayerAlive(client))
  104. {
  105. return false;
  106. }
  107. return true;
  108. }
  109. return false;
  110. }
  111. public PlayerSpawnEvent(Handle:event, const String:name[], bool:dontBroadcast)
  112. {
  113. new client = GetClientOfUserId(GetEventInt(event,"userid"));
  114. totalDamage[client] = 0;
  115. kills[client] = 0;
  116. ShowHud(INVALID_HANDLE);
  117. }
  118. public Action:ShowHud(Handle:timer)
  119. {
  120. for (new player=1;player<=MAXPLAYERS;player++)
  121. {
  122. if (!ValidPlayer(player) || IsFakeClient(player) || GetClientTeam(player) < 2) continue;
  123. if (IsPlayerAlive(player))
  124. {
  125. PrintHintText(player,"%T","HP KILLED DAMAGE",player,GetClientHealth(player),kills[player],totalDamage[player]);
  126. }
  127. else
  128. {
  129. PrintHintText(player,"%T","KILLED DAMAGE",player,kills[player],totalDamage[player]);
  130. }
  131. }
  132. }