FlacoBey

Untitled

Dec 26th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 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_haha", CmdLaserToggle);
  10. }
  11.  
  12. public Action:CmdLaserToggle(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,"+1 lazer");
  26.         }
  27.         if (bHasLaser[client] == 1)
  28.         {
  29.             PrintHintText(client,"У тебя уже есть лазер");
  30.         }
  31.     }
  32.     if (upgrades != L4D2_WEPUPGFLAG_LASER)
  33.     {
  34.         if (bHasLaser[client] == 1)
  35.         {
  36.             CheatCommand(client, "upgrade_add", "LASER_SIGHT");
  37.             bHasLaser[client] = false;
  38.             PrintHintText(client,"Ti postavil lazer");
  39.         }
  40.     }
  41. }
  42.  
  43. stock L4D2_GetWeaponUpgrades(weapon)
  44. {
  45.     return GetEntProp(weapon, Prop_Send, "m_upgradeBitVec");
  46. }
  47.  
  48. stock CheatCommand(client, const String:command[], const String:arguments[])
  49. {
  50.     if (!client) return;
  51.     new admindata = GetUserFlagBits(client);
  52.     SetUserFlagBits(client, ADMFLAG_ROOT);
  53.     new flags = GetCommandFlags(command);
  54.     SetCommandFlags(command, flags & ~FCVAR_CHEAT);
  55.     FakeClientCommand(client, "%s %s", command, arguments);
  56.     SetCommandFlags(command, flags);
  57.     SetUserFlagBits(client, admindata);
  58. }
Advertisement
Add Comment
Please, Sign In to add comment