FlacoBey

Untitled

Jun 4th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.58 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. float mp5AndUzi = 1.0;
  11.  
  12.  
  13. public APLRes AskPluginLoad2(Handle plugin, bool late, char[] erro, int errMax)
  14. {
  15.     lateLoad = late;
  16.     return APLRes_Success;    
  17. }
  18.  
  19. public void OnPluginStart()
  20. {
  21.     if (lateLoad)
  22.     {
  23.         for (int client = 1; client <= MaxClients; client++)
  24.         {
  25.             if (IsClientInGame(client))
  26.             {
  27.                 OnClientPutInServer(client);
  28.             }
  29.         }
  30.     }
  31. }
  32.  
  33. public void OnClientPutInServer(int client)
  34. {
  35.     SDKHook(client, SDKHook_TraceAttack, OnTakeDamage);
  36. }
  37.  
  38. public void OnClientDisconnect(int client)
  39. {
  40.     SDKUnhook(client, SDKHook_TraceAttack, OnTakeDamage);
  41. }
  42.  
  43. public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
  44. {
  45.     if (damagetype & DMG_BULLET)
  46.     {
  47.         if (IsValidClient(attacker))
  48.         {
  49.             if(IsValidClient(victim))
  50.             {
  51.                 char classname[64];
  52.                 GetClientWeapon(attacker, classname, sizeof(classname));
  53.                 if(StrEqual(classname, "weapon_melee"))
  54.                 {
  55.                     GetEntPropString(GetPlayerWeaponSlot(attacker, 1), Prop_Data, "m_strMapSetScriptName", classname, sizeof(classname));
  56.                 }
  57.                 int vClass = GetEntProp(victim, Prop_Send, "m_zombieClass");
  58.                 switch(vClass)
  59.                 {
  60.                     case 9:
  61.                     {
  62.                         if(StrEqual(classname, "knife"))
  63.                         {
  64.                             damage = knife;
  65.                             if(hitgroup == 1) ForcePlayerSuicide(victim);
  66.                             return Plugin_Changed;
  67.                         }
  68.                         else if(StrEqual(classname, "katana") || StrEqual(classname, "fireaxe"))
  69.                         {
  70.                             damage = KatanaAndTopor;
  71.                             if(hitgroup == 1) ForcePlayerSuicide(victim);
  72.                             return Plugin_Changed;
  73.                         }
  74.                         else if(StrEqual(classname, "machete") || StrEqual(classname, "crowbar"))
  75.                         {
  76.                             damage = CrowbarAndMachete;
  77.                             if(hitgroup == 1) ForcePlayerSuicide(victim);
  78.                             return Plugin_Changed;
  79.                         }
  80.                         else
  81.                         {
  82.                             damage = ForAllMelees;
  83.                             if(hitgroup == 1) ForcePlayerSuicide(victim);
  84.                             return Plugin_Changed;
  85.                         }
  86.                     }
  87.                 }
  88.             }
  89.         }
  90.     }
  91.     return Plugin_Continue;
  92. }
  93.  
  94. public bool IsValidClient(int client)
  95. {
  96.     if (client <= 0)
  97.         return false;
  98.        
  99.     if (client > MaxClients)
  100.         return false;
  101.        
  102.     if (!IsClientInGame(client))
  103.         return false;
  104.        
  105.     if (!IsPlayerAlive(client))
  106.         return false;
  107.  
  108.     return true;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment