FlacoBey

Untitled

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