FlacoBey

Untitled

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