FlacoBey

Untitled

Jun 10th, 2019
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.81 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.     if (!(damagetype & DMG_BURN && damagetype & DMG_BLAST))
  52.     {
  53.         if (IsValidClient(attacker) && GetClientTeam(attacker) == 2)
  54.         {
  55.             if(IsValidClient(victim) && GetClientTeam(victim) == 2)
  56.             {
  57.                 if(hitgroup == 3 || hitgroup == 2)
  58.                 {
  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.     }
  162.     return Plugin_Continue;
  163. }
  164. public bool IsValidClient(int client)
  165. {
  166.     if (client <= 0)
  167.         return false;
  168.        
  169.     if (client > MaxClients)
  170.         return false;
  171.        
  172.     if (!IsClientInGame(client))
  173.         return false;
  174.        
  175.     if (!IsPlayerAlive(client))
  176.         return false;
  177.  
  178.     return true;
  179. }
  180.  
  181. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  182. {
  183.     float victim_origin[3];
  184.     char rupture[32];
  185.     char damage_victim[32];
  186.     IntToString(damage, rupture, sizeof(rupture));
  187.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  188.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  189.     int entity = CreateEntityByName("point_hurt");
  190.     DispatchKeyValue(victim, "targetname", damage_victim);
  191.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  192.     DispatchKeyValue(entity, "Damage", rupture);
  193.     DispatchSpawn(entity);
  194.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  195.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  196.     DispatchKeyValue(entity, "classname", "point_hurt");
  197.     DispatchKeyValue(victim, "targetname", "null");
  198.     AcceptEntityInput(entity, "Kill");
  199. }
Advertisement
Add Comment
Please, Sign In to add comment