Advertisement
FlacoBey

Untitled

Jun 7th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.10 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 = 100.0;
  11. float KatanaAndTopor = 500.0;
  12. float CrowbarAndMachete = 400.0;
  13. float knife = 300.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.                 else
  61.                 {
  62.                     return Plugin_Continue;
  63.                 }
  64.                 int vClass = GetEntProp(victim, Prop_Send, "m_zombieClass");
  65.                 switch(vClass)
  66.                 {
  67.                     case 9:
  68.                     {
  69.                         if(StrEqual(classname, "knife"))
  70.                         {
  71.                             damage = knife;
  72.                             return Plugin_Changed;
  73.                         }
  74.                         else if(StrEqual(classname, "katana") || StrEqual(classname, "fireaxe"))
  75.                         {
  76.                             damage = KatanaAndTopor;
  77.                             return Plugin_Changed;
  78.                         }
  79.                         else if(StrEqual(classname, "machete") || StrEqual(classname, "crowbar"))
  80.                         {
  81.                             damage = CrowbarAndMachete;
  82.                             return Plugin_Changed;
  83.                         }
  84.                         else
  85.                         {
  86.                             damage = ForAllMelees;
  87.                             return Plugin_Changed;
  88.                         }
  89.                     }
  90.                 }
  91.             }
  92.         }
  93.     }
  94.     return Plugin_Continue;
  95. }
  96.  
  97. public bool IsValidClient(int client)
  98. {
  99.     if (client <= 0)
  100.         return false;
  101.        
  102.     if (client > MaxClients)
  103.         return false;
  104.        
  105.     if (!IsClientInGame(client))
  106.         return false;
  107.        
  108.     if (!IsPlayerAlive(client))
  109.         return false;
  110.  
  111.     return true;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement