FlacoBey

Untitled

Dec 27th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. #include sdktools
  2.  
  3. #define L4D2_WEPUPGFLAG_LASER  (1 << 2)
  4.  
  5. static int bHasLaser[MAXPLAYERS+1] = 0;
  6.  
  7. public OnMapStart()
  8. {
  9.     for(int i = 1; i <= MaxClients; ++i)
  10.     {
  11.          bHasLaser[i] = 0;
  12.     }
  13. }
  14.  
  15. public OnPluginStart()
  16. {
  17.     RegConsoleCmd("sm_l", LaserTake);
  18. }
  19.  
  20. public Action:LaserTake(client, args)  
  21. {
  22.     new priWeapon = GetPlayerWeaponSlot(client, 0);
  23.     if (priWeapon <= 0 || !IsValidEntity(priWeapon))
  24.     return;
  25.    
  26.     new upgrades = L4D2_GetWeaponUpgrades(priWeapon);
  27.     if (upgrades & L4D2_WEPUPGFLAG_LASER)
  28.     {
  29.         if (bHasLaser[client] == 0)
  30.         {
  31.             CheatCommand(client, "upgrade_remove", "LASER_SIGHT");
  32.             bHasLaser[client]++;
  33.             PrintHintText(client,"Лазер снят");
  34.         }
  35.     }
  36.     if (upgrades != L4D2_WEPUPGFLAG_LASER)
  37.     {
  38.         if (bHasLaser[client] == 1)
  39.         {
  40.             CheatCommand(client, "upgrade_add", "LASER_SIGHT");
  41.             bHasLaser[client] = false;
  42.             PrintHintText(client,"Лазер устоновлен");
  43.         }
  44.     }
  45. }
  46.  
  47. stock L4D2_GetWeaponUpgrades(weapon)
  48. {
  49.     return GetEntProp(weapon, Prop_Send, "m_upgradeBitVec");
  50. }
  51.  
  52. stock CheatCommand(client, const String:command[], const String:arguments[])
  53. {
  54.     if (!client) return;
  55.     new admindata = GetUserFlagBits(client);
  56.     SetUserFlagBits(client, ADMFLAG_ROOT);
  57.     new flags = GetCommandFlags(command);
  58.     SetCommandFlags(command, flags & ~FCVAR_CHEAT);
  59.     FakeClientCommand(client, "%s %s", command, arguments);
  60.     SetCommandFlags(command, flags);
  61.     SetUserFlagBits(client, admindata);
  62. }
Advertisement
Add Comment
Please, Sign In to add comment