Advertisement
FlacoBey

Untitled

Feb 2nd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4.  
  5. #pragma semicolon 1
  6.  
  7. new bool:lateLoad;
  8. char sDataFilePath[PLATFORM_MAX_PATH];
  9.  
  10. public APLRes:AskPluginLoad2(Handle:plugin, bool:late, String:error[], errMax)
  11. {
  12.     lateLoad = late;
  13.     return APLRes_Success;    
  14. }
  15.  
  16. public OnPluginStart()
  17. {
  18.     if (lateLoad)
  19.     {
  20.         for (new client = 1; client <= MaxClients; client++)
  21.         {
  22.             if (IsClientInGame(client))
  23.             {
  24.                 OnClientPutInServer(client);
  25.             }
  26.         }
  27.     }
  28.     BuildPath(Path_SM, sDataFilePath, sizeof(sDataFilePath), "data/weapons_ff.ini");
  29.     if (!FileExists(sDataFilePath))
  30.     {
  31.         new Handle:open_path = OpenFile(sDataFilePath, "w");
  32.         WriteFileLine(open_path, "");
  33.         CloseHandle(open_path);
  34.         PrintToServer("Error Code: WSP-EC-01A");
  35.         KvWriteToFile(sDataFilePath);
  36.     }
  37. }
  38.  
  39. void KvWriteToFile(const char[] path)
  40. {
  41.     KeyValues kv = new KeyValues("FireOfExplosive");
  42.     kv.SetFloat("weapon_grenade_launcher/explosive", 1.0);
  43.  
  44.  
  45.     kv.ExportToFile(path);
  46.  
  47.     delete kv;
  48. }
  49.  
  50. public OnClientPutInServer(client)
  51. {
  52.     SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  53. }
  54.  
  55. public OnClientDisconnect(client)
  56. {
  57.     SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  58. }
  59.  
  60. public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)  
  61. {
  62.     if (damagetype & DMG_BLAST)
  63.     {
  64.         KeyValues kv = new KeyValues("FireOfExplosive");
  65.         if (kv.ImportFromFile(sDataFilePath))
  66.         {
  67.             float num = KvGetFloat(kv, "explosive", 1.0);
  68.             damage = num;
  69.             return Plugin_Changed;
  70.         }
  71.     }
  72.  
  73.     return Plugin_Continue;
  74. }
  75.  
  76. public IsValidClient(client)
  77. {
  78.     if (client <= 0)
  79.         return false;
  80.        
  81.     if (client > MaxClients)
  82.         return false;
  83.        
  84.     if (!IsClientInGame(client))
  85.         return false;
  86.        
  87.     if (!IsPlayerAlive(client))
  88.         return false;
  89.  
  90.     return true;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement