FlacoBey

Untitled

May 31st, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <sourcemod>
  2.  
  3. #pragma semicolon 1
  4. #pragma newdecls required
  5.  
  6. static  float   BLOCKTIME           = 0.3;
  7. static  char    PISTOLNETCLASS[]    = "CPistol";
  8. bool g_bProhibitClientUse[MAXPLAYERS+1];
  9.  
  10. public void OnPluginStart()
  11. {
  12.     HookEvent("player_use",PlayerUse_Event);
  13. }
  14.  
  15. public Action PlayerUse_Event(Handle event, const char[] name, bool dontBroadcast)
  16. {
  17.     char sBuffer[32];
  18.     GetEntityNetClass(GetEventInt(event,"targetid"),sBuffer,sizeof(sBuffer));
  19.    
  20.     if (!StrEqual(PISTOLNETCLASS,sBuffer)){return;}
  21.    
  22.     int client = GetClientOfUserId(GetEventInt(event,"userid"));
  23.    
  24.     g_bProhibitClientUse[client] = true;
  25.     CreateTimer(BLOCKTIME,BlockUse_Timer,client);
  26. }
  27.  
  28. public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
  29. {
  30.     if (!g_bProhibitClientUse[client]) return Plugin_Continue;
  31.     if (!(buttons & IN_USE)) return Plugin_Continue;
  32.    
  33.     buttons = buttons^IN_USE;
  34.    
  35.     return Plugin_Continue;
  36. }
  37.  
  38. public Action BlockUse_Timer(Handle timer, int client)
  39. {
  40.     g_bProhibitClientUse[client] = false;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment