FlacoBey

Untitled

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