FlacoBey

Untitled

Jan 16th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. #include sdktools
  2.  
  3. #define L4D2_WEPUPGFLAG_LASER  (1 << 2)
  4.  
  5. static int bHasLaser[MAXPLAYERS+1] = 0;
  6. public void OnMapStart()
  7. {
  8.     decl String:map[128];
  9.     GetCurrentMap(map, 128);
  10.     if (StrContains(map, "m1", false) != -1)
  11.     {
  12.         for(int i = 1; i <= MaxClients; ++i)
  13.         {
  14.             bHasLaser[i] = 0;
  15.         }
  16.     }
  17. }
  18.  
  19. public void OnPluginStart()
  20. {
  21.     RegConsoleCmd("sm_l", CmdLaserToggle);
  22.     HookEvent("player_death", PlayerLoseLaser);
  23. }
  24.  
  25. public Action PlayerLoseLaser(Event event, const char[] name, bool dontBroadcast)
  26. {
  27.     int death = GetClientOfUserId(event.GetInt("userid"));
  28.     bHasLaser[death] = 0;
  29. }
  30.  
  31. public Action:CmdLaserToggle(client, args)
  32. {
  33.     new priWeapon = GetPlayerWeaponSlot(client, 0);
  34.     if (priWeapon <= 0 || !IsValidEntity(priWeapon))
  35.     return;
  36.    
  37.     new upgrades = L4D2_GetWeaponUpgrades(priWeapon);
  38.     if (upgrades & L4D2_WEPUPGFLAG_LASER)
  39.     {
  40.         if (bHasLaser[client])
  41.         {
  42.             PrintHintText(client, "Зачем тебе ещё 1 лазер?");
  43.         }
  44.         CheatCommand(client, "upgrade_remove", "LASER_SIGHT");
  45.         bHasLaser[client]++;
  46.         PrintHintText(client, "Лазер снят.");
  47.     }
  48.     if (upgrades != L4D2_WEPUPGFLAG_LASER)
  49.     {
  50.         if (bHasLaser[client] == 1)
  51.         {
  52.             CheatCommand(client, "upgrade_add", "LASER_SIGHT");
  53.             bHasLaser[client] = 0;
  54.             PrintHintText(client, "Лазер установлен.");
  55.         }
  56.         PrintHintText(client, "У тебя нету лазера.");
  57.     }
  58. }
  59.  
  60. stock L4D2_GetWeaponUpgrades(weapon)
  61. {
  62.     return GetEntProp(weapon, Prop_Send, "m_upgradeBitVec");
  63. }
  64.  
  65. stock CheatCommand(client, const String:command[], const String:arguments[])
  66. {
  67.     if (!client) return;
  68.     new admindata = GetUserFlagBits(client);
  69.     SetUserFlagBits(client, ADMFLAG_ROOT);
  70.     new flags = GetCommandFlags(command);
  71.     SetCommandFlags(command, flags & ~FCVAR_CHEAT);
  72.     FakeClientCommand(client, "%s %s", command, arguments);
  73.     SetCommandFlags(command, flags);
  74.     SetUserFlagBits(client, admindata);
  75. }
Advertisement
Add Comment
Please, Sign In to add comment