FlacoBey

Untitled

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