FlacoBey

Untitled

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