FlacoBey

Untitled

Jun 10th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.72 KB | None | 0 0
  1. #include <sdktools>
  2. #include <sdkhooks>
  3.  
  4. #pragma newdecls required
  5. #pragma semicolon 1
  6. #pragma tabsize 0
  7.  
  8. bool lateLoad;
  9.  
  10. int AutoShot = 162;
  11. int Pistol = 300;
  12. int Spas = 198;
  13. int Smg = 348;
  14. int Silenced = 318;
  15. int SSG = 348;
  16. int Pumpshotgun = 216;
  17. int Chrome = 270;
  18.  
  19. public APLRes AskPluginLoad2(Handle plugin, bool late, char[] erro, int errMax)
  20. {
  21.     lateLoad = late;
  22.     return APLRes_Success;    
  23. }
  24.  
  25. public void OnPluginStart()
  26. {
  27.     if (lateLoad)
  28.     {
  29.         for (int client = 1; client <= MaxClients; client++)
  30.         {
  31.             if (IsClientInGame(client))
  32.             {
  33.                 OnClientPutInServer(client);
  34.             }
  35.         }
  36.     }
  37. }
  38.  
  39. public void OnClientPutInServer(int client)
  40. {
  41.     SDKHook(client, SDKHook_TraceAttack, OnTakeDamage);
  42. }
  43.  
  44. public void OnClientDisconnect(int client)
  45. {
  46.     SDKUnhook(client, SDKHook_TraceAttack, OnTakeDamage);
  47. }
  48.  
  49. public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
  50. {
  51.     PrintToChatAll("hg - %i", hitgroup);
  52.     if (!(damagetype & DMG_BURN && damagetype & DMG_BLAST))
  53.     {
  54.         if (IsValidClient(attacker) && GetClientTeam(attacker) == 2)
  55.         {
  56.             if(IsValidClient(victim) && GetClientTeam(victim) == 2)
  57.             {
  58.                 if(hitgroup != 3) return Plugin_Continue;
  59.                 int iEnt = GetEntPropEnt(attacker, Prop_Send, "m_hUseEntity");
  60.                 if(IsValidEdict(iEnt) && iEnt > 0)
  61.                 {
  62.                     char sWeaponEx[32];
  63.                     GetEdictClassname(iEnt, sWeaponEx, sizeof(sWeaponEx));
  64.                     if (StrEqual(sWeaponEx, "prop_minigun") || StrEqual(sWeaponEx, "prop_minigun_l4d1")) return Plugin_Continue;
  65.                 }
  66.                 char classname[64];
  67.                 GetClientWeapon(attacker, classname, sizeof(classname));
  68.                 if(StrEqual(classname, "weapon_melee")) return Plugin_Continue;
  69.                
  70.                 if(StrEqual(classname, "weapon_autoshotgun"))
  71.                 {
  72.                     ForceDamageEntity(attacker, AutoShot, victim);
  73.                     damage = 0.0;
  74.                     return Plugin_Changed;
  75.                 }
  76.                 else if(StrEqual(classname, "weapon_hunting_rifle"))
  77.                 {
  78.                     ForcePlayerSuicide(victim);
  79.                 }
  80.                 else if(StrEqual(classname, "weapon_rifle"))
  81.                 {
  82.                     ForcePlayerSuicide(victim);
  83.                 }
  84.                 else if(StrEqual(classname, "weapon_pistol"))
  85.                 {
  86.                     ForceDamageEntity(attacker, Pistol, victim);
  87.                     damage = 0.0;
  88.                     return Plugin_Changed;
  89.                 }
  90.                 else if(StrEqual(classname, "weapon_pistol_magnum"))
  91.                 {
  92.                     ForcePlayerSuicide(victim);
  93.                 }
  94.                 else if(StrEqual(classname, "weapon_pumpshotgun"))
  95.                 {
  96.                     ForceDamageEntity(attacker, Pumpshotgun, victim);
  97.                     damage = 0.0;
  98.                     return Plugin_Changed;
  99.                 }
  100.                 else if(StrEqual(classname, "weapon_rifle_ak47"))
  101.                 {
  102.                     ForcePlayerSuicide(victim);
  103.                 }
  104.                 else if(StrEqual(classname, "weapon_rifle_desert"))
  105.                 {
  106.                     ForcePlayerSuicide(victim);
  107.                 }
  108.                 else if(StrEqual(classname, "weapon_rifle_m60"))
  109.                 {
  110.                     ForcePlayerSuicide(victim);
  111.                 }
  112.                 else if(StrEqual(classname, "weapon_rifle_sg552"))
  113.                 {
  114.                     ForcePlayerSuicide(victim);
  115.                 }
  116.                 else if(StrEqual(classname, "weapon_shotgun_chrome"))
  117.                 {
  118.                     ForceDamageEntity(attacker, Chrome, victim);
  119.                     damage = 0.0;
  120.                     return Plugin_Changed;
  121.                 }
  122.                 else if(StrEqual(classname, "weapon_shotgun_spas"))
  123.                 {
  124.                     ForceDamageEntity(attacker, Spas, victim);
  125.                     damage = 0.0;
  126.                     return Plugin_Changed;
  127.                 }
  128.                 else if(StrEqual(classname, "weapon_smg"))
  129.                 {
  130.                     ForceDamageEntity(attacker, Smg, victim);
  131.                     damage = 0.0;
  132.                     return Plugin_Changed;
  133.                 }
  134.                 else if(StrEqual(classname, "weapon_smg_mp5"))
  135.                 {
  136.                     ForceDamageEntity(attacker, SSG, victim);
  137.                     damage = 0.0;
  138.                     return Plugin_Changed;
  139.                 }
  140.                 else if(StrEqual(classname, "weapon_smg_silenced"))
  141.                 {
  142.                     ForceDamageEntity(attacker, Silenced, victim);
  143.                     damage = 0.0;
  144.                     return Plugin_Changed;
  145.                 }
  146.                 else if(StrEqual(classname, "weapon_sniper_awp"))
  147.                 {
  148.                     ForcePlayerSuicide(victim);
  149.                 }
  150.                 else if(StrEqual(classname, "weapon_sniper_scout"))
  151.                 {
  152.                     ForcePlayerSuicide(victim);
  153.                 }
  154.                 else if(StrEqual(classname, "weapon_sniper_military"))
  155.                 {
  156.                     ForcePlayerSuicide(victim);
  157.                 }
  158.             }
  159.         }
  160.     }
  161.     return Plugin_Continue;
  162. }
  163. public bool IsValidClient(int client)
  164. {
  165.     if (client <= 0)
  166.         return false;
  167.        
  168.     if (client > MaxClients)
  169.         return false;
  170.        
  171.     if (!IsClientInGame(client))
  172.         return false;
  173.        
  174.     if (!IsPlayerAlive(client))
  175.         return false;
  176.  
  177.     return true;
  178. }
  179.  
  180. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  181. {
  182.     float victim_origin[3];
  183.     char rupture[32];
  184.     char damage_victim[32];
  185.     IntToString(damage, rupture, sizeof(rupture));
  186.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  187.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  188.     int entity = CreateEntityByName("point_hurt");
  189.     DispatchKeyValue(victim, "targetname", damage_victim);
  190.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  191.     DispatchKeyValue(entity, "Damage", rupture);
  192.     DispatchSpawn(entity);
  193.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  194.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  195.     DispatchKeyValue(entity, "classname", "point_hurt");
  196.     DispatchKeyValue(victim, "targetname", "null");
  197.     AcceptEntityInput(entity, "Kill");
  198. }
Advertisement
Add Comment
Please, Sign In to add comment