Advertisement
FlacoBey

Untitled

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