Advertisement
supertimor

Untitled

Jan 30th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdkhooks>
  3. #pragma newdecls required
  4. ConVar g_NextHitTime;
  5. bool block[MAXPLAYERS + 1];
  6.  
  7. public Plugin myinfo =
  8. {
  9. name = "HNS - After Knife Block",
  10. author = "SUPER TIMOR",
  11. description = "Makes TT immune to get hurt after knife hit",
  12. version = "1.0",
  13. url = "http://cs-placzabaw.pl"
  14. };
  15. public void OnPluginStart()
  16. {
  17. HookEvent("player_spawn", PlayerSpawn);
  18. g_NextHitTime = CreateConVar("next_hit_time", "3.0", "Float value, that describes time needed to make CT able to hit TT again");
  19.  
  20. AutoExecConfig(true, "hns-akb", "sourcemod");
  21. }
  22. public void OnClientPutInServer(int client)
  23. {
  24. SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  25. block[client] = false;
  26. }
  27. public void OnClientDisconnect(int client)
  28. {
  29. SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  30. block[client] = false;
  31. }
  32. public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
  33. {
  34. if(!IsValidClient(victim) || !IsValidClient(attacker))
  35. return Plugin_Continue;
  36.  
  37. if(GetClientTeam(victim) == 3)
  38. return Plugin_Continue;
  39.  
  40. if(block[victim])
  41. return Plugin_Handled;
  42. else
  43. {
  44. char weapon[32];
  45. GetClientWeapon(attacker, weapon, sizeof(weapon));
  46.  
  47. if((StrContains(weapon, "knife") >= 0 || StrContains(weapon, "bayonet") >= 0) && !block[victim] && IsPlayerAlive(victim))
  48. {
  49. if(damage > 55.0)
  50. {
  51. damage = 55.0;
  52. return Plugin_Changed;
  53. }
  54. KnifeBlock(victim);
  55. }
  56.  
  57. }
  58. return Plugin_Continue;
  59. }
  60. public void KnifeBlock(int client)
  61. {
  62. CreateTimer(g_NextHitTime.FloatValue, NoKnifeBlock, GetClientUserId(client))
  63.  
  64. block[client] = true;
  65. SetEntityRenderMode(client, RENDER_TRANSCOLOR);
  66. SetEntityRenderColor(client, 255, 0, 0, 160);
  67. }
  68. public Action NoKnifeBlock(Handle timer, any userid)
  69. {
  70. int client = GetClientOfUserId(userid);
  71. if (!client)
  72. return Plugin_Stop;
  73.  
  74. block[client] = false;
  75. SetEntityRenderMode(client, RENDER_TRANSCOLOR);
  76. SetEntityRenderColor(client, 255, 255, 255, 255);
  77. return Plugin_Continue;
  78. }
  79. public Action PlayerSpawn(Handle event, char[] name, bool dontBroadcast)
  80. {
  81. int client = GetClientOfUserId(GetEventInt(event, "userid"));
  82. block[client] = false;
  83. }
  84. public bool IsValidClient(int client)
  85. {
  86. if (client <= 0 || client > MaxClients)
  87. return false;
  88.  
  89. if (!IsClientInGame(client))
  90. return false;
  91.  
  92. if (!IsPlayerAlive(client))
  93. return false;
  94.  
  95. return true;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement