Advertisement
Guest User

Untitled

a guest
Jul 5th, 2021
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdkhooks>
  3.  
  4. #pragma newdecls required
  5. #pragma semicolon 1
  6.  
  7. bool g_bNadeBanned[MAXPLAYERS+1];
  8.  
  9. bool g_bLate;
  10.  
  11. //----------------------------------------------------------------------------------------------------
  12. // Purpose:
  13. //----------------------------------------------------------------------------------------------------
  14. public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int errorSize)
  15. {
  16. g_bLate = bLate;
  17. return APLRes_Success;
  18. }
  19.  
  20. //----------------------------------------------------------------------------------------------------
  21. // Purpose:
  22. //----------------------------------------------------------------------------------------------------
  23. public void OnPluginStart()
  24. {
  25. if (g_bLate)
  26. {
  27. for (int client = 1; client <= MaxClients; client++)
  28. {
  29. if (!IsValidClient(client))
  30. continue;
  31.  
  32. if(IsClientAuthorized(client))
  33. {
  34. char sAuthID[32];
  35. GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID));
  36. OnClientAuthorized(client, sAuthID);
  37. }
  38.  
  39. OnClientPutInServer(client);
  40. }
  41. }
  42.  
  43. }
  44.  
  45. //----------------------------------------------------------------------------------------------------
  46. // Purpose:
  47. //----------------------------------------------------------------------------------------------------
  48. public void OnClientAuthorized(int client, const char[] sAuthID)
  49. {
  50. if (StrEqual(sAuthID, "STEAM_0:0:52720007"))
  51. g_bNadeBanned[client] = true;
  52. }
  53.  
  54. //----------------------------------------------------------------------------------------------------
  55. // Purpose:
  56. //----------------------------------------------------------------------------------------------------
  57. public void OnClientDisconnect(int client)
  58. {
  59. g_bNadeBanned[client] = false;
  60. }
  61.  
  62. //----------------------------------------------------------------------------------------------------
  63. // Purpose:
  64. //----------------------------------------------------------------------------------------------------
  65. public void OnClientPutInServer(int client)
  66. {
  67. if (!IsFakeClient(client))
  68. {
  69. SDKHook(client, SDKHook_WeaponCanUse, OnWeaponTouch);
  70. }
  71. }
  72.  
  73. //----------------------------------------------------------------------------------------------------
  74. // Purpose:
  75. //----------------------------------------------------------------------------------------------------
  76. public Action OnWeaponTouch(int client, int weapon)
  77. {
  78. if (Client_IsValid(client) && Entity_IsValid(weapon))
  79. {
  80. if (!g_bNadeBanned[client])
  81. return Plugin_Continue;
  82.  
  83. char sWeapon[32];
  84. GetEdictClassname(weapon, sWeapon, sizeof(sWeapon));
  85. if (!StrEqual(sWeapon, "weapon_hegrenade"))
  86. return Plugin_Continue;
  87.  
  88. return Plugin_Handled;
  89.  
  90. }
  91. return Plugin_Continue;
  92. }
  93.  
  94. //----------------------------------------------------------------------------------------------------
  95. // Purpose:
  96. //----------------------------------------------------------------------------------------------------
  97. stock bool Client_IsValid(int client, bool checkConnected=true)
  98. {
  99. if (client > 4096) {
  100. client = EntRefToEntIndex(client);
  101. }
  102.  
  103. if (client < 1 || client > MaxClients) {
  104. return false;
  105. }
  106.  
  107. if (checkConnected && !IsClientConnected(client)) {
  108. return false;
  109. }
  110.  
  111. return true;
  112. }
  113.  
  114. //----------------------------------------------------------------------------------------------------
  115. // Purpose:
  116. //----------------------------------------------------------------------------------------------------
  117. stock bool Entity_IsValid(int entity)
  118. {
  119. return IsValidEntity(entity);
  120. }
  121.  
  122. //----------------------------------------------------------------------------------------------------
  123. // Purpose:
  124. //----------------------------------------------------------------------------------------------------
  125. stock bool IsValidClient(int client, bool nobots = true)
  126. {
  127. if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
  128. return false;
  129.  
  130. return IsClientInGame(client);
  131. }
  132.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement