FlacoBey

Untitled

Jan 1st, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.15 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4.  
  5. #pragma semicolon 1
  6.  
  7. #define ZOMBIECLASS_CHARGER 6
  8.  
  9. new bool:lateLoad;
  10.  
  11. public APLRes:AskPluginLoad2(Handle:plugin, bool:late, String:error[], errMax)
  12. {
  13.     lateLoad = late;
  14.     return APLRes_Success;    
  15. }
  16.  
  17. public OnPluginStart()
  18. {
  19.     if (lateLoad)
  20.     {
  21.         for (new client = 1; client <= MaxClients; client++)
  22.         {
  23.             if (IsClientInGame(client))
  24.             {
  25.                 OnClientPutInServer(client);
  26.             }
  27.         }
  28.     }
  29.     char path[PLATFORM_MAX_PATH];
  30.     BuildPath(Path_SM, path, PLATFORM_MAX_PATH, "data/damage.ini");
  31.  
  32.     KvWriteToFile(path);
  33. }
  34.  
  35. void KvWriteToFile(const char[] path)
  36. {
  37.     KeyValues kv = new KeyValues("damage_modifier");
  38.     kv.SetNum("weapon_autoshotgun/damage_m", 1);
  39.     kv.SetNum("weapon_hunting_rifle/damage_m", 1);
  40.     kv.SetNum("weapon_pistol/damage_m", 1);
  41.     kv.SetNum("weapon_rifle_ak47/damage_m", 1);
  42.     kv.SetNum("weapon_rifle/damage_m", 1);
  43.     kv.SetNum("weapon_pumpshotgun/damage_m", 1);
  44.     kv.SetNum("weapon_sniper_awp/damage_m", 1);
  45.     kv.SetNum("weapon_machete/damage_m", 1);
  46.     kv.SetNum("weapon_fireaxe/damage_m", 1);
  47.  
  48.  
  49.     kv.ExportToFile(path);
  50.  
  51.     delete kv;
  52. }
  53.  
  54. public OnClientPutInServer(client)
  55. {
  56.     SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  57. }
  58.  
  59. public OnClientDisconnect(client)
  60. {
  61.     SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  62. }
  63.  
  64. public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)  
  65. {
  66.    
  67.     char pathKey[128];
  68.     KeyValues kv = new KeyValues("damage_modifier");
  69.     if (kv.ImportFromFile(pathKey))
  70.     {
  71.         if(bIsSurvivor(attacker))
  72.         {
  73.             decl String:classname[64];
  74.             GetClientWeapon(attacker, classname, sizeof(classname));
  75.            
  76.             char b[64];
  77.             KvGetSectionName(kv, b, sizeof(b));
  78.             if (StrEqual(b, classname))
  79.             {
  80.                 new num = KvGetNum(kv, "damage_m", 1);
  81.                 damage *= num;
  82.                 int health = GetClientHealth(victim);
  83.                 PrintToChatAll("%i", health);
  84.                 return Plugin_Changed;
  85.             }
  86.         }
  87.     }
  88.     return Plugin_Continue;
  89. }
  90.  
  91. stock bool bIsSurvivor(int client)
  92. {
  93.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  94. }
Advertisement
Add Comment
Please, Sign In to add comment