FlacoBey

Untitled

Dec 27th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 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.     decl String:map[128];    
  10.     GetCurrentMap(map, 128);
  11.     if (StrContains(map, "m1", false))
  12.     {
  13.         for(int i = 1; i <= MaxClients; ++i)
  14.         {
  15.             bHasLaser[i] = 0;
  16.         }
  17.     }
  18. }
  19.  
  20. public OnPluginStart()
  21. {
  22.     RegConsoleCmd("sm_l", CmdLaserToggle);
  23. }
  24.  
  25. public Action:CmdLaserToggle(client, args)
  26. {
  27.     new priWeapon = GetPlayerWeaponSlot(client, 0);
  28.     if (priWeapon <= 0 || !IsValidEntity(priWeapon))
  29.     return;
  30.    
  31.     new upgrades = L4D2_GetWeaponUpgrades(priWeapon);
  32.     if (upgrades & L4D2_WEPUPGFLAG_LASER)
  33.     {
  34.         if (bHasLaser[client] == 0)
  35.         {
  36.             CheatCommand(client, "upgrade_remove", "LASER_SIGHT");
  37.             bHasLaser[client]++;
  38.             PrintHintText(client,"Лазер снят");
  39.         }
  40.         else
  41.         {
  42.             PrintHintText(client,"Зачем тебе ещё 1 лазер?");
  43.         }
  44.     }
  45.     if (upgrades != L4D2_WEPUPGFLAG_LASER)
  46.     {
  47.         if (bHasLaser[client] == 1)
  48.         {
  49.             CheatCommand(client, "upgrade_add", "LASER_SIGHT");
  50.             bHasLaser[client] = false;
  51.             PrintHintText(client,"Лазер установлен");
  52.         }
  53.     }
  54. }
  55.  
  56. stock L4D2_GetWeaponUpgrades(weapon)
  57. {
  58.     return GetEntProp(weapon, Prop_Send, "m_upgradeBitVec");
  59. }
  60.  
  61. stock CheatCommand(client, const String:command[], const String:arguments[])
  62. {
  63.     if (!client) return;
  64.     new admindata = GetUserFlagBits(client);
  65.     SetUserFlagBits(client, ADMFLAG_ROOT);
  66.     new flags = GetCommandFlags(command);
  67.     SetCommandFlags(command, flags & ~FCVAR_CHEAT);
  68.     FakeClientCommand(client, "%s %s", command, arguments);
  69.     SetCommandFlags(command, flags);
  70.     SetUserFlagBits(client, admindata);
  71. }
Advertisement
Add Comment
Please, Sign In to add comment