FlacoBey

Untitled

Dec 26th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. #include sdktools
  2.  
  3. #define L4D2_WEPUPGFLAG_LASER  (1 << 2)
  4.  
  5. static bool:bHasLaser[MAXPLAYERS+1]             = false;
  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] == false)
  22.         {
  23.             CheatCommand(client, "upgrade_remove", "LASER_SIGHT");
  24.             bHasLaser[client] = true;
  25.             PrintHintText(client,"+1 lazer");
  26.         }
  27.         if (bHasLaser[client] == true)
  28.         {
  29.             bHasLaser[client] = true;
  30.             PrintHintText(client,"У тебя уже есть лазер");
  31.         }
  32.     }
  33.     new CurrentUpgrades = L4D2_GetWeaponUpgrades(priWeapon);
  34.     if (!CurrentUpgrades)
  35.     {
  36.         if (bHasLaser[client] == true)
  37.         {
  38.             CheatCommand(client, "upgrade_add", "LASER_SIGHT");
  39.             bHasLaser[client] = false;
  40.             PrintHintText(client,"Ti postavil lazer");
  41.         }
  42.     }
  43. }
  44.  
  45. stock L4D2_GetWeaponUpgrades(weapon)
  46. {
  47.     return GetEntProp(weapon, Prop_Send, "m_upgradeBitVec");
  48. }
  49.  
  50. stock CheatCommand(client, const String:command[], const String:arguments[])
  51. {
  52.     if (!client) return;
  53.     new admindata = GetUserFlagBits(client);
  54.     SetUserFlagBits(client, ADMFLAG_ROOT);
  55.     new flags = GetCommandFlags(command);
  56.     SetCommandFlags(command, flags & ~FCVAR_CHEAT);
  57.     FakeClientCommand(client, "%s %s", command, arguments);
  58.     SetCommandFlags(command, flags);
  59.     SetUserFlagBits(client, admindata);
  60. }
Add Comment
Please, Sign In to add comment