FlacoBey

Untitled

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