FlacoBey

Untitled

Dec 27th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 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.         else
  36.         {
  37.             PrintHintText(client,"Зачем тебе ещё 1 лазер?");
  38.         }
  39.     }
  40.     if (upgrades != L4D2_WEPUPGFLAG_LASER)
  41.     {
  42.         if (bHasLaser[client] == 1)
  43.         {
  44.             CheatCommand(client, "upgrade_add", "LASER_SIGHT");
  45.             bHasLaser[client] = 0;
  46.             PrintHintText(client,"Лазер устоновлен");
  47.         }
  48.     }
  49. }
  50.  
  51. stock L4D2_GetWeaponUpgrades(weapon)
  52. {
  53.     return GetEntProp(weapon, Prop_Send, "m_upgradeBitVec");
  54. }
  55.  
  56. stock CheatCommand(client, const String:command[], const String:arguments[])
  57. {
  58.     if (!client) return;
  59.     new admindata = GetUserFlagBits(client);
  60.     SetUserFlagBits(client, ADMFLAG_ROOT);
  61.     new flags = GetCommandFlags(command);
  62.     SetCommandFlags(command, flags & ~FCVAR_CHEAT);
  63.     FakeClientCommand(client, "%s %s", command, arguments);
  64.     SetCommandFlags(command, flags);
  65.     SetUserFlagBits(client, admindata);
  66. }
Advertisement
Add Comment
Please, Sign In to add comment