Advertisement
FlacoBey

Untitled

Jan 16th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.96 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.         if(bHasLaser[client] == 1)
  57.         {
  58.             PrintHintText(client, "У тебя нету лазера.");
  59.         }
  60.     }
  61. }
  62.  
  63. stock L4D2_GetWeaponUpgrades(weapon)
  64. {
  65.     return GetEntProp(weapon, Prop_Send, "m_upgradeBitVec");
  66. }
  67.  
  68. stock CheatCommand(client, const String:command[], const String:arguments[])
  69. {
  70.     if (!client) return;
  71.     new admindata = GetUserFlagBits(client);
  72.     SetUserFlagBits(client, ADMFLAG_ROOT);
  73.     new flags = GetCommandFlags(command);
  74.     SetCommandFlags(command, flags & ~FCVAR_CHEAT);
  75.     FakeClientCommand(client, "%s %s", command, arguments);
  76.     SetCommandFlags(command, flags);
  77.     SetUserFlagBits(client, admindata);
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement