FlacoBey

Untitled

Dec 26th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.86 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 OnPluginStart()
  8. {
  9.     RegConsoleCmd("sm_l", LaserTake);
  10.     HookEvent("map_transition", MapTransition)
  11. }
  12.  
  13. public Action:LaserTake(client, args)  
  14. {
  15.     new priWeapon = GetPlayerWeaponSlot(client, 0);
  16.     if (priWeapon <= 0 || !IsValidEntity(priWeapon))
  17.     return;
  18.    
  19.     new upgrades = L4D2_GetWeaponUpgrades(priWeapon);
  20.     if (upgrades & L4D2_WEPUPGFLAG_LASER)
  21.     {
  22.         if (bHasLaser[client] == 0)
  23.         {
  24.             CheatCommand(client, "upgrade_remove", "LASER_SIGHT");
  25.             bHasLaser[client]++;
  26.             PrintHintText(client,"+1 лазер");
  27.         }
  28.         if (bHasLaser[client] == 1)
  29.         {
  30.             PrintHintText(client,"+1 лазер");
  31.         }
  32.     }
  33.     if (upgrades != L4D2_WEPUPGFLAG_LASER)
  34.     {
  35.         if (bHasLaser[client] == 1)
  36.         {
  37.             CheatCommand(client, "upgrade_add", "LASER_SIGHT");
  38.             bHasLaser[client] = false;
  39.             PrintHintText(client,"Лазер устоновлен");
  40.         }
  41.     }
  42. }
  43.  
  44. public void MapTransition(Event hEvent, const char[] sEvName, bool bDontBroadcast)
  45. {
  46.     CreateTimer(5.0, GiverLaser, TIMER_FLAG_NO_MAPCHANGE);
  47. }
  48.  
  49. public Action GiverLaser(Handle timer, any client)
  50. {
  51.     bHasLaser[client] = 1;
  52. }
  53.  
  54. stock L4D2_GetWeaponUpgrades(weapon)
  55. {
  56.     return GetEntProp(weapon, Prop_Send, "m_upgradeBitVec");
  57. }
  58.  
  59. stock CheatCommand(client, const String:command[], const String:arguments[])
  60. {
  61.     if (!client) return;
  62.     new admindata = GetUserFlagBits(client);
  63.     SetUserFlagBits(client, ADMFLAG_ROOT);
  64.     new flags = GetCommandFlags(command);
  65.     SetCommandFlags(command, flags & ~FCVAR_CHEAT);
  66.     FakeClientCommand(client, "%s %s", command, arguments);
  67.     SetCommandFlags(command, flags);
  68.     SetUserFlagBits(client, admindata);
  69. }
Advertisement
Add Comment
Please, Sign In to add comment