FlacoBey

Untitled

Jan 4th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.99 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4.  
  5. #pragma semicolon 1
  6.  
  7. #define ZOMBIECLASS_SMOKER    1
  8. #define ZOMBIECLASS_BOOMER    2
  9. #define ZOMBIECLASS_HUNTER    3
  10. #define ZOMBIECLASS_SPITTER   4
  11. #define ZOMBIECLASS_JOCKEY    5
  12. #define ZOMBIECLASS_CHARGER   6
  13. #define ZOMBIECLASS_WITCH     7
  14. #define ZOMBIECLASS_TANK      8
  15.  
  16. new bool:lateLoad;
  17. char sDataFilePath[PLATFORM_MAX_PATH];
  18.  
  19. public APLRes:AskPluginLoad2(Handle:plugin, bool:late, String:error[], errMax)
  20. {
  21.     lateLoad = late;
  22.     return APLRes_Success;    
  23. }
  24.  
  25. public OnPluginStart()
  26. {
  27.     if (lateLoad)
  28.     {
  29.         for (new client = 1; client <= MaxClients; client++)
  30.         {
  31.             if (IsClientInGame(client))
  32.             {
  33.                 OnClientPutInServer(client);
  34.             }
  35.         }
  36.     }
  37.     BuildPath(Path_SM, sDataFilePath, sizeof(sDataFilePath), "data/melee_damage.ini");
  38.     if (!FileExists(sDataFilePath))
  39.     {
  40.         new Handle:open_path = OpenFile(sDataFilePath, "w");
  41.         WriteFileLine(open_path, "");
  42.         CloseHandle(open_path);
  43.         PrintToServer("Error Code: WSP-EC-01A");
  44.         KvWriteToFile(sDataFilePath);
  45.     }
  46. }
  47.  
  48. void KvWriteToFile(const char[] path)
  49. {
  50.     KeyValues kv = new KeyValues("damage_melee");
  51.     kv.SetNum("ZOMBIECLASS_SMOKER/damage", 1);
  52.     kv.SetNum("ZOMBIECLASS_BOOMER/damage", 1);
  53.     kv.SetNum("ZOMBIECLASS_HUNTER/damage", 1);
  54.     kv.SetNum("ZOMBIECLASS_SPITTER/damage", 1);
  55.     kv.SetNum("ZOMBIECLASS_JOCKEY/damage", 1);
  56.     kv.SetNum("ZOMBIECLASS_CHARGER/damage", 1);
  57.     kv.SetNum("ZOMBIECLASS_TANK/damage", 1);
  58.  
  59.     kv.ExportToFile(path);
  60.  
  61.     delete kv;
  62. }
  63.  
  64. public OnClientPutInServer(client)
  65. {
  66.     SDKHook(client, SDKHook_TraceAttack, _SI_OnTraceAttack);
  67. }
  68.  
  69. public OnClientDisconnect(client)
  70. {
  71.     SDKUnhook(client, SDKHook_TraceAttack, _SI_OnTraceAttack);
  72. }
  73.  
  74. public Action:_SI_OnTraceAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
  75. {
  76.     decl String:clsname[64];
  77.     GetEdictClassname(inflictor, clsname, 64);
  78.     if (StrEqual(clsname, "weapon_melee"))
  79.     {
  80.         KeyValues kv = new KeyValues("damage_melee");
  81.         if (kv.ImportFromFile(sDataFilePath))
  82.         {
  83.             new num = KvGetNum(kv, "damage", 1);
  84.             if(GetEntProp(victim, Prop_Send, "m_zombieClass") == 1)
  85.             {
  86.                 if (KvJumpToKey(kv, "ZOMBIECLASS_SMOKER", true))
  87.                 {
  88.                     int heal = GetClientHealth(victim);
  89.                     PrintToChatAll("Smoker=%i", heal);
  90.                     damage += (damage * 0) + num;
  91.                 }
  92.             }
  93.             else if(GetEntProp(victim, Prop_Send, "m_zombieClass") == 2)
  94.             {
  95.                 if (KvJumpToKey(kv, "ZOMBIECLASS_BOOMER", true))
  96.                 {
  97.                     int heal = GetClientHealth(victim);
  98.                     PrintToChatAll("Boomer=%i", heal);
  99.                     damage += (damage * 0) + num;
  100.                 }
  101.             }
  102.             else if(GetEntProp(victim, Prop_Send, "m_zombieClass") == 3)
  103.             {
  104.                 if (KvJumpToKey(kv, "ZOMBIECLASS_HUNTER", true))
  105.                 {
  106.                     int heal = GetClientHealth(victim);
  107.                     PrintToChatAll("Hunter=%i", heal);
  108.                     damage += (damage * 0) + num;
  109.                 }
  110.             }
  111.             else if(GetEntProp(victim, Prop_Send, "m_zombieClass") == 4)
  112.             {
  113.                 if (KvJumpToKey(kv, "ZOMBIECLASS_SPITTER", true))
  114.                 {
  115.                     int heal = GetClientHealth(victim);
  116.                     PrintToChatAll("Spitter=%i", heal);
  117.                     damage += (damage * 0) + num;
  118.                 }
  119.             }
  120.             else if(GetEntProp(victim, Prop_Send, "m_zombieClass") == 5)
  121.             {
  122.                 if (KvJumpToKey(kv, "ZOMBIECLASS_JOCKEY", true))
  123.                 {
  124.                     int heal = GetClientHealth(victim);
  125.                     PrintToChatAll("Jockey=%i", heal);
  126.                     damage += (damage * 0) + num;
  127.                 }
  128.             }
  129.             else if(GetEntProp(victim, Prop_Send, "m_zombieClass") == 6)
  130.             {
  131.                 if (KvJumpToKey(kv, "ZOMBIECLASS_CHARGER", true))
  132.                 {
  133.                     int heal = GetClientHealth(victim);
  134.                     PrintToChatAll("Charger=%i", heal);
  135.                     damage += (damage * 0) + num;
  136.                 }
  137.             }
  138.             else if(GetEntProp(victim, Prop_Send, "m_zombieClass") == 7)
  139.             {
  140.                 if (KvJumpToKey(kv, "ZOMBIECLASS_WITCH", true))
  141.                 {
  142.                     int heal = GetClientHealth(victim);
  143.                     PrintToChatAll("Witch=%i", heal);
  144.                     damage += (damage * 0) + num;
  145.                 }
  146.             }
  147.             else if(GetEntProp(victim, Prop_Send, "m_zombieClass") == 8)
  148.             {
  149.                 if (KvJumpToKey(kv, "ZOMBIECLASS_TANK", true))
  150.                 {
  151.                     int heal = GetClientHealth(victim);
  152.                     PrintToChatAll("Tank=%i", heal);
  153.                     damage += (damage * 0) + num;
  154.                 }
  155.             }
  156.         }
  157.     }
  158.     return Plugin_Continue;
  159. }
  160. /*
  161. public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)  
  162. {
  163.     if (!(damagetype & DMG_BURN))
  164.     {
  165.         if (IsValidCharger(victim))
  166.         {
  167.             KeyValues kv = new KeyValues("damage_modifier");
  168.             if (kv.ImportFromFile(sDataFilePath))
  169.             {
  170.                 decl String:classname[64];
  171.                 GetClientWeapon(attacker, classname, sizeof(classname));
  172.                 if (KvJumpToKey(kv, classname, true))
  173.                 {
  174.                     int heal = GetClientHealth(victim);
  175.                     PrintToChatAll("Charger=%i", heal);
  176.                     return Plugin_Changed;
  177.                 }
  178.             }
  179.         }
  180.     }
  181.     return Plugin_Continue;
  182. }
  183. */
  184.  
  185. public IsValidClient(client)
  186. {
  187.     if (client <= 0)
  188.         return false;
  189.        
  190.     if (client > MaxClients)
  191.         return false;
  192.        
  193.     if (!IsClientInGame(client))
  194.         return false;
  195.        
  196.     if (!IsPlayerAlive(client))
  197.         return false;
  198.  
  199.     return true;
  200. }
Advertisement
Add Comment
Please, Sign In to add comment